diff --git a/src/main/java/com/gmail/nossr50/config/spout/SpoutConfig.java b/src/main/java/com/gmail/nossr50/config/spout/SpoutConfig.java index 5a61d93a6..a37b57bbe 100644 --- a/src/main/java/com/gmail/nossr50/config/spout/SpoutConfig.java +++ b/src/main/java/com/gmail/nossr50/config/spout/SpoutConfig.java @@ -1,5 +1,7 @@ package com.gmail.nossr50.config.spout; +import org.getspout.spoutapi.keyboard.Keyboard; + import com.gmail.nossr50.config.ConfigLoader; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.spout.huds.HudType; @@ -34,7 +36,14 @@ public class SpoutConfig extends ConfigLoader { } public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); } - public String getMenuKey() { return config.getString("Menu.Key", "KEY_M"); } + public Keyboard getMenuKey() { + try { + return Keyboard.valueOf(config.getString("Menu.Key", "KEY_M").toUpperCase().trim()); + } + catch (IllegalArgumentException ex) { + return Keyboard.KEY_M; + } + } /* XP Bar */ public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); } diff --git a/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java b/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java index 988515c4e..6781d12e4 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java @@ -11,13 +11,13 @@ import org.getspout.spoutapi.gui.Button; import org.getspout.spoutapi.gui.ScreenType; import org.getspout.spoutapi.player.SpoutPlayer; +import com.gmail.nossr50.config.spout.SpoutConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton; import com.gmail.nossr50.datatypes.spout.huds.McMMOHud; import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.player.UserManager; -import com.gmail.nossr50.util.spout.SpoutUtils; public class SpoutListener implements Listener { @@ -32,7 +32,7 @@ public class SpoutListener implements Listener { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(spoutPlayer); // TODO: Add custom titles based on skills - if (SpoutUtils.showPowerLevel) { + if (SpoutConfig.getInstance().getShowPowerLevel()) { spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getTitle(), mcMMOPlayer.getPowerLevel())); } @@ -81,7 +81,7 @@ public class SpoutListener implements Listener { return; } - if (event.getKey() == SpoutUtils.menuKey) { + if (event.getKey() == SpoutConfig.getInstance().getMenuKey()) { McMMOHud spoutHud = UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud(); if (!spoutHud.isMenuOpened()) { diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index b7536d981..c31ec61b3 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -321,7 +321,6 @@ public class mcMMO extends JavaPlugin { spoutEnabled = true; SpoutConfig.getInstance(); - SpoutUtils.setupSpoutConfigs(); SpoutUtils.registerCustomEvent(); SpoutUtils.preCacheFiles(); SpoutUtils.reloadSpoutPlayers(); // Handle spout players after a /reload diff --git a/src/main/java/com/gmail/nossr50/util/spout/SpoutUtils.java b/src/main/java/com/gmail/nossr50/util/spout/SpoutUtils.java index be404e757..c7ee8ab55 100644 --- a/src/main/java/com/gmail/nossr50/util/spout/SpoutUtils.java +++ b/src/main/java/com/gmail/nossr50/util/spout/SpoutUtils.java @@ -13,13 +13,11 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.getspout.spoutapi.SpoutManager; import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent; -import org.getspout.spoutapi.keyboard.Keyboard; import org.getspout.spoutapi.player.FileManager; import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.spout.SpoutConfig; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.listeners.SpoutListener; @@ -37,10 +35,8 @@ public class SpoutUtils { public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator; public final static String soundDirectory = spoutDirectory + "Sound" + File.separator; - public static boolean showPowerLevel; - private final static SpoutListener spoutListener = new SpoutListener(); - public static Keyboard menuKey; +// public static Keyboard menuKey; /** * Write file to disk. @@ -148,25 +144,6 @@ public class SpoutUtils { writeFile("level.wav", soundDirectory); } - /** - * Setup Spout config options - */ - public static void setupSpoutConfigs() { - showPowerLevel = SpoutConfig.getInstance().getShowPowerLevel(); - String temp = SpoutConfig.getInstance().getMenuKey(); - - for (Keyboard x : Keyboard.values()) { - if (x.toString().equalsIgnoreCase(temp)) { - menuKey = x; - } - } - - if (menuKey == null) { - mcMMO.p.getLogger().warning("Invalid KEY for Menu.Key, using KEY_M"); - menuKey = Keyboard.KEY_M; - } - } - /** * Get all the Spout files in the Resources folder. *