mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Only save on changes
This commit is contained in:
parent
24ceeb626b
commit
79346d92d7
@ -30,6 +30,7 @@ public class PlayerProfile {
|
||||
private final Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
|
||||
private final Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||
private final Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||
private boolean changed = false;
|
||||
|
||||
public PlayerProfile(String playerName) {
|
||||
this.playerName = playerName;
|
||||
@ -69,7 +70,10 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
mcMMO.getDatabaseManager().saveUser(this);
|
||||
if (changed) {
|
||||
mcMMO.getDatabaseManager().saveUser(this);
|
||||
changed = false;
|
||||
}
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
@ -147,6 +151,8 @@ public class PlayerProfile {
|
||||
public void setSkillDATS(AbilityType abilityType, long DATS) {
|
||||
int wearsOff = (int) (DATS * .001D);
|
||||
|
||||
changed = true;
|
||||
|
||||
skillsDATS.put(abilityType, wearsOff);
|
||||
}
|
||||
|
||||
@ -154,6 +160,8 @@ public class PlayerProfile {
|
||||
* Reset all skill cooldowns.
|
||||
*/
|
||||
public void resetCooldowns() {
|
||||
changed = true;
|
||||
|
||||
for (AbilityType ability : skillsDATS.keySet()) {
|
||||
skillsDATS.put(ability, 0);
|
||||
}
|
||||
@ -202,6 +210,8 @@ public class PlayerProfile {
|
||||
return;
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) - xp);
|
||||
}
|
||||
|
||||
@ -216,6 +226,8 @@ public class PlayerProfile {
|
||||
return;
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
||||
skills.put(skillType, newValue);
|
||||
skillsXp.put(skillType, 0F);
|
||||
}
|
||||
@ -231,6 +243,8 @@ public class PlayerProfile {
|
||||
return;
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
||||
skills.put(skillType, skills.get(skillType) + levels);
|
||||
skillsXp.put(skillType, 0F);
|
||||
}
|
||||
@ -246,6 +260,8 @@ public class PlayerProfile {
|
||||
return;
|
||||
}
|
||||
|
||||
changed = true;
|
||||
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) + experience);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user