*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,26 +10,26 @@ 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; }
}
/**
@EventHandler * Monitor SpoutCraftEnable events.
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) *
{ * @param event The event to watch
SpoutPlayer sPlayer = event.getPlayer(); */
if(sPlayer.isSpoutCraftEnabled()) @EventHandler
{ public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
//Setup Party HUD stuff SpoutPlayer sPlayer = event.getPlayer();
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer));
//Party.update(sPlayer); if (sPlayer.isSpoutCraftEnabled()) {
Users.getProfile(sPlayer).toggleSpoutEnabled(); SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer)); //Setup Party HUD stuff
} Users.getProfile(sPlayer).toggleSpoutEnabled();
} }
} }
}

View File

@ -17,65 +17,75 @@ 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;
} }
@EventHandler /**
public void onButtonClick(ButtonClickEvent event) * Monitor Spout ButtonClick events.
{ *
SpoutPlayer sPlayer = event.getPlayer(); * @param event The event to watch
PlayerProfile PP = Users.getProfile(sPlayer); */
@EventHandler
if(event.getButton() instanceof ButtonHUDStyle) public void onButtonClick(ButtonClickEvent event) {
{ SpoutPlayer sPlayer = event.getPlayer();
if(SpoutStuff.playerHUDs.containsKey(sPlayer)) PlayerProfile PP = Users.getProfile(sPlayer);
{
SpoutStuff.playerHUDs.get(sPlayer).resetHUD(); if (event.getButton() instanceof ButtonHUDStyle) {
SpoutStuff.playerHUDs.remove(sPlayer); if (SpoutStuff.playerHUDs.containsKey(sPlayer)) {
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
switch(PP.getHUDType()) SpoutStuff.playerHUDs.remove(sPlayer);
{
case RETRO: switch (PP.getHUDType()) {
PP.setHUDType(HUDType.STANDARD); case RETRO:
break; PP.setHUDType(HUDType.STANDARD);
case STANDARD: break;
PP.setHUDType(HUDType.SMALL);
break; case STANDARD:
case SMALL: PP.setHUDType(HUDType.SMALL);
PP.setHUDType(HUDType.DISABLED); break;
break;
case DISABLED: case SMALL:
PP.setHUDType(HUDType.RETRO); PP.setHUDType(HUDType.DISABLED);
} break;
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer)); case DISABLED:
PP.setHUDType(HUDType.RETRO);
SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP); break;
}
} else if (event.getButton() instanceof ButtonEscape) default:
{ break;
sPlayer.getMainScreen().closePopup(); }
} else if (event.getButton() instanceof ButtonPartyToggle)
{ SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer));
PP.togglePartyHUD(); SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP);
ButtonPartyToggle bpt = (ButtonPartyToggle)event.getButton(); }
bpt.updateText(PP); }
SpoutStuff.playerHUDs.get(sPlayer).resetHUD(); else if (event.getButton() instanceof ButtonEscape) {
SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer); sPlayer.getMainScreen().closePopup();
} }
} else if (event.getButton() instanceof ButtonPartyToggle) {
PP.togglePartyHUD();
@EventHandler ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton();
public void onScreenClose(ScreenCloseEvent event) bpt.updateText(PP);
{ SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
if(event.getScreen() instanceof PopupMMO) SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer);
{ }
SpoutStuff.playerScreens.remove(event.getPlayer()); }
}
} /**
} * 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());
}
}
}