From e5441f2a96bc23f19ffd1d17fc227b506a1bb7ff Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 30 Apr 2019 01:39:06 -0700 Subject: [PATCH] Taming XP values are now converted to an enum mpa and managed by ExperienceMapManager --- .../util/experience/ExperienceMapManager.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceMapManager.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceMapManager.java index 13d24c1ff..fab258969 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceMapManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceMapManager.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.config.Unload; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import org.bukkit.Material; +import org.bukkit.entity.EntityType; import java.util.HashMap; @@ -16,6 +17,7 @@ public class ExperienceMapManager implements Unload { private HashMap herbalismFullyQualifiedBlockXpMap; private HashMap woodcuttingFullyQualifiedBlockXpMap; private HashMap excavationFullyQualifiedBlockXpMap; + private HashMap tamingExperienceMap; private double globalXpMult; @@ -24,6 +26,7 @@ public class ExperienceMapManager implements Unload { herbalismFullyQualifiedBlockXpMap = new HashMap<>(); woodcuttingFullyQualifiedBlockXpMap = new HashMap<>(); excavationFullyQualifiedBlockXpMap = new HashMap<>(); + tamingExperienceMap = new HashMap<>(); //Register with unloader mcMMO.getConfigManager().registerUnloadable(this); @@ -43,6 +46,34 @@ public class ExperienceMapManager implements Unload { buildHerbalismBlockXPMap(); buildWoodcuttingBlockXPMap(); buildExcavationBlockXPMap(); + buildTamingXPMap(); + } + + /** + * Taming entries in the config are case insensitive, but for faster lookups we convert them to ENUMs + */ + private void buildTamingXPMap() + { + mcMMO.p.getLogger().info("Building Taming XP list..."); + HashMap userTamingConfigMap = mcMMO.getConfigManager().getConfigExperience().getTamingExperienceMap(); + + for(String s : userTamingConfigMap.keySet()) + { + boolean matchFound = false; + for(EntityType entityType : EntityType.values()) + { + if(entityType.toString().equalsIgnoreCase(s)) + { + //Match! + matchFound = true; + tamingExperienceMap.put(entityType, userTamingConfigMap.get(s)); + } + } + if(!matchFound) + { + mcMMO.p.getLogger().info("Unable to find entity with matching name - "+s); + } + } } private void fillBlockXPMap(HashMap userConfigMap, HashMap fullyQualifiedBlockXPMap)