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 8e89f7786..b3c4d7813 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -30,6 +30,7 @@ public class PlayerProfile { private final Map skills = new HashMap(); // Skill & Level private final Map skillsXp = new HashMap(); // Skill & XP private final Map skillsDATS = new HashMap(); // 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); }