瀏覽代碼

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
NuclearW 13 年之前
父節點
當前提交
9278ca4d27
共有 1 個文件被更改,包括 40 次插入0 次删除
  1. 40 0
      src/main/java/com/gmail/nossr50/listeners/mcSelfListener.java

+ 40 - 0
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 <http://www.gnu.org/licenses/>.
+*/
+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();
+			}
+		}
+	}
+}