*CLEANUP* - mcSpoutListener.java & mcSpoutScreenListener.java

This commit is contained in:
GJ 2012-03-11 01:39:14 -05:00
parent def65282dd
commit 0a8d34a21f
3 changed files with 94 additions and 85 deletions

View File

@ -46,7 +46,6 @@ import com.gmail.nossr50.skills.Repair;
import com.gmail.nossr50.skills.Skills; import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Taming; import com.gmail.nossr50.skills.Taming;
public class mcPlayerListener implements Listener { public class mcPlayerListener implements Listener {
protected static final Logger log = Logger.getLogger("Minecraft"); protected static final Logger log = Logger.getLogger("Minecraft");
private mcMMO plugin; private mcMMO plugin;

View File

@ -10,25 +10,25 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.HUDmmo; import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.spout.SpoutStuff;
public class mcSpoutListener implements Listener public class mcSpoutListener implements Listener {
{ //Why do we have this here? We never use it...
mcMMO plugin = null; mcMMO plugin = null;
public mcSpoutListener(mcMMO pluginx) public mcSpoutListener(mcMMO pluginx) {
{
plugin = pluginx; plugin = pluginx;
} }
/**
* Monitor SpoutCraftEnable events.
*
* @param event The event to watch
*/
@EventHandler @EventHandler
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
{
SpoutPlayer sPlayer = event.getPlayer(); SpoutPlayer sPlayer = event.getPlayer();
if(sPlayer.isSpoutCraftEnabled())
{
//Setup Party HUD stuff
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer));
//Party.update(sPlayer); if (sPlayer.isSpoutCraftEnabled()) {
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer)); //Setup Party HUD stuff
Users.getProfile(sPlayer).toggleSpoutEnabled(); Users.getProfile(sPlayer).toggleSpoutEnabled();
} }
} }

View File

@ -17,51 +17,58 @@ import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
import com.gmail.nossr50.datatypes.popups.PopupMMO; import com.gmail.nossr50.datatypes.popups.PopupMMO;
import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.spout.SpoutStuff;
public class mcSpoutScreenListener implements Listener public class mcSpoutScreenListener implements Listener {
{ //Why do we have this here? We never use it...
mcMMO plugin = null; mcMMO plugin = null;
public mcSpoutScreenListener(mcMMO pluginx)
{ public mcSpoutScreenListener(mcMMO pluginx) {
plugin = pluginx; plugin = pluginx;
} }
/**
* Monitor Spout ButtonClick events.
*
* @param event The event to watch
*/
@EventHandler @EventHandler
public void onButtonClick(ButtonClickEvent event) public void onButtonClick(ButtonClickEvent event) {
{
SpoutPlayer sPlayer = event.getPlayer(); SpoutPlayer sPlayer = event.getPlayer();
PlayerProfile PP = Users.getProfile(sPlayer); PlayerProfile PP = Users.getProfile(sPlayer);
if(event.getButton() instanceof ButtonHUDStyle) if (event.getButton() instanceof ButtonHUDStyle) {
{ if (SpoutStuff.playerHUDs.containsKey(sPlayer)) {
if(SpoutStuff.playerHUDs.containsKey(sPlayer))
{
SpoutStuff.playerHUDs.get(sPlayer).resetHUD(); SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
SpoutStuff.playerHUDs.remove(sPlayer); SpoutStuff.playerHUDs.remove(sPlayer);
switch(PP.getHUDType()) switch (PP.getHUDType()) {
{
case RETRO: case RETRO:
PP.setHUDType(HUDType.STANDARD); PP.setHUDType(HUDType.STANDARD);
break; break;
case STANDARD: case STANDARD:
PP.setHUDType(HUDType.SMALL); PP.setHUDType(HUDType.SMALL);
break; break;
case SMALL: case SMALL:
PP.setHUDType(HUDType.DISABLED); PP.setHUDType(HUDType.DISABLED);
break; break;
case DISABLED: case DISABLED:
PP.setHUDType(HUDType.RETRO); PP.setHUDType(HUDType.RETRO);
break;
default:
break;
} }
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer)); SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer));
SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP); SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP);
} }
} else if (event.getButton() instanceof ButtonEscape) }
{ else if (event.getButton() instanceof ButtonEscape) {
sPlayer.getMainScreen().closePopup(); sPlayer.getMainScreen().closePopup();
} else if (event.getButton() instanceof ButtonPartyToggle) }
{ else if (event.getButton() instanceof ButtonPartyToggle) {
PP.togglePartyHUD(); PP.togglePartyHUD();
ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton(); ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton();
bpt.updateText(PP); bpt.updateText(PP);
@ -70,11 +77,14 @@ public class mcSpoutScreenListener implements Listener
} }
} }
/**
* Monitor Spout ScreenClose events.
*
* @param event The event to watch
*/
@EventHandler @EventHandler
public void onScreenClose(ScreenCloseEvent event) public void onScreenClose(ScreenCloseEvent event) {
{ if (event.getScreen() instanceof PopupMMO) {
if(event.getScreen() instanceof PopupMMO)
{
SpoutStuff.playerScreens.remove(event.getPlayer()); SpoutStuff.playerScreens.remove(event.getPlayer());
} }
} }