From 6c266a8926073e3c0772f9d7b89fce9c62024bf1 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 7 Feb 2013 12:17:18 -0500 Subject: [PATCH] We don't need two functions that do the exact same thing. --- .../commands/admin/AddlevelsCommand.java | 6 +++--- .../nossr50/commands/admin/AddxpCommand.java | 6 +++--- .../nossr50/commands/admin/MmoeditCommand.java | 6 +++--- .../commands/admin/SkillresetCommand.java | 6 +++--- .../nossr50/skills/utilities/SkillTools.java | 18 +----------------- .../nossr50/skills/utilities/SkillType.java | 2 +- .../nossr50/spout/commands/XplockCommand.java | 2 +- 7 files changed, 15 insertions(+), 31 deletions(-) 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 5a989c156..48303ea78 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/AddlevelsCommand.java @@ -57,7 +57,7 @@ public class AddlevelsCommand implements CommandExecutor{ } } else { - profile.addLevels(SkillTools.getSkillType(args[0]), levels); + profile.addLevels(SkillType.getSkill(args[0]), levels); } if (allSkills) { @@ -109,7 +109,7 @@ public class AddlevelsCommand implements CommandExecutor{ } } else { - profile.addLevels(SkillTools.getSkillType(args[1]), levels); + profile.addLevels(SkillType.getSkill(args[1]), levels); } profile.save(); // Since this is a temporary profile, we save it here. @@ -129,7 +129,7 @@ public class AddlevelsCommand implements CommandExecutor{ mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels)); } else { - profile.addLevels(SkillTools.getSkillType(args[1]), levels); + profile.addLevels(SkillType.getSkill(args[1]), levels); mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(args[1]))); } } 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 4f816a4f7..4afd3be14 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/AddxpCommand.java @@ -61,7 +61,7 @@ public class AddxpCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp)); } else { - mcMMOPlayer.applyXpGain(SkillTools.getSkillType(args[0]), xp); + mcMMOPlayer.applyXpGain(SkillType.getSkill(args[0]), xp); sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(args[0]))); } @@ -108,7 +108,7 @@ public class AddxpCommand implements CommandExecutor { } } else { - profile.setSkillXpLevel(SkillTools.getSkillType(args[1]), xp); + profile.setSkillXpLevel(SkillType.getSkill(args[1]), xp); } profile.save(); // Since this is a temporary profile, we save it here. @@ -126,7 +126,7 @@ public class AddxpCommand implements CommandExecutor { mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp)); } else { - mcMMOPlayer.applyXpGain(SkillTools.getSkillType(args[1]), xp); + mcMMOPlayer.applyXpGain(SkillType.getSkill(args[1]), xp); mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(args[1]))); } } 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 d881aefa7..58ec2f815 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/MmoeditCommand.java @@ -59,7 +59,7 @@ public class MmoeditCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue)); } else { - profile.modifySkill(SkillTools.getSkillType(args[0]), newValue); + profile.modifySkill(SkillType.getSkill(args[0]), newValue); sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(args[0]), newValue)); } @@ -105,7 +105,7 @@ public class MmoeditCommand implements CommandExecutor { } } else { - profile.modifySkill(SkillTools.getSkillType(args[1]), newValue); + profile.modifySkill(SkillType.getSkill(args[1]), newValue); } profile.save(); // Since this is a temporary profile, we save it here. @@ -125,7 +125,7 @@ public class MmoeditCommand implements CommandExecutor { mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue)); } else { - profile.modifySkill(SkillTools.getSkillType(args[1]), newValue); + profile.modifySkill(SkillType.getSkill(args[1]), newValue); mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(args[1]), newValue)); } } 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 12678982d..ec8a5f277 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/SkillresetCommand.java @@ -72,7 +72,7 @@ public class SkillresetCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.Reset.All")); } else { - profile.modifySkill(SkillTools.getSkillType(args[0]), 0); + profile.modifySkill(SkillType.getSkill(args[0]), 0); sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(args[0]))); } @@ -132,7 +132,7 @@ public class SkillresetCommand implements CommandExecutor { } } else { - profile.modifySkill(SkillTools.getSkillType(args[1]), 0); + profile.modifySkill(SkillType.getSkill(args[1]), 0); } profile.save(); // Since this is a temporary profile, we save it here. @@ -152,7 +152,7 @@ public class SkillresetCommand implements CommandExecutor { mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.All")); } else { - profile.modifySkill(SkillTools.getSkillType(args[1]), 0); + profile.modifySkill(SkillType.getSkill(args[1]), 0); mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(args[1]))); } } 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 85e612bba..d57b91eb4 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/SkillTools.java @@ -269,22 +269,6 @@ public class SkillTools { } } - /** - * Get the skill represented by the given string - * - * @param skillName The name of the skill - * @return the SkillType if it exists, null otherwise - */ - public static SkillType getSkillType(String skillName) { - for (SkillType x : SkillType.values()) { - if (x.toString().equalsIgnoreCase(skillName)) { - return x; - } - } - - return null; - } - /** * Checks if the given string represents a valid skill * @@ -292,7 +276,7 @@ public class SkillTools { * @return true if this is a valid skill, false otherwise */ public static boolean isSkill(String skillName) { - if (getSkillType(skillName) != null) { + if (SkillType.getSkill(skillName) != null) { return true; } diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/SkillType.java b/src/main/java/com/gmail/nossr50/skills/utilities/SkillType.java index bd26ce7ff..65ba6c1e2 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/SkillType.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/SkillType.java @@ -119,7 +119,7 @@ public enum SkillType { } public static SkillType getSkill(String skillName) { - for (SkillType type : SkillType.values()) { + for (SkillType type : values()) { if (type.name().equalsIgnoreCase(skillName)) { return type; } 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 179d736b8..ff55af1a4 100644 --- a/src/main/java/com/gmail/nossr50/spout/commands/XplockCommand.java +++ b/src/main/java/com/gmail/nossr50/spout/commands/XplockCommand.java @@ -43,7 +43,7 @@ public class XplockCommand extends SpoutCommand { return true; } - lockXpBar(sender, SkillTools.getSkillType(args[0])); + lockXpBar(sender, SkillType.getSkill(args[0])); return true; }