From 9278ca4d27c0211aa886f7f6c4cb206c3cfcc998 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Sat, 11 Feb 2012 00:11:08 -0500 Subject: [PATCH] Watch ourselves for negative xp gain. Hopefully we'll get more info on the bug if we can't solve it by next release from anyone running a dev build. Will help on the hunt of issue #98 --- .../nossr50/listeners/mcSelfListener.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/com/gmail/nossr50/listeners/mcSelfListener.java diff --git a/src/main/java/com/gmail/nossr50/listeners/mcSelfListener.java b/src/main/java/com/gmail/nossr50/listeners/mcSelfListener.java new file mode 100644 index 000000000..7b247b8e3 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/listeners/mcSelfListener.java @@ -0,0 +1,40 @@ +/* + This file is part of mcMMO. + + mcMMO is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + mcMMO is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with mcMMO. If not, see . +*/ +package com.gmail.nossr50.listeners; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +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(); + } + } + } +}