diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PersistentPlayerDataBuilder.java b/src/main/java/com/gmail/nossr50/datatypes/player/PersistentPlayerDataBuilder.java index e41ce98bb..e3dc07a06 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PersistentPlayerDataBuilder.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PersistentPlayerDataBuilder.java @@ -6,7 +6,12 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.experience.MMOExperienceBarManager; import com.neetgames.mcmmo.MobHealthBarType; import com.neetgames.mcmmo.UniqueDataType; +import com.neetgames.mcmmo.api.SkillRegister; +import com.neetgames.mcmmo.skill.RootSkill; import com.neetgames.mcmmo.skill.SkillBossBarState; +import com.neetgames.mcmmo.skill.SkillIdentity; +import com.neetgames.mcmmo.skill.SuperSkill; +import it.unimi.dsi.fastutil.Hash; import org.apache.commons.lang.NullArgumentException; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -14,6 +19,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.EnumMap; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; public class PersistentPlayerDataBuilder { @@ -29,11 +36,11 @@ public class PersistentPlayerDataBuilder { private @Nullable MobHealthBarType mobHealthBarType; /* Skill Data */ - private @Nullable EnumMap skillLevelValues; - private @Nullable EnumMap skillExperienceValues; - private @Nullable EnumMap abilityDeactivationTimestamps; // Ability & Cooldown - private @Nullable EnumMap uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..) - private @Nullable EnumMap barStateMap; + private @Nullable Map skillLevelValues; + private @Nullable Map skillExperienceValues; + private @Nullable Map abilityDeactivationTimestamps; // Ability & Cooldown + private @Nullable Map uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..) + private @Nullable Map barStateMap; /* Special Flags */ private boolean partyChatSpying; @@ -99,19 +106,19 @@ public class PersistentPlayerDataBuilder { throw new NullArgumentException("mobHealthBarType"); - return new PersistentPlayerData(playerUUID, playerName, partyChatSpying, skillLevelValues, skillExperienceValues, abilityDeactivationTimestamps, uniquePlayerData, barStateMap, scoreboardTipsShown, mobHealthBarType, lastLogin, leaderBoardExemption); + return new PersistentPlayerData(playerUUID, playerName, partyChatSpying, skillLevelValues, skillExperienceValues, abilityDeactivationTimestamps, uniquePlayerData, barStateMap, scoreboardTipsShown, lastLogin, leaderBoardExemption); } - private void validateBarStateMapEntries(@NotNull EnumMap map) { - EnumMap barMapDefaults = MMOExperienceBarManager.generateDefaultBarStateMap(); - - for(PrimarySkillType primarySkillType : PrimarySkillType.values()) { - map.putIfAbsent(primarySkillType, barMapDefaults.get(primarySkillType)); + private void validateBarStateMapEntries(@NotNull Map map) { + Map barMapDefaults = MMOExperienceBarManager.generateDefaultBarStateMap(); + + for(RootSkill key : mcMMO.p.getSkillRegister().getRootSkills()) { + map.putIfAbsent(key, barMapDefaults.get(key)); } } - private void validateExperienceValueMapEntries(@NotNull EnumMap map) { - for(PrimarySkillType key : PrimarySkillType.values()) { + private void validateExperienceValueMapEntries(@NotNull Map map) { + for(RootSkill key : mcMMO.p.getSkillRegister().getRootSkills()) { map.putIfAbsent(key, 0F); if(map.get(key) < 0F) { @@ -121,7 +128,7 @@ public class PersistentPlayerDataBuilder { } } - private void validateUniquePlayerDataMapEntries(@NotNull EnumMap map) { + private void validateUniquePlayerDataMapEntries(@NotNull Map map) { for(UniqueDataType key : UniqueDataType.values()) { map.putIfAbsent(key, 0); @@ -132,8 +139,8 @@ public class PersistentPlayerDataBuilder { } } - private void validateAbilityCooldownMapEntries(@NotNull EnumMap map) { - for(SuperAbilityType key : SuperAbilityType.values()) { + private void validateAbilityCooldownMapEntries(@NotNull Map map) { + for(SuperSkill key : mcMMO.p.getSkillRegister().getSuperSkills()) { map.putIfAbsent(key, 0); if(map.get(key) < 0) { @@ -143,8 +150,8 @@ public class PersistentPlayerDataBuilder { } } - private void validateSkillLevelMapEntries(@NotNull EnumMap map) { - for(PrimarySkillType key : PrimarySkillType.values()) { + private void validateSkillLevelMapEntries(@NotNull Map map) { + for(RootSkill key : mcMMO.p.getSkillRegister().getRootSkills()) { map.putIfAbsent(key, 0); if(map.get(key) < 0) { @@ -181,43 +188,34 @@ public class PersistentPlayerDataBuilder { return this; } - public @Nullable MobHealthBarType getMobHealthBarType() { - return mobHealthBarType; - } - - public @NotNull PersistentPlayerDataBuilder setMobHealthBarType(@NotNull MobHealthBarType mobHealthBarType) { - this.mobHealthBarType = mobHealthBarType; - return this; - } - - public @Nullable EnumMap getSkillLevelValues() { + public @Nullable Map getSkillLevelValues() { return skillLevelValues; } - public @NotNull PersistentPlayerDataBuilder setSkillLevelValues(@NotNull EnumMap skillLevelValues) { + public @NotNull PersistentPlayerDataBuilder setSkillLevelValues(@NotNull HashMap skillLevelValues) { this.skillLevelValues = skillLevelValues; return this; } - public @Nullable EnumMap getSkillExperienceValues() { + public @Nullable Map getSkillExperienceValues() { return skillExperienceValues; } - public @NotNull PersistentPlayerDataBuilder setSkillExperienceValues(@NotNull EnumMap skillExperienceValues) { + public @NotNull PersistentPlayerDataBuilder setSkillExperienceValues(@NotNull HashMap skillExperienceValues) { this.skillExperienceValues = skillExperienceValues; return this; } - public @Nullable EnumMap getAbilityDeactivationTimestamps() { + public @Nullable Map getAbilityDeactivationTimestamps() { return abilityDeactivationTimestamps; } - public @NotNull PersistentPlayerDataBuilder setAbilityDeactivationTimestamps(@NotNull EnumMap abilityDeactivationTimestamps) { + public @NotNull PersistentPlayerDataBuilder setAbilityDeactivationTimestamps(@NotNull HashMap abilityDeactivationTimestamps) { this.abilityDeactivationTimestamps = abilityDeactivationTimestamps; return this; } - public @Nullable EnumMap getUniquePlayerData() { + public @Nullable Map getUniquePlayerData() { return uniquePlayerData; } @@ -226,11 +224,11 @@ public class PersistentPlayerDataBuilder { return this; } - public @Nullable EnumMap getBarStateMap() { + public @Nullable Map getBarStateMap() { return barStateMap; } - public @NotNull PersistentPlayerDataBuilder setBarStateMap(@NotNull EnumMap barStateMap) { + public @NotNull PersistentPlayerDataBuilder setBarStateMap(@NotNull Map barStateMap) { this.barStateMap = barStateMap; return this; }