From 3236ee5ec90f71656ad02181a99e5a08c7f02705 Mon Sep 17 00:00:00 2001 From: riking Date: Sat, 16 Nov 2013 17:21:21 -0800 Subject: [PATCH] Harden save() method by making a defensive copy --- .../java/com/gmail/nossr50/datatypes/player/PlayerProfile.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 e39239e47..cf8742c8d 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -13,6 +13,7 @@ import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.util.player.UserManager; +import com.google.common.collect.ImmutableMap; public class PlayerProfile { private final String playerName; @@ -63,7 +64,7 @@ public class PlayerProfile { return; } - changed = !mcMMO.getDatabaseManager().saveUser(this); + changed = !mcMMO.getDatabaseManager().saveUser(new PlayerProfile(playerName, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType)); if (changed) { mcMMO.p.getLogger().warning("PlayerProfile for " + playerName + " failed to save");