Add config reload

This commit is contained in:
nossr50 2019-04-29 22:37:46 -07:00
parent 6e173c0d4e
commit 7b3f69aee6
2 changed files with 50 additions and 22 deletions

View File

@ -335,22 +335,11 @@ public final class ConfigManager {
*/ */
private void initMiscManagers() { private void initMiscManagers() {
experienceMapManager = new ExperienceMapManager(); 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 * 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 * GETTER BOILER PLATE
*/ */
@ -670,4 +665,8 @@ public final class ConfigManager {
public ConfigExperience getConfigExperience() { public ConfigExperience getConfigExperience() {
return configExperience.getConfig(); return configExperience.getConfig();
} }
public SkillPropertiesManager getSkillPropertiesManager() {
return skillPropertiesManager;
}
} }

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.util.experience; package com.gmail.nossr50.util.experience;
import com.gmail.nossr50.config.Unload; import com.gmail.nossr50.config.Unload;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import org.bukkit.Material; import org.bukkit.Material;
@ -10,10 +11,12 @@ import java.util.HashMap;
* This class handles the XP for block break related XP * This class handles the XP for block break related XP
*/ */
public class ExperienceMapManager implements Unload { public class ExperienceMapManager implements Unload {
private HashMap<Material, Integer> miningXpMap; private HashMap<PrimarySkillType, HashMap<Material, String>> skillMaterialXPMap;
private HashMap<Material, Integer> herbalismXpMap; private HashMap<String, Integer> miningXpMap;
private HashMap<Material, Integer> woodcuttingXpMap; private HashMap<String, Integer> herbalismXpMap;
private HashMap<Material, Integer> excavationXpMap; private HashMap<String, Integer> woodcuttingXpMap;
private HashMap<String, Integer> excavationXpMap;
private double globalXpMult; private double globalXpMult;
public ExperienceMapManager() { public ExperienceMapManager() {
@ -26,12 +29,38 @@ public class ExperienceMapManager implements Unload {
mcMMO.getConfigManager().registerUnloadable(this); mcMMO.getConfigManager().registerUnloadable(this);
} }
public void buildMaterialXPMap(HashMap<String, Integer> xpMap, PrimarySkillType primarySkillType)
{
}
/** /**
* Change the gloabl xp multiplier, this is temporary and will not be serialiized * 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) { public void setGlobalXpMult(double newGlobalXpMult) {
globalXpMult = newValue; mcMMO.p.getLogger().info("Setting the global XP multiplier -> " + newGlobalXpMult);
globalXpMult = newGlobalXpMult;
}
public void setMiningXpMap(HashMap<String, Integer> miningXpMap) {
mcMMO.p.getLogger().info("Registering Mining XP Values...");
this.miningXpMap = miningXpMap;
}
public void setHerbalismXpMap(HashMap<String, Integer> herbalismXpMap) {
mcMMO.p.getLogger().info("Registering Herbalism XP Values...");
this.herbalismXpMap = herbalismXpMap;
}
public void setWoodcuttingXpMap(HashMap<String, Integer> woodcuttingXpMap) {
mcMMO.p.getLogger().info("Registering Woodcutting XP Values...");
this.woodcuttingXpMap = woodcuttingXpMap;
}
public void setExcavationXpMap(HashMap<String, Integer> 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 * @return true if the block has valid xp registers
*/ */
public boolean hasMiningXp(Material material) { public boolean hasMiningXp(Material material) {
return miningXpMap.get(material) != null; return miningXpMap.get(material.getKey().getKey()) != null;
} }
/** /**