aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/me/Danker/commands/PetsCommand.java15
-rw-r--r--src/main/java/me/Danker/utils/Utils.java10
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 5d38214..c697689 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);
+ }
+
}