diff --git a/src/main/java/com/gmail/nossr50/listeners/SpoutInputListener.java b/src/main/java/com/gmail/nossr50/listeners/SpoutInputListener.java deleted file mode 100644 index 12885eb4a..000000000 --- a/src/main/java/com/gmail/nossr50/listeners/SpoutInputListener.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.gmail.nossr50.listeners; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.getspout.spoutapi.event.input.KeyPressedEvent; -import org.getspout.spoutapi.gui.ScreenType; -import org.getspout.spoutapi.player.SpoutPlayer; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.popups.PopupMMO; -import com.gmail.nossr50.spout.SpoutStuff; -import com.gmail.nossr50.util.Users; - -public class SpoutInputListener implements Listener { - private mcMMO plugin; - - public SpoutInputListener(mcMMO plugin) { - this.plugin = plugin; - } - - /** - * Monitor Spout KeyPressed events. - * - * @param event The event to watch - */ - @EventHandler - public void onKeyPressedEvent(KeyPressedEvent event) { - SpoutPlayer sPlayer = event.getPlayer(); - - if (!sPlayer.isSpoutCraftEnabled() || sPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) { - return; - } - - if (event.getKey() == SpoutStuff.keypress) { - if (!SpoutStuff.playerScreens.containsKey(sPlayer)) { - PopupMMO mmoPop = new PopupMMO(sPlayer, Users.getProfile(sPlayer), plugin); - - SpoutStuff.playerScreens.put(sPlayer, mmoPop); - sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer)); - sPlayer.getMainScreen().setDirty(true); - } - else { - sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer)); - sPlayer.getMainScreen().setDirty(true); - } - } - } -} diff --git a/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java b/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java index 914789e65..1c7ccfdf5 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SpoutListener.java @@ -3,22 +3,30 @@ package com.gmail.nossr50.listeners; import org.bukkit.ChatColor; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.getspout.spoutapi.event.input.KeyPressedEvent; +import org.getspout.spoutapi.event.screen.ButtonClickEvent; +import org.getspout.spoutapi.event.screen.ScreenCloseEvent; import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent; +import org.getspout.spoutapi.gui.ScreenType; import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.SpoutConfig; +import com.gmail.nossr50.datatypes.HUDType; import com.gmail.nossr50.datatypes.HUDmmo; import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.datatypes.buttons.ButtonEscape; +import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle; +import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle; +import com.gmail.nossr50.datatypes.popups.PopupMMO; import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.util.Users; public class SpoutListener implements Listener { - //Why do we have this here? We never use it... - mcMMO plugin = null; + private final mcMMO plugin; - public SpoutListener(mcMMO pluginx) { - plugin = pluginx; + public SpoutListener(mcMMO plugin) { + this.plugin = plugin; } /** @@ -42,4 +50,96 @@ public class SpoutListener implements Listener { PPs.toggleSpoutEnabled(); } } -} \ No newline at end of file + + /** + * Monitor Spout ButtonClick events. + * + * @param event The event to watch + */ + @EventHandler + public void onButtonClick(ButtonClickEvent event) { + SpoutPlayer sPlayer = event.getPlayer(); + PlayerProfile PP = Users.getProfile(sPlayer); + + if (event.getButton() instanceof ButtonHUDStyle) { + if (SpoutStuff.playerHUDs.containsKey(sPlayer)) { + SpoutStuff.playerHUDs.get(sPlayer).resetHUD(); + SpoutStuff.playerHUDs.remove(sPlayer); + + switch (PP.getHUDType()) { + case RETRO: + PP.setHUDType(HUDType.STANDARD); + break; + + case STANDARD: + PP.setHUDType(HUDType.SMALL); + break; + + case SMALL: + PP.setHUDType(HUDType.DISABLED); + break; + + case DISABLED: + PP.setHUDType(HUDType.RETRO); + break; + + default: + break; + } + + SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); + SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP); + } + } + else if (event.getButton() instanceof ButtonEscape) { + sPlayer.getMainScreen().closePopup(); + } + else if (event.getButton() instanceof ButtonPartyToggle) { + PP.togglePartyHUD(); + ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton(); + bpt.updateText(PP); + SpoutStuff.playerHUDs.get(sPlayer).resetHUD(); + SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer); + } + } + + /** + * Monitor Spout ScreenClose events. + * + * @param event The event to watch + */ + @EventHandler + public void onScreenClose(ScreenCloseEvent event) { + if (event.getScreen() instanceof PopupMMO) { + SpoutStuff.playerScreens.remove(event.getPlayer()); + } + } + + /** + * Monitor Spout KeyPressed events. + * + * @param event The event to watch + */ + @EventHandler + public void onKeyPressedEvent(KeyPressedEvent event) { + SpoutPlayer sPlayer = event.getPlayer(); + + if (!sPlayer.isSpoutCraftEnabled() || sPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) { + return; + } + + if (event.getKey() == SpoutStuff.keypress) { + if (!SpoutStuff.playerScreens.containsKey(sPlayer)) { + PopupMMO mmoPop = new PopupMMO(sPlayer, Users.getProfile(sPlayer), plugin); + + SpoutStuff.playerScreens.put(sPlayer, mmoPop); + sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer)); + sPlayer.getMainScreen().setDirty(true); + } + else { + sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer)); + sPlayer.getMainScreen().setDirty(true); + } + } + } +} diff --git a/src/main/java/com/gmail/nossr50/listeners/SpoutScreenListener.java b/src/main/java/com/gmail/nossr50/listeners/SpoutScreenListener.java deleted file mode 100644 index c71a81274..000000000 --- a/src/main/java/com/gmail/nossr50/listeners/SpoutScreenListener.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.gmail.nossr50.listeners; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.getspout.spoutapi.event.screen.ButtonClickEvent; -import org.getspout.spoutapi.event.screen.ScreenCloseEvent; -import org.getspout.spoutapi.player.SpoutPlayer; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.HUDType; -import com.gmail.nossr50.datatypes.HUDmmo; -import com.gmail.nossr50.datatypes.PlayerProfile; -import com.gmail.nossr50.datatypes.buttons.ButtonEscape; -import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle; -import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle; -import com.gmail.nossr50.datatypes.popups.PopupMMO; -import com.gmail.nossr50.spout.SpoutStuff; -import com.gmail.nossr50.util.Users; - -public class SpoutScreenListener implements Listener { - //Why do we have this here? We never use it... - mcMMO plugin = null; - - public SpoutScreenListener(mcMMO pluginx) { - plugin = pluginx; - } - - /** - * Monitor Spout ButtonClick events. - * - * @param event The event to watch - */ - @EventHandler - public void onButtonClick(ButtonClickEvent event) { - SpoutPlayer sPlayer = event.getPlayer(); - PlayerProfile PP = Users.getProfile(sPlayer); - - if (event.getButton() instanceof ButtonHUDStyle) { - if (SpoutStuff.playerHUDs.containsKey(sPlayer)) { - SpoutStuff.playerHUDs.get(sPlayer).resetHUD(); - SpoutStuff.playerHUDs.remove(sPlayer); - - switch (PP.getHUDType()) { - case RETRO: - PP.setHUDType(HUDType.STANDARD); - break; - - case STANDARD: - PP.setHUDType(HUDType.SMALL); - break; - - case SMALL: - PP.setHUDType(HUDType.DISABLED); - break; - - case DISABLED: - PP.setHUDType(HUDType.RETRO); - break; - - default: - break; - } - - SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); - SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP); - } - } - else if (event.getButton() instanceof ButtonEscape) { - sPlayer.getMainScreen().closePopup(); - } - else if (event.getButton() instanceof ButtonPartyToggle) { - PP.togglePartyHUD(); - ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton(); - bpt.updateText(PP); - SpoutStuff.playerHUDs.get(sPlayer).resetHUD(); - SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer); - } - } - - /** - * Monitor Spout ScreenClose events. - * - * @param event The event to watch - */ - @EventHandler - public void onScreenClose(ScreenCloseEvent event) { - if (event.getScreen() instanceof PopupMMO) { - SpoutStuff.playerScreens.remove(event.getPlayer()); - } - } -} diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java b/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java index ec7b2d3f6..940d199c6 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java @@ -25,9 +25,7 @@ import com.gmail.nossr50.datatypes.HUDmmo; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.popups.PopupMMO; import com.gmail.nossr50.datatypes.SkillType; -import com.gmail.nossr50.listeners.SpoutInputListener; import com.gmail.nossr50.listeners.SpoutListener; -import com.gmail.nossr50.listeners.SpoutScreenListener; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Users; @@ -41,8 +39,6 @@ public class SpoutStuff { public final static String soundDirectory = spoutDirectory + "Sound" + File.separator; private final static SpoutListener spoutListener = new SpoutListener(plugin); - private final static SpoutInputListener spoutInputListener = new SpoutInputListener(plugin); - private final static SpoutScreenListener spoutScreenListener = new SpoutScreenListener(plugin); public static HashMap playerHUDs = new HashMap(); public static HashMap playerScreens = new HashMap(); @@ -201,8 +197,6 @@ public class SpoutStuff { */ public static void registerCustomEvent() { plugin.getServer().getPluginManager().registerEvents(spoutListener, plugin); - plugin.getServer().getPluginManager().registerEvents(spoutInputListener, plugin); - plugin.getServer().getPluginManager().registerEvents(spoutScreenListener, plugin); } /**