diff --git a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java index 9962119fa..48932c5b4 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java @@ -46,7 +46,7 @@ import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.skills.woodcutting.WoodcuttingCommand; import com.gmail.nossr50.spout.commands.MchudCommand; import com.gmail.nossr50.spout.commands.XplockCommand; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; public final class CommandRegistrationHelper { private CommandRegistrationHelper() {}; @@ -55,12 +55,12 @@ public final class CommandRegistrationHelper { public static void registerSkillCommands() { for (SkillType skill : SkillType.values()) { String commandName = skill.toString().toLowerCase(); - String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase(); + String localizedName = LocaleLoader.getString(StringUtils.getCapitalized(commandName) + ".SkillName").toLowerCase(); PluginCommand command; command = mcMMO.p.getCommand(commandName); - command.setDescription(LocaleLoader.getString("Commands.Description.Skill", Misc.getCapitalized(localizedName))); + command.setDescription(LocaleLoader.getString("Commands.Description.Skill", StringUtils.getCapitalized(localizedName))); command.setPermission("mcmmo.commands." + commandName); command.setPermissionMessage(permissionsMessage); command.setUsage(LocaleLoader.getString("Commands.Usage.0", localizedName)); diff --git a/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java index 285cf3288..38ad435fa 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java @@ -10,7 +10,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public class AddlevelsCommand implements CommandExecutor{ @@ -39,11 +39,11 @@ public class AddlevelsCommand implements CommandExecutor{ return true; } - if (!Misc.isInt(args[1])) { + if (!StringUtils.isInt(args[1])) { return false; } - levels = Integer.valueOf(args[1]); + levels = Integer.parseInt(args[1]); profile = Users.getPlayer((Player) sender).getProfile(); if (allSkills) { @@ -63,7 +63,7 @@ public class AddlevelsCommand implements CommandExecutor{ sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels)); } else { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(args[0]))); + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, StringUtils.getCapitalized(args[0]))); } return true; @@ -82,12 +82,12 @@ public class AddlevelsCommand implements CommandExecutor{ return true; } - if (!Misc.isInt(args[2])) { + if (!StringUtils.isInt(args[2])) { return false; } McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]); - levels = Integer.valueOf(args[2]); + levels = Integer.parseInt(args[2]); // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. if (mcMMOPlayer == null) { @@ -129,7 +129,7 @@ public class AddlevelsCommand implements CommandExecutor{ } else { profile.addLevels(SkillType.getSkill(args[1]), levels); - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(args[1]))); + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, StringUtils.getCapitalized(args[1]))); } } @@ -137,7 +137,7 @@ public class AddlevelsCommand implements CommandExecutor{ sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0])); } else { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(args[1]), args[0])); + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", StringUtils.getCapitalized(args[1]), args[0])); } return true; diff --git a/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java index 8ca8621ff..997110f31 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java @@ -9,7 +9,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public class AddxpCommand implements CommandExecutor { @@ -39,11 +39,11 @@ public class AddxpCommand implements CommandExecutor { return true; } - if (!Misc.isInt(args[1])) { + if (!StringUtils.isInt(args[1])) { return false; } - xp = Integer.valueOf(args[1]); + xp = Integer.parseInt(args[1]); mcMMOPlayer = Users.getPlayer((Player) sender); profile = mcMMOPlayer.getProfile(); @@ -60,7 +60,7 @@ public class AddxpCommand implements CommandExecutor { } else { mcMMOPlayer.applyXpGain(SkillType.getSkill(args[0]), xp); - sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(args[0]))); + sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, StringUtils.getCapitalized(args[0]))); } return true; @@ -79,12 +79,12 @@ public class AddxpCommand implements CommandExecutor { return true; } - if (!Misc.isInt(args[2])) { + if (!StringUtils.isInt(args[2])) { return false; } mcMMOPlayer = Users.getPlayer(args[0]); - xp = Integer.valueOf(args[2]); + xp = Integer.parseInt(args[2]); // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. if (mcMMOPlayer == null) { @@ -125,7 +125,7 @@ public class AddxpCommand implements CommandExecutor { } else { mcMMOPlayer.applyXpGain(SkillType.getSkill(args[1]), xp); - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(args[1]))); + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, StringUtils.getCapitalized(args[1]))); } } @@ -133,7 +133,7 @@ public class AddxpCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0])); } else { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(args[1]), args[0])); + sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", StringUtils.getCapitalized(args[1]), args[0])); } return true; diff --git a/src/main/java/com/gmail/nossr50/commands/admin/HardcoreCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/HardcoreCommand.java index b0bf42b1f..6da6889fa 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/HardcoreCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/HardcoreCommand.java @@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; public class HardcoreCommand implements CommandExecutor{ @@ -52,7 +52,7 @@ public class HardcoreCommand implements CommandExecutor{ return true; } - if (!Misc.isDouble(args[0])) { + if (!StringUtils.isDouble(args[0])) { return false; } @@ -62,7 +62,7 @@ public class HardcoreCommand implements CommandExecutor{ } DecimalFormat percent = new DecimalFormat("##0.00%"); - double newPercent = Misc.getDouble(args[0]); + double newPercent = Double.parseDouble(args[0]); Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent); sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D))); diff --git a/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java index 2f33a0d69..49fbae4d1 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java @@ -10,7 +10,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public class MmoeditCommand implements CommandExecutor { @@ -39,11 +39,11 @@ public class MmoeditCommand implements CommandExecutor { return true; } - if (!Misc.isInt(args[1])) { + if (!StringUtils.isInt(args[1])) { return false; } - newValue = Integer.valueOf(args[1]); + newValue = Integer.parseInt(args[1]); profile = Users.getPlayer((Player) sender).getProfile(); if (allSkills) { @@ -59,7 +59,7 @@ public class MmoeditCommand implements CommandExecutor { } else { profile.modifySkill(SkillType.getSkill(args[0]), newValue); - sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(args[0]), newValue)); + sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", StringUtils.getCapitalized(args[0]), newValue)); } return true; @@ -78,11 +78,11 @@ public class MmoeditCommand implements CommandExecutor { return true; } - if (!Misc.isInt(args[2])) { + if (!StringUtils.isInt(args[2])) { return false; } - newValue = Integer.valueOf(args[2]); + newValue = Integer.parseInt(args[2]); McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]); // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. @@ -125,7 +125,7 @@ public class MmoeditCommand implements CommandExecutor { } else { profile.modifySkill(SkillType.getSkill(args[1]), newValue); - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(args[1]), newValue)); + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", StringUtils.getCapitalized(args[1]), newValue)); } } @@ -133,7 +133,7 @@ public class MmoeditCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0])); } else { - sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(args[1]), args[0])); + sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", StringUtils.getCapitalized(args[1]), args[0])); } return true; diff --git a/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java index a925b8b3e..4c543c75a 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java @@ -10,7 +10,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public class SkillresetCommand implements CommandExecutor { @@ -72,7 +72,7 @@ public class SkillresetCommand implements CommandExecutor { } else { profile.modifySkill(SkillType.getSkill(args[0]), 0); - sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(args[0]))); + sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", StringUtils.getCapitalized(args[0]))); } return true; @@ -152,7 +152,7 @@ public class SkillresetCommand implements CommandExecutor { } else { profile.modifySkill(SkillType.getSkill(args[1]), 0); - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(args[1]))); + mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", StringUtils.getCapitalized(args[1]))); } } @@ -160,7 +160,7 @@ public class SkillresetCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0])); } else { - sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(args[1]), args[0])); + sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", StringUtils.getCapitalized(args[1]), args[0])); } return true; diff --git a/src/main/java/com/gmail/nossr50/commands/admin/VampirismCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/VampirismCommand.java index 5bc965c29..ee1b42921 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/VampirismCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/VampirismCommand.java @@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; public class VampirismCommand implements CommandExecutor { @@ -57,7 +57,7 @@ public class VampirismCommand implements CommandExecutor { return true; } - if (!Misc.isDouble(args[0])) { + if (!StringUtils.isDouble(args[0])) { return false; } @@ -67,7 +67,7 @@ public class VampirismCommand implements CommandExecutor { } DecimalFormat percent = new DecimalFormat("##0.00%"); - double newPercent = Misc.getDouble(args[0]); + double newPercent = Double.parseDouble(args[0]); Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent); sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D))); diff --git a/src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java index 1d12472ab..ec40ffbb8 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/XprateCommand.java @@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; public class XprateCommand implements CommandExecutor { private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier(); @@ -34,7 +34,7 @@ public class XprateCommand implements CommandExecutor { return true; case 2: - if (!Misc.isInt(args[0])) { + if (!StringUtils.isInt(args[0])) { return false; } @@ -48,7 +48,7 @@ public class XprateCommand implements CommandExecutor { } mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1])); - int newXpRate = Misc.getInt(args[0]); + int newXpRate = Integer.parseInt(args[0]); Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate); if (mcMMO.p.isXPEventEnabled()) { diff --git a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java index bec85692d..19a5d6f22 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -13,7 +13,7 @@ import com.gmail.nossr50.database.Database; import com.gmail.nossr50.database.Leaderboard; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.SkillTools; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; public class MctopCommand implements CommandExecutor { @Override @@ -26,8 +26,8 @@ public class MctopCommand implements CommandExecutor { return true; case 1: - if (Misc.isInt(args[0])) { - display(Integer.valueOf(args[0]), "ALL", sender, useMySQL, command); + if (StringUtils.isInt(args[0])) { + display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command); } else if (SkillTools.isSkill(args[0])) { display(1, args[0], sender, useMySQL, command); @@ -42,15 +42,15 @@ public class MctopCommand implements CommandExecutor { return true; case 2: - if (!Misc.isInt(args[1])) { + if (!StringUtils.isInt(args[1])) { return false; } if (SkillTools.isSkill(args[0])) { - display(Integer.valueOf(args[1]), args[0], sender, useMySQL, command); + display(Integer.parseInt(args[1]), args[0], sender, useMySQL, command); } else if (SkillTools.isLocalizedSkill(args[0])) { - display(Integer.valueOf(args[1]), SkillTools.translateLocalizedSkill(args[0]), sender, useMySQL, command); + display(Integer.parseInt(args[1]), SkillTools.translateLocalizedSkill(args[0]), sender, useMySQL, command); } else { sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); @@ -91,7 +91,7 @@ public class MctopCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); } else { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", Misc.getCapitalized(skill))); + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill))); } int n = (page * 10) - 9; // Position @@ -128,7 +128,7 @@ public class MctopCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); } else { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", Misc.getCapitalized(query))); + sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query))); } int place = (page * 10) - 9; diff --git a/src/main/java/com/gmail/nossr50/database/Leaderboard.java b/src/main/java/com/gmail/nossr50/database/Leaderboard.java index 8dbd9684e..2719da269 100644 --- a/src/main/java/com/gmail/nossr50/database/Leaderboard.java +++ b/src/main/java/com/gmail/nossr50/database/Leaderboard.java @@ -15,7 +15,7 @@ import org.bukkit.Bukkit; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; public final class Leaderboard { private static HashMap> playerStatHash = new HashMap>(); @@ -71,64 +71,64 @@ public final class Leaderboard { players.add(p); - if (character.length > 1 && Misc.isInt(character[1])) { - mining.add(new PlayerStat(p, Integer.valueOf(character[1]))); - powerLevel += Integer.valueOf(character[1]); + if (character.length > 1 && StringUtils.isInt(character[1])) { + mining.add(new PlayerStat(p, Integer.parseInt(character[1]))); + powerLevel += Integer.parseInt(character[1]); } - if (character.length > 5 && Misc.isInt(character[5])) { - woodcutting.add(new PlayerStat(p, Integer.valueOf(character[5]))); - powerLevel += Integer.valueOf(character[5]); + if (character.length > 5 && StringUtils.isInt(character[5])) { + woodcutting.add(new PlayerStat(p, Integer.parseInt(character[5]))); + powerLevel += Integer.parseInt(character[5]); } - if (character.length > 7 && Misc.isInt(character[7])) { - repair.add(new PlayerStat(p, Integer.valueOf(character[7]))); - powerLevel += Integer.valueOf(character[7]); + if (character.length > 7 && StringUtils.isInt(character[7])) { + repair.add(new PlayerStat(p, Integer.parseInt(character[7]))); + powerLevel += Integer.parseInt(character[7]); } - if (character.length > 8 && Misc.isInt(character[8])) { - unarmed.add(new PlayerStat(p, Integer.valueOf(character[8]))); - powerLevel += Integer.valueOf(character[8]); + if (character.length > 8 && StringUtils.isInt(character[8])) { + unarmed.add(new PlayerStat(p, Integer.parseInt(character[8]))); + powerLevel += Integer.parseInt(character[8]); } - if (character.length > 9 && Misc.isInt(character[9])) { - herbalism.add(new PlayerStat(p, Integer.valueOf(character[9]))); - powerLevel += Integer.valueOf(character[9]); + if (character.length > 9 && StringUtils.isInt(character[9])) { + herbalism.add(new PlayerStat(p, Integer.parseInt(character[9]))); + powerLevel += Integer.parseInt(character[9]); } - if (character.length > 10 && Misc.isInt(character[10])) { - excavation.add(new PlayerStat(p, Integer.valueOf(character[10]))); - powerLevel += Integer.valueOf(character[10]); + if (character.length > 10 && StringUtils.isInt(character[10])) { + excavation.add(new PlayerStat(p, Integer.parseInt(character[10]))); + powerLevel += Integer.parseInt(character[10]); } - if (character.length > 11 && Misc.isInt(character[11])) { - archery.add(new PlayerStat(p, Integer.valueOf(character[11]))); - powerLevel += Integer.valueOf(character[11]); + if (character.length > 11 && StringUtils.isInt(character[11])) { + archery.add(new PlayerStat(p, Integer.parseInt(character[11]))); + powerLevel += Integer.parseInt(character[11]); } - if (character.length > 12 && Misc.isInt(character[12])) { - swords.add(new PlayerStat(p, Integer.valueOf(character[12]))); - powerLevel += Integer.valueOf(character[12]); + if (character.length > 12 && StringUtils.isInt(character[12])) { + swords.add(new PlayerStat(p, Integer.parseInt(character[12]))); + powerLevel += Integer.parseInt(character[12]); } - if (character.length > 13 && Misc.isInt(character[13])) { - axes.add(new PlayerStat(p, Integer.valueOf(character[13]))); - powerLevel += Integer.valueOf(character[13]); + if (character.length > 13 && StringUtils.isInt(character[13])) { + axes.add(new PlayerStat(p, Integer.parseInt(character[13]))); + powerLevel += Integer.parseInt(character[13]); } - if (character.length > 14 && Misc.isInt(character[14])) { - acrobatics.add(new PlayerStat(p, Integer.valueOf(character[14]))); - powerLevel += Integer.valueOf(character[14]); + if (character.length > 14 && StringUtils.isInt(character[14])) { + acrobatics.add(new PlayerStat(p, Integer.parseInt(character[14]))); + powerLevel += Integer.parseInt(character[14]); } - if (character.length > 24 && Misc.isInt(character[24])) { - taming.add(new PlayerStat(p, Integer.valueOf(character[24]))); - powerLevel += Integer.valueOf(character[24]); + if (character.length > 24 && StringUtils.isInt(character[24])) { + taming.add(new PlayerStat(p, Integer.parseInt(character[24]))); + powerLevel += Integer.parseInt(character[24]); } - if (character.length > 34 && Misc.isInt(character[34])) { - fishing.add(new PlayerStat(p, Integer.valueOf(character[34]))); - powerLevel += Integer.valueOf(character[34]); + if (character.length > 34 && StringUtils.isInt(character[34])) { + fishing.add(new PlayerStat(p, Integer.parseInt(character[34]))); + powerLevel += Integer.parseInt(character[34]); } powerLevels.add(new PlayerStat(p, powerLevel)); @@ -355,7 +355,7 @@ public final class Leaderboard { String[] splitLine = line.split(":"); if (splitLine.length > 37) { - if (currentTime - (Misc.getLong(line.split(":")[37]) * 1000) <= purgeTime) { + if (currentTime - (StringUtils.getLong(line.split(":")[37]) * 1000) <= purgeTime) { writer.append(line).append("\r\n"); } else { diff --git a/src/main/java/com/gmail/nossr50/database/runnables/SQLConversionTask.java b/src/main/java/com/gmail/nossr50/database/runnables/SQLConversionTask.java index 30eb83ea4..624d06df0 100644 --- a/src/main/java/com/gmail/nossr50/database/runnables/SQLConversionTask.java +++ b/src/main/java/com/gmail/nossr50/database/runnables/SQLConversionTask.java @@ -7,6 +7,7 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.database.Database; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; public class SQLConversionTask implements Runnable { private String tablePrefix = Config.getInstance().getMySQLTablePrefix(); @@ -175,34 +176,34 @@ public class SQLConversionTask implements Runnable { Database.write("UPDATE " + tablePrefix + "skills SET " - + " taming = taming+" + Misc.getInt(taming) - + ", mining = mining+" + Misc.getInt(mining) - + ", repair = repair+" + Misc.getInt(repair) - + ", woodcutting = woodcutting+" + Misc.getInt(woodcutting) - + ", unarmed = unarmed+" + Misc.getInt(unarmed) - + ", herbalism = herbalism+" + Misc.getInt(herbalism) - + ", excavation = excavation+" + Misc.getInt(excavation) - + ", archery = archery+" + Misc.getInt(archery) - + ", swords = swords+" + Misc.getInt(swords) - + ", axes = axes+" + Misc.getInt(axes) - + ", acrobatics = acrobatics+" + Misc.getInt(acrobatics) - + ", fishing = fishing+" + Misc.getInt(fishing) + + " taming = taming+" + StringUtils.getInt(taming) + + ", mining = mining+" + StringUtils.getInt(mining) + + ", repair = repair+" + StringUtils.getInt(repair) + + ", woodcutting = woodcutting+" + StringUtils.getInt(woodcutting) + + ", unarmed = unarmed+" + StringUtils.getInt(unarmed) + + ", herbalism = herbalism+" + StringUtils.getInt(herbalism) + + ", excavation = excavation+" + StringUtils.getInt(excavation) + + ", archery = archery+" + StringUtils.getInt(archery) + + ", swords = swords+" + StringUtils.getInt(swords) + + ", axes = axes+" + StringUtils.getInt(axes) + + ", acrobatics = acrobatics+" + StringUtils.getInt(acrobatics) + + ", fishing = fishing+" + StringUtils.getInt(fishing) + " WHERE user_id = " + id); Database.write("UPDATE " + tablePrefix + "experience SET " - + " taming = " + Misc.getInt(tamingXP) - + ", mining = " + Misc.getInt(miningXP) - + ", repair = " + Misc.getInt(repairXP) - + ", woodcutting = " + Misc.getInt(woodCuttingXP) - + ", unarmed = " + Misc.getInt(unarmedXP) - + ", herbalism = " + Misc.getInt(herbalismXP) - + ", excavation = " + Misc.getInt(excavationXP) - + ", archery = " + Misc.getInt(archeryXP) - + ", swords = " + Misc.getInt(swordsXP) - + ", axes = " + Misc.getInt(axesXP) - + ", acrobatics = " + Misc.getInt(acrobaticsXP) - + ", fishing = " + Misc.getInt(fishingXP) + + " taming = " + StringUtils.getInt(tamingXP) + + ", mining = " + StringUtils.getInt(miningXP) + + ", repair = " + StringUtils.getInt(repairXP) + + ", woodcutting = " + StringUtils.getInt(woodCuttingXP) + + ", unarmed = " + StringUtils.getInt(unarmedXP) + + ", herbalism = " + StringUtils.getInt(herbalismXP) + + ", excavation = " + StringUtils.getInt(excavationXP) + + ", archery = " + StringUtils.getInt(archeryXP) + + ", swords = " + StringUtils.getInt(swordsXP) + + ", axes = " + StringUtils.getInt(axesXP) + + ", acrobatics = " + StringUtils.getInt(acrobaticsXP) + + ", fishing = " + StringUtils.getInt(fishingXP) + " WHERE user_id = " + id); } else { @@ -237,34 +238,34 @@ public class SQLConversionTask implements Runnable { Database.write("UPDATE " + tablePrefix + "skills SET " - + " taming = taming+" + Misc.getInt(taming) - + ", mining = mining+" + Misc.getInt(mining) - + ", repair = repair+" + Misc.getInt(repair) - + ", woodcutting = woodcutting+" + Misc.getInt(woodcutting) - + ", unarmed = unarmed+" + Misc.getInt(unarmed) - + ", herbalism = herbalism+" + Misc.getInt(herbalism) - + ", excavation = excavation+" + Misc.getInt(excavation) - + ", archery = archery+" + Misc.getInt(archery) - + ", swords = swords+" + Misc.getInt(swords) - + ", axes = axes+" + Misc.getInt(axes) - + ", acrobatics = acrobatics+" + Misc.getInt(acrobatics) - + ", fishing = fishing+" + Misc.getInt(fishing) + + " taming = taming+" + StringUtils.getInt(taming) + + ", mining = mining+" + StringUtils.getInt(mining) + + ", repair = repair+" + StringUtils.getInt(repair) + + ", woodcutting = woodcutting+" + StringUtils.getInt(woodcutting) + + ", unarmed = unarmed+" + StringUtils.getInt(unarmed) + + ", herbalism = herbalism+" + StringUtils.getInt(herbalism) + + ", excavation = excavation+" + StringUtils.getInt(excavation) + + ", archery = archery+" + StringUtils.getInt(archery) + + ", swords = swords+" + StringUtils.getInt(swords) + + ", axes = axes+" + StringUtils.getInt(axes) + + ", acrobatics = acrobatics+" + StringUtils.getInt(acrobatics) + + ", fishing = fishing+" + StringUtils.getInt(fishing) + " WHERE user_id = " + id); Database.write("UPDATE " + tablePrefix + "experience SET " - + " taming = " + Misc.getInt(tamingXP) - + ", mining = " + Misc.getInt(miningXP) - + ", repair = " + Misc.getInt(repairXP) - + ", woodcutting = " + Misc.getInt(woodCuttingXP) - + ", unarmed = " + Misc.getInt(unarmedXP) - + ", herbalism = " + Misc.getInt(herbalismXP) - + ", excavation = " + Misc.getInt(excavationXP) - + ", archery = " + Misc.getInt(archeryXP) - + ", swords = " + Misc.getInt(swordsXP) - + ", axes = " + Misc.getInt(axesXP) - + ", acrobatics = " + Misc.getInt(acrobaticsXP) - + ", fishing = " + Misc.getInt(fishingXP) + + " taming = " + StringUtils.getInt(tamingXP) + + ", mining = " + StringUtils.getInt(miningXP) + + ", repair = " + StringUtils.getInt(repairXP) + + ", woodcutting = " + StringUtils.getInt(woodCuttingXP) + + ", unarmed = " + StringUtils.getInt(unarmedXP) + + ", herbalism = " + StringUtils.getInt(herbalismXP) + + ", excavation = " + StringUtils.getInt(excavationXP) + + ", archery = " + StringUtils.getInt(archeryXP) + + ", swords = " + StringUtils.getInt(swordsXP) + + ", axes = " + StringUtils.getInt(axesXP) + + ", acrobatics = " + StringUtils.getInt(acrobaticsXP) + + ", fishing = " + StringUtils.getInt(fishingXP) + " WHERE user_id = " + id); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index b385a1fc7..13d187dd2 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -17,6 +17,7 @@ import com.gmail.nossr50.spout.SpoutConfig; import com.gmail.nossr50.spout.huds.HudType; import com.gmail.nossr50.spout.huds.SpoutHud; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; public class PlayerProfile { private String playerName; @@ -205,49 +206,49 @@ public class PlayerProfile { continue; } - if (character.length > 1 && Misc.isInt(character[1])) + if (character.length > 1 && StringUtils.isInt(character[1])) skills.put(SkillType.MINING, Integer.valueOf(character[1])); - if (character.length > 4 && Misc.isInt(character[4])) + if (character.length > 4 && StringUtils.isInt(character[4])) skillsXp.put(SkillType.MINING, Integer.valueOf(character[4])); - if (character.length > 5 && Misc.isInt(character[5])) + if (character.length > 5 && StringUtils.isInt(character[5])) skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5])); - if (character.length > 6 && Misc.isInt(character[6])) + if (character.length > 6 && StringUtils.isInt(character[6])) skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6])); - if (character.length > 7 && Misc.isInt(character[7])) + if (character.length > 7 && StringUtils.isInt(character[7])) skills.put(SkillType.REPAIR, Integer.valueOf(character[7])); - if (character.length > 8 && Misc.isInt(character[8])) + if (character.length > 8 && StringUtils.isInt(character[8])) skills.put(SkillType.UNARMED, Integer.valueOf(character[8])); - if (character.length > 9 && Misc.isInt(character[9])) + if (character.length > 9 && StringUtils.isInt(character[9])) skills.put(SkillType.HERBALISM, Integer.valueOf(character[9])); - if (character.length > 10 && Misc.isInt(character[10])) + if (character.length > 10 && StringUtils.isInt(character[10])) skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10])); - if (character.length > 11 && Misc.isInt(character[11])) + if (character.length > 11 && StringUtils.isInt(character[11])) skills.put(SkillType.ARCHERY, Integer.valueOf(character[11])); - if (character.length > 12 && Misc.isInt(character[12])) + if (character.length > 12 && StringUtils.isInt(character[12])) skills.put(SkillType.SWORDS, Integer.valueOf(character[12])); - if (character.length > 13 && Misc.isInt(character[13])) + if (character.length > 13 && StringUtils.isInt(character[13])) skills.put(SkillType.AXES, Integer.valueOf(character[13])); - if (character.length > 14 && Misc.isInt(character[14])) + if (character.length > 14 && StringUtils.isInt(character[14])) skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14])); - if (character.length > 15 && Misc.isInt(character[15])) + if (character.length > 15 && StringUtils.isInt(character[15])) skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15])); - if (character.length > 16 && Misc.isInt(character[16])) + if (character.length > 16 && StringUtils.isInt(character[16])) skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16])); - if (character.length > 17 && Misc.isInt(character[17])) + if (character.length > 17 && StringUtils.isInt(character[17])) skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17])); - if (character.length > 18 && Misc.isInt(character[18])) + if (character.length > 18 && StringUtils.isInt(character[18])) skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18])); - if (character.length > 19 && Misc.isInt(character[19])) + if (character.length > 19 && StringUtils.isInt(character[19])) skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19])); - if (character.length > 20 && Misc.isInt(character[20])) + if (character.length > 20 && StringUtils.isInt(character[20])) skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20])); - if (character.length > 21 && Misc.isInt(character[21])) + if (character.length > 21 && StringUtils.isInt(character[21])) skillsXp.put(SkillType.AXES, Integer.valueOf(character[21])); - if (character.length > 22 && Misc.isInt(character[22])) + if (character.length > 22 && StringUtils.isInt(character[22])) skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22])); - if (character.length > 24 && Misc.isInt(character[24])) + if (character.length > 24 && StringUtils.isInt(character[24])) skills.put(SkillType.TAMING, Integer.valueOf(character[24])); - if (character.length > 25 && Misc.isInt(character[25])) + if (character.length > 25 && StringUtils.isInt(character[25])) skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25])); if (character.length > 26) skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26])); @@ -384,18 +385,18 @@ public class PlayerProfile { writer.append(skillsXp.get(SkillType.TAMING)).append(":"); // Need to store the DATS of abilities nao // Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker - writer.append(String.valueOf(skillsDATS.get(AbilityType.BERSERK))).append(":"); - writer.append(String.valueOf(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER))).append(":"); - writer.append(String.valueOf(skillsDATS.get(AbilityType.TREE_FELLER))).append(":"); - writer.append(String.valueOf(skillsDATS.get(AbilityType.GREEN_TERRA))).append(":"); - writer.append(String.valueOf(skillsDATS.get(AbilityType.SERRATED_STRIKES))).append(":"); - writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER))).append(":"); - writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER))).append(":"); + writer.append(skillsDATS.get(AbilityType.BERSERK)).append(":"); + writer.append(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)).append(":"); + writer.append(skillsDATS.get(AbilityType.TREE_FELLER)).append(":"); + writer.append(skillsDATS.get(AbilityType.GREEN_TERRA)).append(":"); + writer.append(skillsDATS.get(AbilityType.SERRATED_STRIKES)).append(":"); + writer.append(skillsDATS.get(AbilityType.SKULL_SPLIITER)).append(":"); + writer.append(skillsDATS.get(AbilityType.SUPER_BREAKER)).append(":"); writer.append(hudType.toString()).append(":"); writer.append(skills.get(SkillType.FISHING)).append(":"); writer.append(skillsXp.get(SkillType.FISHING)).append(":"); - writer.append(String.valueOf(skillsDATS.get(AbilityType.BLAST_MINING))).append(":"); - writer.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":"); + writer.append(skillsDATS.get(AbilityType.BLAST_MINING)).append(":"); + writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":"); writer.append("\r\n"); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 942c5ded3..70c7b896c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -44,6 +44,7 @@ import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Motd; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public class PlayerListener implements Listener { @@ -373,7 +374,7 @@ public class PlayerListener implements Listener { for (SkillType skill : SkillType.values()) { String skillName = skill.toString().toLowerCase(); - String localizedName = LocaleLoader.getString(Misc.getCapitalized(skillName) + ".SkillName").toLowerCase(); + String localizedName = LocaleLoader.getString(StringUtils.getCapitalized(skillName) + ".SkillName").toLowerCase(); if (lowerCaseCommand.equals(localizedName)) { event.setMessage(message.replace(command, skillName)); diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java index 668040483..94fa4a1c6 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java @@ -10,8 +10,8 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.party.ShareHandler.ShareMode; -import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public class PartyExpShareCommand implements CommandExecutor { @@ -55,7 +55,7 @@ public class PartyExpShareCommand implements CommandExecutor { playerParty.setXpShareMode(mode); for (Player member : playerParty.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + Misc.getCapitalized(mode.toString())))); + member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())))); } } } diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java index 310b2d60f..6ea13d301 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java @@ -10,8 +10,8 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.party.ShareHandler.ShareMode; -import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public class PartyItemShareCommand implements CommandExecutor { @@ -60,7 +60,7 @@ public class PartyItemShareCommand implements CommandExecutor { playerParty.setItemShareMode(mode); for (Player member : playerParty.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + Misc.getCapitalized(mode.toString())))); + member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())))); } } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/skills/SkillCommand.java index 88602ba2d..d362e8630 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillCommand.java @@ -14,6 +14,7 @@ import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public abstract class SkillCommand implements CommandExecutor { @@ -31,7 +32,7 @@ public abstract class SkillCommand implements CommandExecutor { public SkillCommand(SkillType skill) { this.skill = skill; - this.skillString = Misc.getCapitalized(skill.toString()); + this.skillString = StringUtils.getCapitalized(skill.toString()); } @Override diff --git a/src/main/java/com/gmail/nossr50/skills/SkillGuide.java b/src/main/java/com/gmail/nossr50/skills/SkillGuide.java index 7c1f9fe8d..e7ead566f 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillGuide.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillGuide.java @@ -7,7 +7,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; public final class SkillGuide { private SkillGuide() {} @@ -55,7 +55,7 @@ public final class SkillGuide { public static boolean grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) { String skillName = skilltype.toString(); - String capitalized = Misc.getCapitalized(skillName); + String capitalized = StringUtils.getCapitalized(skillName); String localized = SkillTools.localizeSkillName(skilltype); player.sendMessage(LocaleLoader.getString("Guides.Available", localized, localized.toLowerCase())); @@ -82,19 +82,19 @@ public final class SkillGuide { case 2: int totalPages = SkillGuide.getTotalPageNumber(address); - if (!Misc.isInt(args[1])) { + if (!StringUtils.isInt(args[1])) { player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid")); return true; } - if (Misc.getInt(args[1]) > totalPages) { + if (Integer.parseInt(args[1]) > totalPages) { player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages)); return true; } SkillGuide.clearChat(player); - for (String target : SkillGuide.grabPageContents(localized, address, Misc.getInt(args[1]))) { + for (String target : SkillGuide.grabPageContents(localized, address, Integer.parseInt(args[1]))) { player.sendMessage(target); } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningCommand.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningCommand.java index 128732fa5..df88180e1 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningCommand.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningCommand.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.mining; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillCommand; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; public class MiningCommand extends SkillCommand { @@ -156,7 +155,7 @@ public class MiningCommand extends SkillCommand { player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", BlastMining.rank1))); } else { - player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (Misc.getInt(blastMiningRank) - 1)))); + player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (Integer.parseInt(blastMiningRank) - 1)))); } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java index cb18186bf..6dd292092 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/SimpleRepairManager.java @@ -14,8 +14,8 @@ import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; public class SimpleRepairManager implements RepairManager { private HashMap repairables; @@ -76,7 +76,7 @@ public class SimpleRepairManager implements RepairManager { // Level check if (skillLevel < repairable.getMinimumLevel()) { - player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", String.valueOf(repairable.getMinimumLevel()), Misc.prettyItemString(item.getTypeId()))); + player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", String.valueOf(repairable.getMinimumLevel()), StringUtils.getPrettyItemString(item.getTypeId()))); return; } @@ -84,7 +84,7 @@ public class SimpleRepairManager implements RepairManager { // Check if they have the proper material to repair with if (!inventory.contains(repairable.getRepairMaterialId())) { - String message = LocaleLoader.getString("Skills.NeedMore", Misc.prettyItemString(repairable.getRepairMaterialId())); + String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairable.getRepairMaterialId())); if (repairable.getRepairMaterialMetadata() != (byte) -1) { // TODO: Do something nicer than append the metadata as a :# ? if (findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata()) == -1) { diff --git a/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java b/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java index 6fcc065f9..c6de8e203 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/CallOfTheWildEventHandler.java @@ -12,6 +12,7 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; public class CallOfTheWildEventHandler { protected Player player; @@ -30,7 +31,7 @@ public class CallOfTheWildEventHandler { if (player == null) return; - player.sendMessage(LocaleLoader.getString("Skills.NeedMore", Misc.prettyItemString(inHand.getTypeId()))); + player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(inHand.getTypeId()))); } protected boolean nearbyEntityExists() { diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java index d57b91eb4..f814387e4 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java @@ -19,6 +19,7 @@ import com.gmail.nossr50.spout.SpoutConfig; import com.gmail.nossr50.spout.SpoutTools; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public class SkillTools { @@ -235,7 +236,7 @@ public class SkillTools { } } - String capitalized = Misc.getCapitalized(skillType.toString()); + String capitalized = StringUtils.getCapitalized(skillType.toString()); /* Spout Stuff */ if (mcMMO.spoutEnabled) { @@ -285,7 +286,7 @@ public class SkillTools { public static boolean isLocalizedSkill(String skillName) { for (SkillType skill : SkillType.values()) { - if (skillName.equalsIgnoreCase(LocaleLoader.getString(Misc.getCapitalized(skill.toString() + ".SkillName")))) { + if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString() + ".SkillName")))) { return true; } } @@ -295,7 +296,7 @@ public class SkillTools { public static String translateLocalizedSkill(String skillName) { for (SkillType skill : SkillType.values()) { - if (skillName.equalsIgnoreCase(LocaleLoader.getString(Misc.getCapitalized(skill.toString() + ".SkillName")))) { + if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString() + ".SkillName")))) { return skill.toString(); } } @@ -304,7 +305,7 @@ public class SkillTools { } public static String localizeSkillName(SkillType skill) { - return Misc.getCapitalized(LocaleLoader.getString(Misc.getCapitalized(skill.toString()) + ".SkillName")); + return StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".SkillName")); } /** diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutTools.java b/src/main/java/com/gmail/nossr50/spout/SpoutTools.java index 3478de43d..3f4051495 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutTools.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutTools.java @@ -25,7 +25,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.Users; public class SpoutTools { @@ -147,8 +147,8 @@ public class SpoutTools { } String skillTypeString = skillType.toString(); - String standardFileName = Misc.getCapitalized(skillTypeString)+".png"; - String retroFileName = Misc.getCapitalized(skillTypeString)+"_r.png"; + String standardFileName = StringUtils.getCapitalized(skillTypeString)+".png"; + String retroFileName = StringUtils.getCapitalized(skillTypeString)+"_r.png"; writeFile(standardFileName, hudStandardDirectory); writeFile(retroFileName, hudRetroDirectory); @@ -210,8 +210,8 @@ public class SpoutTools { String skillTypeString = skillType.toString(); - files.add(new File(hudStandardDirectory + Misc.getCapitalized(skillTypeString) + ".png")); - files.add(new File(hudRetroDirectory + Misc.getCapitalized(skillTypeString) + "_r.png")); + files.add(new File(hudStandardDirectory + StringUtils.getCapitalized(skillTypeString) + ".png")); + files.add(new File(hudRetroDirectory + StringUtils.getCapitalized(skillTypeString) + "_r.png")); } // Blank icons diff --git a/src/main/java/com/gmail/nossr50/spout/commands/XplockCommand.java b/src/main/java/com/gmail/nossr50/spout/commands/XplockCommand.java index ff55af1a4..48afb045a 100644 --- a/src/main/java/com/gmail/nossr50/spout/commands/XplockCommand.java +++ b/src/main/java/com/gmail/nossr50/spout/commands/XplockCommand.java @@ -6,8 +6,8 @@ import org.bukkit.command.CommandSender; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.utilities.SkillTools; import com.gmail.nossr50.skills.utilities.SkillType; -import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.StringUtils; public class XplockCommand extends SpoutCommand { @Override @@ -52,7 +52,7 @@ public class XplockCommand extends SpoutCommand { spoutHud.setXpBarLocked(true); spoutHud.setSkillLock(skill); spoutHud.updateXpBar(); - sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", Misc.getCapitalized(skill.toString()))); + sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", StringUtils.getCapitalized(skill.toString()))); } } diff --git a/src/main/java/com/gmail/nossr50/spout/popups/XpBar.java b/src/main/java/com/gmail/nossr50/spout/popups/XpBar.java index 2d188f7d0..7a6ec9db3 100644 --- a/src/main/java/com/gmail/nossr50/spout/popups/XpBar.java +++ b/src/main/java/com/gmail/nossr50/spout/popups/XpBar.java @@ -13,7 +13,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.spout.SpoutConfig; import com.gmail.nossr50.spout.huds.HudType; -import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.StringUtils; public class XpBar { private SpoutPlayer spoutPlayer; @@ -204,7 +204,7 @@ public class XpBar { * @param playerProfile The profile of the player whose XP bar should be updated */ private void updateXpBarStandard(SkillType skillType, PlayerProfile playerProfile) { - xpIcon.setUrl(Misc.getCapitalized(skillType.toString()) + ".png"); + xpIcon.setUrl(StringUtils.getCapitalized(skillType.toString()) + ".png"); ((GenericTexture) xpBar).setUrl(getUrlBar(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.STANDARD))); @@ -220,7 +220,7 @@ public class XpBar { private void updateXpBarRetro(SkillType skillType, PlayerProfile playerProfile) { Color color = getRetroColor(skillType); - xpIcon.setUrl(Misc.getCapitalized(skillType.toString()) + "_r.png"); + xpIcon.setUrl(StringUtils.getCapitalized(skillType.toString()) + "_r.png"); xpFill.setBottomColor(color); xpFill.setTopColor(color); diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index 2144149fc..4d2e3ddcc 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -100,87 +100,6 @@ public final class Misc { } } - /** - * Gets a capitalized version of the target string. - * - * @param target String to capitalize - * @return the capitalized string - */ - public static String getCapitalized(String target) { - String firstLetter = target.substring(0,1); - String remainder = target.substring(1); - String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase(); - - return capitalized; - } - - /** - * Gets a nicely formatted string version of an item name from a given item ID. - * - * @param itemID The ID of the item to convert to string. - * @return the nicely formatting string - */ - public static String prettyItemString(int itemID) { - String baseString = Material.getMaterial(itemID).toString(); - String[] substrings = baseString.split("_"); - String prettyString = ""; - int size = 1; - - for (String s : substrings) { - prettyString = prettyString.concat(Misc.getCapitalized(s)); - - if (size < substrings.length) { - prettyString = prettyString.concat(" "); - } - - size++; - } - - return prettyString; - } - - /** - * Gets the int represented by this string. - * - * @param string The string to parse - * @return the int represented by this string - */ - public static int getInt(String string) { - if (isInt(string)) { - return Integer.parseInt(string); - } - - return 0; - } - - /** - * Gets the long represented by this string. - * - * @param string The string to parse - * @return the long represented by this string - */ - public static long getLong(String string) { - if (isLong(string)) { - return Long.parseLong(string); - } - - return 0; - } - - /** - * Gets the long represented by this string. - * - * @param string The string to parse - * @return the long represented by this string - */ - public static double getDouble(String string) { - if (isDouble(string)) { - return Double.parseDouble(string); - } - - return 0; - } - /** * Checks to see if an entity is currently invincible. * @@ -283,54 +202,6 @@ public final class Misc { return false; } - /** - * Determine if a string represents an Integer - * - * @param string String to check - * @return true if the string is an Integer, false otherwise - */ - public static boolean isInt(String string) { - try { - Integer.parseInt(string); - return true; - } - catch (NumberFormatException nFE) { - return false; - } - } - - /** - * Determine if a string represents a Long - * - * @param string String to check - * @return true if the string is a Long, false otherwise - */ - public static boolean isLong(String string) { - try { - Long.parseLong(string); - return true; - } - catch (NumberFormatException nFE) { - return false; - } - } - - /** - * Determine if a string represents a Double - * - * @param string String to check - * @return true if the string is a Double, false otherwise - */ - public static boolean isDouble(String string) { - try { - Double.parseDouble(string); - return true; - } - catch (NumberFormatException nFE) { - return false; - } - } - /** * Drop items at a given location. * diff --git a/src/main/java/com/gmail/nossr50/util/StringUtils.java b/src/main/java/com/gmail/nossr50/util/StringUtils.java new file mode 100644 index 000000000..b2b5944e9 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/StringUtils.java @@ -0,0 +1,124 @@ +package com.gmail.nossr50.util; + +import org.bukkit.Material; + +public class StringUtils { + + /** + * Gets a capitalized version of the target string. + * + * @param target String to capitalize + * @return the capitalized string + */ + public static String getCapitalized(String target) { + String firstLetter = target.substring(0,1); + String remainder = target.substring(1); + String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase(); + + return capitalized; + } + + /** + * Gets a nicely formatted string version of an item name from a given item ID. + * + * @param itemID The ID of the item to convert to string. + * @return the nicely formatting string + */ + public static String getPrettyItemString(int itemID) { + String baseString = Material.getMaterial(itemID).toString(); + String[] substrings = baseString.split("_"); + String prettyString = ""; + int size = 1; + + for (String s : substrings) { + prettyString = prettyString.concat(getCapitalized(s)); + + if (size < substrings.length) { + prettyString = prettyString.concat(" "); + } + + size++; + } + + return prettyString; + } + + /** + * Gets the int represented by this string. + * + * @param string The string to parse + * @return the int represented by this string + */ + public static int getInt(String string) { + try { + return Integer.parseInt(string); + } + catch (NumberFormatException nFE) { + return 0; + } + } + + /** + * Gets the long represented by this string. + * + * @param string The string to parse + * @return the long represented by this string + */ + public static long getLong(String string) { + try { + return Long.parseLong(string); + } + catch (NumberFormatException nFE) { + return 0; + } + } + + /** + * Determine if a string represents an Integer + * + * @param string String to check + * @return true if the string is an Integer, false otherwise + */ + public static boolean isInt(String string) { + try { + Integer.parseInt(string); + return true; + } + catch (NumberFormatException nFE) { + return false; + } + } + + /** + * Determine if a string represents a Long + * + * @param string String to check + * @return true if the string is a Long, false otherwise + */ + public static boolean isLong(String string) { + try { + Long.parseLong(string); + return true; + } + catch (NumberFormatException nFE) { + return false; + } + } + + /** + * Determine if a string represents a Double + * + * @param string String to check + * @return true if the string is a Double, false otherwise + */ + public static boolean isDouble(String string) { + try { + Double.parseDouble(string); + return true; + } + catch (NumberFormatException nFE) { + return false; + } + } + +}