diff options
author | bowser0000 <bowser0000@gmail.com> | 2020-08-18 18:56:52 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2020-08-18 18:56:52 -0400 |
commit | 67cb5cc2b84743a936aeb8aa3b9e875b2e24a5ea (patch) | |
tree | 0b10dec7d9598e08c1ec2e57fd44491d45b96593 /src/main/java/me/Danker | |
parent | 976e2efc4991202cf0d2dc86eb0d38a22be4de48 (diff) | |
download | SkyblockMod-67cb5cc2b84743a936aeb8aa3b9e875b2e24a5ea.tar.gz SkyblockMod-67cb5cc2b84743a936aeb8aa3b9e875b2e24a5ea.tar.bz2 SkyblockMod-67cb5cc2b84743a936aeb8aa3b9e875b2e24a5ea.zip |
Fix capitalization of pets
Also move capitalization into Utils
Diffstat (limited to 'src/main/java/me/Danker')
-rw-r--r-- | src/main/java/me/Danker/commands/PetsCommand.java | 15 | ||||
-rw-r--r-- | src/main/java/me/Danker/utils/Utils.java | 10 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/main/java/me/Danker/commands/PetsCommand.java b/src/main/java/me/Danker/commands/PetsCommand.java index 75367ab..4967964 100644 --- a/src/main/java/me/Danker/commands/PetsCommand.java +++ b/src/main/java/me/Danker/commands/PetsCommand.java @@ -51,11 +51,6 @@ public class PetsCommand extends CommandBase { return 100; } - static String capitalize(String string) { - String capitalized = string.substring(0, 1).toUpperCase() + string.substring(1).toLowerCase(); - return capitalized; - } - @Override public String getCommandName() { return "petsof"; @@ -169,7 +164,7 @@ public class PetsCommand extends CommandBase { // Loop through pet rarities for (JsonObject legPet : legendaryPets) { - String petName = capitalize(legPet.get("type").getAsString()); + String petName = Utils.capitalizeString(legPet.get("type").getAsString()); int level = petXpToLevel(legPet.get("exp").getAsDouble(), "LEGENDARY"); String messageToAdd = ""; @@ -183,7 +178,7 @@ public class PetsCommand extends CommandBase { } for (JsonObject epicPet: epicPets) { - String petName = capitalize(epicPet.get("type").getAsString()); + String petName = Utils.capitalizeString(epicPet.get("type").getAsString()); int level = petXpToLevel(epicPet.get("exp").getAsDouble(), "EPIC"); String messageToAdd = ""; @@ -197,7 +192,7 @@ public class PetsCommand extends CommandBase { } for (JsonObject rarePet: rarePets) { - String petName = capitalize(rarePet.get("type").getAsString()); + String petName = Utils.capitalizeString(rarePet.get("type").getAsString()); int level = petXpToLevel(rarePet.get("exp").getAsDouble(), "RARE"); String messageToAdd = ""; @@ -211,7 +206,7 @@ public class PetsCommand extends CommandBase { } for (JsonObject uncommonPet: uncommonPets) { - String petName = capitalize(uncommonPet.get("type").getAsString()); + String petName = Utils.capitalizeString(uncommonPet.get("type").getAsString()); int level = petXpToLevel(uncommonPet.get("exp").getAsDouble(), "UNCOMMON"); String messageToAdd = ""; @@ -225,7 +220,7 @@ public class PetsCommand extends CommandBase { } for (JsonObject commonPet: commonPets) { - String petName = capitalize(commonPet.get("type").getAsString()); + String petName = Utils.capitalizeString(commonPet.get("type").getAsString()); int level = petXpToLevel(commonPet.get("exp").getAsDouble(), "COMMON"); String messageToAdd = ""; diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java index 5dc30c6..835e613 100644 --- a/src/main/java/me/Danker/utils/Utils.java +++ b/src/main/java/me/Danker/utils/Utils.java @@ -103,4 +103,14 @@ public class Utils { inSkyblock = false; } + public static String capitalizeString(String string) { + String[] words = string.split("_"); + + for (int i = 0; i < words.length; i++) { + words[i] = words[i].substring(0, 1).toUpperCase() + words[i].substring(1).toLowerCase(); + } + + return String.join(" ", words); + } + } |