diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index c6b784666..24a9ccd06 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -521,6 +521,7 @@ public class McMMOPlayer { } profile.setSkillXpLevel(skillType, profile.getSkillXpLevelRaw(skillType) + event.getRawXpGained()); + profile.registeredXpGain(skillType, event.getRawXpGained()); McMMOHud spoutHud = profile.getSpoutHud(); diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index 4cb2f11d5..6c1d085ad 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -262,7 +262,7 @@ public class PlayerProfile { */ public float getRegisteredXpGain(SkillType skillType) { float xp; - + if (rollingSkillsXp.get(skillType) == null) { xp = 0F; } @@ -283,7 +283,7 @@ public class PlayerProfile { public void registeredXpGain(SkillType skillType, float xp) { LinkedList gains = gainedSkillsXp.get(skillType); - if(gains == null) { + if (gains == null) { gains = new LinkedList(); // Maybe add an initial capacity? } gains.addLast(new SkillXpGain(System.currentTimeMillis(), xp)); @@ -302,20 +302,21 @@ public class PlayerProfile { long now = System.currentTimeMillis(); Iterator>> iterator = gainedSkillsXp.entrySet().iterator(); - while(iterator.hasNext()) { + while (iterator.hasNext()) { Entry> skillGains = iterator.next(); float xp = 0; // Because we are using a LinkedList and addLast ordering is guaranteed, so we loop through and remove things that are too old, and stop immediately once we find a young'n Iterator gainsIterator = skillGains.getValue().iterator(); - while(gainsIterator.hasNext()) { + while (gainsIterator.hasNext()) { SkillXpGain gain = gainsIterator.next(); - if(now - gain.getTime() >= age) { + if (now - gain.getTime() >= age) { gainsIterator.remove(); - // Because gainedSkillsXp conatins this SkillType, we assume that rollingSkillsXp must also have this SkillType + // Because gainedSkillsXp contains this SkillType, we assume that rollingSkillsXp must also have this SkillType xp += rollingSkillsXp.get(skillGains.getKey()); - } else { + } + else { break; } } diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index 63752ed25..2ff497700 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -67,7 +67,5 @@ public class SelfListener implements Listener { event.setCancelled(true); } } - - mcMMOPlayer.getProfile().registeredXpGain(skillType, event.getRawXpGained()); } }