mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-02 01:46:45 +01:00
Cleanup
This commit is contained in:
parent
3525dc82b0
commit
ed1c072fd7
@ -521,6 +521,7 @@ public class McMMOPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
profile.setSkillXpLevel(skillType, profile.getSkillXpLevelRaw(skillType) + event.getRawXpGained());
|
profile.setSkillXpLevel(skillType, profile.getSkillXpLevelRaw(skillType) + event.getRawXpGained());
|
||||||
|
profile.registeredXpGain(skillType, event.getRawXpGained());
|
||||||
|
|
||||||
McMMOHud spoutHud = profile.getSpoutHud();
|
McMMOHud spoutHud = profile.getSpoutHud();
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ public class PlayerProfile {
|
|||||||
public void registeredXpGain(SkillType skillType, float xp) {
|
public void registeredXpGain(SkillType skillType, float xp) {
|
||||||
LinkedList<SkillXpGain> gains = gainedSkillsXp.get(skillType);
|
LinkedList<SkillXpGain> gains = gainedSkillsXp.get(skillType);
|
||||||
|
|
||||||
if(gains == null) {
|
if (gains == null) {
|
||||||
gains = new LinkedList<SkillXpGain>(); // Maybe add an initial capacity?
|
gains = new LinkedList<SkillXpGain>(); // Maybe add an initial capacity?
|
||||||
}
|
}
|
||||||
gains.addLast(new SkillXpGain(System.currentTimeMillis(), xp));
|
gains.addLast(new SkillXpGain(System.currentTimeMillis(), xp));
|
||||||
@ -302,20 +302,21 @@ public class PlayerProfile {
|
|||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
Iterator<Entry<SkillType, LinkedList<SkillXpGain>>> iterator = gainedSkillsXp.entrySet().iterator();
|
Iterator<Entry<SkillType, LinkedList<SkillXpGain>>> iterator = gainedSkillsXp.entrySet().iterator();
|
||||||
while(iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Entry<SkillType, LinkedList<SkillXpGain>> skillGains = iterator.next();
|
Entry<SkillType, LinkedList<SkillXpGain>> skillGains = iterator.next();
|
||||||
|
|
||||||
float xp = 0;
|
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
|
// 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<SkillXpGain> gainsIterator = skillGains.getValue().iterator();
|
Iterator<SkillXpGain> gainsIterator = skillGains.getValue().iterator();
|
||||||
while(gainsIterator.hasNext()) {
|
while (gainsIterator.hasNext()) {
|
||||||
SkillXpGain gain = gainsIterator.next();
|
SkillXpGain gain = gainsIterator.next();
|
||||||
|
|
||||||
if(now - gain.getTime() >= age) {
|
if (now - gain.getTime() >= age) {
|
||||||
gainsIterator.remove();
|
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());
|
xp += rollingSkillsXp.get(skillGains.getKey());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,5 @@ public class SelfListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer.getProfile().registeredXpGain(skillType, event.getRawXpGained());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user