mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-19 16:59:37 +01:00
Moved all Spout checks into one listener.
This commit is contained in:
parent
63f683982f
commit
77d74717d2
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,22 +3,30 @@ package com.gmail.nossr50.listeners;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
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.event.spout.SpoutCraftEnableEvent;
|
||||||
|
import org.getspout.spoutapi.gui.ScreenType;
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.SpoutConfig;
|
import com.gmail.nossr50.config.SpoutConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.HUDType;
|
||||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
import com.gmail.nossr50.datatypes.HUDmmo;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
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.spout.SpoutStuff;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class SpoutListener implements Listener {
|
public class SpoutListener implements Listener {
|
||||||
//Why do we have this here? We never use it...
|
private final mcMMO plugin;
|
||||||
mcMMO plugin = null;
|
|
||||||
|
|
||||||
public SpoutListener(mcMMO pluginx) {
|
public SpoutListener(mcMMO plugin) {
|
||||||
plugin = pluginx;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,4 +50,96 @@ public class SpoutListener implements Listener {
|
|||||||
PPs.toggleSpoutEnabled();
|
PPs.toggleSpoutEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -25,9 +25,7 @@ import com.gmail.nossr50.datatypes.HUDmmo;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
import com.gmail.nossr50.listeners.SpoutInputListener;
|
|
||||||
import com.gmail.nossr50.listeners.SpoutListener;
|
import com.gmail.nossr50.listeners.SpoutListener;
|
||||||
import com.gmail.nossr50.listeners.SpoutScreenListener;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
@ -41,8 +39,6 @@ public class SpoutStuff {
|
|||||||
public final static String soundDirectory = spoutDirectory + "Sound" + File.separator;
|
public final static String soundDirectory = spoutDirectory + "Sound" + File.separator;
|
||||||
|
|
||||||
private final static SpoutListener spoutListener = new SpoutListener(plugin);
|
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<Player, HUDmmo> playerHUDs = new HashMap<Player, HUDmmo>();
|
public static HashMap<Player, HUDmmo> playerHUDs = new HashMap<Player, HUDmmo>();
|
||||||
public static HashMap<SpoutPlayer, PopupMMO> playerScreens = new HashMap<SpoutPlayer, PopupMMO>();
|
public static HashMap<SpoutPlayer, PopupMMO> playerScreens = new HashMap<SpoutPlayer, PopupMMO>();
|
||||||
@ -201,8 +197,6 @@ public class SpoutStuff {
|
|||||||
*/
|
*/
|
||||||
public static void registerCustomEvent() {
|
public static void registerCustomEvent() {
|
||||||
plugin.getServer().getPluginManager().registerEvents(spoutListener, plugin);
|
plugin.getServer().getPluginManager().registerEvents(spoutListener, plugin);
|
||||||
plugin.getServer().getPluginManager().registerEvents(spoutInputListener, plugin);
|
|
||||||
plugin.getServer().getPluginManager().registerEvents(spoutScreenListener, plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user