From 9a852b1baf2b76dbf9bba54b6171c757274980ba Mon Sep 17 00:00:00 2001 From: Kane York Date: Wed, 5 Jun 2013 10:55:19 -0600 Subject: [PATCH] Don't calculate diminshed returns when subtracting XP Any penalty XP that goes through the event after diminished returns has activated would be cancelled by this listener. This bails out early if the event is subtracting. --- .../java/com/gmail/nossr50/listeners/SelfListener.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index 2ff497700..65b8f495f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -39,7 +39,12 @@ public class SelfListener implements Listener { int threshold = Config.getInstance().getExperienceDeminishedReturnsThreshold(); if (threshold <= 0) { - return; + return; // Dim. returns is turned off + } + + final int rawXp = event.getRawXpGained(); + if (rawXp < 0) { + return; // Don't calculate for XP subtraction } Player player = event.getPlayer(); @@ -58,7 +63,7 @@ public class SelfListener implements Listener { // System.out.println(difference * 100 + "% over the threshold!"); // System.out.println("Previous: " + event.getRawXpGained()); // System.out.println("Adjusted XP " + (event.getRawXpGained() - (event.getRawXpGained() * difference))); - float newValue = event.getRawXpGained() - (event.getRawXpGained() * difference); + float newValue = rawXp - (rawXp * difference); if (newValue > 0) { event.setRawXpGained(newValue);