mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-25 18:17:46 +01:00
*CLEANUP* - mcSelfListener.java & mcSpoutInputListener.java
This commit is contained in:
parent
4359dc764f
commit
def65282dd
@ -9,16 +9,24 @@ import com.gmail.nossr50.events.McMMOPlayerXpGainEvent;
|
||||
* Listener for listening to our own events, only really useful for catching errors
|
||||
*/
|
||||
public class mcSelfListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
|
||||
int xp = event.getXpGained();
|
||||
if(xp < 0) {
|
||||
try {
|
||||
throw new Exception("Gained negative XP!");
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor internal XP gain events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
|
||||
int xp = event.getXpGained();
|
||||
|
||||
if(xp < 0) {
|
||||
try {
|
||||
throw new Exception("Gained negative XP!");
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,37 +11,38 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
|
||||
public class mcSpoutInputListener implements Listener
|
||||
{
|
||||
mcMMO plugin = null;
|
||||
|
||||
public mcSpoutInputListener(mcMMO pluginx)
|
||||
{
|
||||
plugin = pluginx;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onKeyPressedEvent(KeyPressedEvent event)
|
||||
{
|
||||
if(!event.getPlayer().isSpoutCraftEnabled() || event.getPlayer().getMainScreen().getActivePopup() != null)
|
||||
return;
|
||||
if(event.getScreenType() != ScreenType.GAME_SCREEN)
|
||||
return;
|
||||
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class mcSpoutInputListener implements Listener {
|
||||
private mcMMO plugin;
|
||||
|
||||
public mcSpoutInputListener(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user