diff --git a/src/com/onarandombox/MultiverseCore/MVWorld.java b/src/com/onarandombox/MultiverseCore/MVWorld.java index a181b944..1638135f 100644 --- a/src/com/onarandombox/MultiverseCore/MVWorld.java +++ b/src/com/onarandombox/MultiverseCore/MVWorld.java @@ -11,35 +11,48 @@ import org.bukkit.World.Environment; import org.bukkit.util.config.Configuration; enum EnglishChatColor { - AQUA(ChatColor.AQUA), - BLACK(ChatColor.BLACK), - BLUE(ChatColor.BLUE), - DARKAQUA(ChatColor.DARK_AQUA), - DARKBLUE(ChatColor.DARK_BLUE), - DARKGRAY(ChatColor.DARK_GRAY), - DARKGREEN(ChatColor.DARK_GREEN), - DARKPURPLE(ChatColor.DARK_PURPLE), - DARKRED(ChatColor.DARK_RED), - GOLD(ChatColor.GOLD), - GRAY(ChatColor.GRAY), - GREEN(ChatColor.GREEN), - LIGHTPURPLE(ChatColor.LIGHT_PURPLE), - RED(ChatColor.RED), - YELLOW(ChatColor.YELLOW), - WHITE(ChatColor.WHITE); + AQUA("AQUA", ChatColor.AQUA), + BLACK("BLACK", ChatColor.BLACK), + BLUE("BLUE", ChatColor.BLUE), + DARKAQUA("DARKAQUA", ChatColor.DARK_AQUA), + DARKBLUE("DARKBLUE", ChatColor.DARK_BLUE), + DARKGRAY("DARKGRAY", ChatColor.DARK_GRAY), + DARKGREEN("DARKGREEN", ChatColor.DARK_GREEN), + DARKPURPLE("DARKPURPLE", ChatColor.DARK_PURPLE), + DARKRED("DARKRED", ChatColor.DARK_RED), + GOLD("GOLD", ChatColor.GOLD), + GRAY("GRAY", ChatColor.GRAY), + GREEN("GREEN", ChatColor.GREEN), + LIGHTPURPLE("LIGHTPURPLE", ChatColor.LIGHT_PURPLE), + RED("RED", ChatColor.RED), + YELLOW("YELLOW", ChatColor.YELLOW), + WHITE("WHITE", ChatColor.WHITE); private ChatColor color; + private String text; - EnglishChatColor(ChatColor color) { + EnglishChatColor(String name, ChatColor color) { this.color = color; + this.text = name; } public String getText() { - return this.toString(); + return this.text; } public ChatColor getColor() { return this.color; } + + public static EnglishChatColor fromString(String text) { + if (text != null) { + for (EnglishChatColor c : EnglishChatColor.values()) { + if (text.equalsIgnoreCase(c.text)) { + return c; + } + } + } + return EnglishChatColor.WHITE; + } } public class MVWorld { @@ -460,19 +473,10 @@ public class MVWorld { } public void setAliasColor(String aliasColor) { - try { - this.aliasColor = EnglishChatColor.valueOf(aliasColor).getColor(); - } catch (Exception e) { - this.aliasColor = ChatColor.WHITE; - } - if (this.aliasColor != null) { - this.config.setProperty("worlds." + this.name + ".alias.color", aliasColor); - this.config.save(); - } else { - this.plugin.log(Level.WARNING, "Color \"" + aliasColor + "\" was not found."); - this.aliasColor = ChatColor.WHITE; - } - + EnglishChatColor color = EnglishChatColor.fromString(aliasColor); + this.aliasColor = color.getColor(); + this.config.setProperty("worlds." + this.name + ".alias.color", color.getText()); + this.config.save(); return; }