From 7b3f69aee685fa9461de73a11797c8680b077882 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 29 Apr 2019 22:37:46 -0700 Subject: [PATCH] Add config reload --- .../gmail/nossr50/config/ConfigManager.java | 27 ++++++----- .../util/experience/ExperienceMapManager.java | 45 +++++++++++++++---- 2 files changed, 50 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index 1448ecb3a..21813dbf9 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -335,22 +335,11 @@ public final class ConfigManager { */ private void initMiscManagers() { experienceMapManager = new ExperienceMapManager(); + //Set the global XP val + experienceMapManager.setGlobalXpMult(getConfigExperience().getGlobalXPMultiplier()); + experienceMapManager.setExcavationXpMap(getConfigExperience().getExcavationExperienceMap()); } - /** - * Initializes all of our Multi Config Containers - */ - /*private void initMultiConfigContainers() - { - //Repair - repairableMultiConfigContainer = new MultiConfigContainer<>("repair", CollectionClassType.REPAIR); - unloadables.add(repairableMultiConfigContainer); - - //Salvage - salvageableMultiConfigContainer = new MultiConfigContainer<>("salvage", CollectionClassType.SALVAGE); - unloadables.add(salvageableMultiConfigContainer); - }*/ - /** * Initializes any managers related to config collections */ @@ -431,6 +420,12 @@ public final class ConfigManager { } + public void reloadConfigs() { + mcMMO.p.getLogger().info("Reloading config values..."); + unloadAllConfigsAndRegisters(); //Unload Everything + loadConfigs(); //Load everything again + } + /* * GETTER BOILER PLATE */ @@ -670,4 +665,8 @@ public final class ConfigManager { public ConfigExperience getConfigExperience() { return configExperience.getConfig(); } + + public SkillPropertiesManager getSkillPropertiesManager() { + return skillPropertiesManager; + } } 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 4c7941ff5..37c4dfd9a 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceMapManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceMapManager.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.util.experience; import com.gmail.nossr50.config.Unload; +import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import org.bukkit.Material; @@ -10,10 +11,12 @@ import java.util.HashMap; * This class handles the XP for block break related XP */ public class ExperienceMapManager implements Unload { - private HashMap miningXpMap; - private HashMap herbalismXpMap; - private HashMap woodcuttingXpMap; - private HashMap excavationXpMap; + private HashMap> skillMaterialXPMap; + private HashMap miningXpMap; + private HashMap herbalismXpMap; + private HashMap woodcuttingXpMap; + private HashMap excavationXpMap; + private double globalXpMult; public ExperienceMapManager() { @@ -26,12 +29,38 @@ public class ExperienceMapManager implements Unload { mcMMO.getConfigManager().registerUnloadable(this); } + public void buildMaterialXPMap(HashMap xpMap, PrimarySkillType primarySkillType) + { + + } + /** * Change the gloabl xp multiplier, this is temporary and will not be serialiized - * @param newValue new global xp multiplier value + * @param newGlobalXpMult new global xp multiplier value */ - public void setGlobalXpMult(double newValue) { - globalXpMult = newValue; + public void setGlobalXpMult(double newGlobalXpMult) { + mcMMO.p.getLogger().info("Setting the global XP multiplier -> " + newGlobalXpMult); + globalXpMult = newGlobalXpMult; + } + + public void setMiningXpMap(HashMap miningXpMap) { + mcMMO.p.getLogger().info("Registering Mining XP Values..."); + this.miningXpMap = miningXpMap; + } + + public void setHerbalismXpMap(HashMap herbalismXpMap) { + mcMMO.p.getLogger().info("Registering Herbalism XP Values..."); + this.herbalismXpMap = herbalismXpMap; + } + + public void setWoodcuttingXpMap(HashMap woodcuttingXpMap) { + mcMMO.p.getLogger().info("Registering Woodcutting XP Values..."); + this.woodcuttingXpMap = woodcuttingXpMap; + } + + public void setExcavationXpMap(HashMap excavationXpMap) { + mcMMO.p.getLogger().info("Registering Excavation XP Values..."); + this.excavationXpMap = excavationXpMap; } /** @@ -60,7 +89,7 @@ public class ExperienceMapManager implements Unload { * @return true if the block has valid xp registers */ public boolean hasMiningXp(Material material) { - return miningXpMap.get(material) != null; + return miningXpMap.get(material.getKey().getKey()) != null; } /**