Init and register skill configs to a map to make traversing the root node for a specific skill given the same structure easier

This commit is contained in:
nossr50 2019-04-04 22:47:40 -07:00
parent 51291f7c49
commit 42a7673ad7
4 changed files with 42 additions and 24 deletions

View File

@ -44,6 +44,7 @@ import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig;
import com.gmail.nossr50.config.treasure.FishingTreasureConfig; import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig; import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig;
import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.skills.repair.repairables.Repairable;
@ -112,6 +113,8 @@ public final class ConfigManager {
private SerializedConfigLoader<ConfigAdmin> configAdmin; private SerializedConfigLoader<ConfigAdmin> configAdmin;
private SerializedConfigLoader<ConfigMobs> configMobs; private SerializedConfigLoader<ConfigMobs> configMobs;
private HashMap<PrimarySkillType, SerializedConfigLoader> skillConfigLoaders;
private SerializedConfigLoader<ConfigAcrobatics> configAcrobatics; private SerializedConfigLoader<ConfigAcrobatics> configAcrobatics;
private SerializedConfigLoader<ConfigAlchemy> configAlchemy; private SerializedConfigLoader<ConfigAlchemy> configAlchemy;
private SerializedConfigLoader<ConfigArchery> configArchery; private SerializedConfigLoader<ConfigArchery> configArchery;
@ -223,20 +226,20 @@ public final class ConfigManager {
configAdmin = new SerializedConfigLoader<>(ConfigAdmin.class, "admin.conf", "Admin", null); configAdmin = new SerializedConfigLoader<>(ConfigAdmin.class, "admin.conf", "Admin", null);
configMobs = new SerializedConfigLoader<>(ConfigMobs.class, "creatures.conf", "Creatures", null); configMobs = new SerializedConfigLoader<>(ConfigMobs.class, "creatures.conf", "Creatures", null);
configAcrobatics = new SerializedConfigLoader<>(ConfigAcrobatics.class, "acrobatics.conf", "Acrobatics", null); registerSkillConfig(PrimarySkillType.ACROBATICS, ConfigAcrobatics.class);
configSalvage = new SerializedConfigLoader<>(ConfigSalvage.class, "salvage.conf", "Salvage", null); registerSkillConfig(PrimarySkillType.SALVAGE, ConfigSalvage.class);
configArchery = new SerializedConfigLoader<>(ConfigArchery.class, "archery.conf", "Archery", null); registerSkillConfig(PrimarySkillType.ARCHERY, ConfigArchery.class);
configAxes = new SerializedConfigLoader<>(ConfigAxes.class, "axes.conf", "Axes", null); registerSkillConfig(PrimarySkillType.AXES, ConfigAxes.class);
configExcavation = new SerializedConfigLoader<>(ConfigExcavation.class, "excavation.conf", "Excavation", null); registerSkillConfig(PrimarySkillType.EXCAVATION, ConfigExcavation.class);
configFishing = new SerializedConfigLoader<>(ConfigFishing.class, "fishing.conf", "Fishing", null); registerSkillConfig(PrimarySkillType.FISHING, ConfigFishing.class);
configHerbalism = new SerializedConfigLoader<>(ConfigHerbalism.class, "herbalism.conf", "Herbalism", null); registerSkillConfig(PrimarySkillType.HERBALISM, ConfigHerbalism.class);
configMining = new SerializedConfigLoader<>(ConfigMining.class, "mining.conf", "Mining", null); registerSkillConfig(PrimarySkillType.MINING, ConfigMining.class);
configRepair = new SerializedConfigLoader<>(ConfigRepair.class, "repair.conf", "Repair", null); registerSkillConfig(PrimarySkillType.REPAIR, ConfigRepair.class);
configSwords = new SerializedConfigLoader<>(ConfigSwords.class, "swords.conf", "Swords", null); registerSkillConfig(PrimarySkillType.SWORDS, ConfigSwords.class);
configTaming = new SerializedConfigLoader<>(ConfigTaming.class, "taming.conf", "Taming", null); registerSkillConfig(PrimarySkillType.TAMING, ConfigTaming.class);
configUnarmed = new SerializedConfigLoader<>(ConfigUnarmed.class, "unarmed.conf", "Unarmed", null); registerSkillConfig(PrimarySkillType.UNARMED, ConfigUnarmed.class);
configWoodcutting = new SerializedConfigLoader<>(ConfigWoodcutting.class, "woodcutting.conf", "Woodcutting", null); registerSkillConfig(PrimarySkillType.WOODCUTTING, ConfigWoodcutting.class);
configSmelting = new SerializedConfigLoader<>(ConfigSmelting.class, "smelting.conf", "Smelting", null); registerSkillConfig(PrimarySkillType.SMELTING, ConfigSmelting.class);
//Serialized Data //Serialized Data
partyData = new SerializedConfigLoader<>(ConfigPartyData.class, "partydata.conf", "PartyData", null); partyData = new SerializedConfigLoader<>(ConfigPartyData.class, "partydata.conf", "PartyData", null);
@ -280,6 +283,11 @@ public final class ConfigManager {
initCollectionManagers(); initCollectionManagers();
} }
private void registerSkillConfig(PrimarySkillType primarySkillType, Class clazz)
{
skillConfigLoaders.put(primarySkillType, SkillConfigFactory.initSkillConfig(primarySkillType, clazz));
}
/** /**
* Misc managers * Misc managers
*/ */

View File

@ -0,0 +1,16 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.config.hocon.SerializedConfigLoader;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.StringUtils;
public class SkillConfigFactory {
protected static SerializedConfigLoader initSkillConfig(PrimarySkillType primarySkillType, Class<?> clazz)
{
return new SerializedConfigLoader<>(clazz,
primarySkillType.toString().toLowerCase() + ".conf",
StringUtils.getCapitalized(primarySkillType.toString()),
null);
}
}

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.config.hocon.skills.repair.repairmastery; package com.gmail.nossr50.config.hocon.skills.repair.repairmastery;
import com.gmail.nossr50.annotation.SkillProperty;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;

View File

@ -17,7 +17,7 @@ public class RepairMasteryStandard {
"\n a player should have based on how far they are from the max bonus level value, and the other parameters used for the scaling of the sub-skill." + "\n a player should have based on how far they are from the max bonus level value, and the other parameters used for the scaling of the sub-skill." +
"\n-- NOTE: This setting is only valid for standard level scaling. --" + "\n-- NOTE: This setting is only valid for standard level scaling. --" +
"\nDefault value: "+MAX_BONUS_LEVEL_DEFAULT) "\nDefault value: "+MAX_BONUS_LEVEL_DEFAULT)
private int maxBonusLevel = MAX_BONUS_LEVEL_DEFAULT; public int maxBonusLevel = MAX_BONUS_LEVEL_DEFAULT;
@Setting(value = "Max-Bonus-Percentage", comment = "This is the maximum benefit for additional repair amount from this skill when the player reaches \"Max-Bonus-Level\"." + @Setting(value = "Max-Bonus-Percentage", comment = "This is the maximum benefit for additional repair amount from this skill when the player reaches \"Max-Bonus-Level\"." +
"\nRepair Mastery's bonus to repair is dynamically adjusted based on the players level difference from the \"Max-Bonus-Level\", you can think of it as a curve where reaching \"Max-Bonus-Level\" is the peak." + "\nRepair Mastery's bonus to repair is dynamically adjusted based on the players level difference from the \"Max-Bonus-Level\", you can think of it as a curve where reaching \"Max-Bonus-Level\" is the peak." +
@ -25,13 +25,5 @@ public class RepairMasteryStandard {
"\n and the player was level " + PLAYER_LEVEL_FIFTY_PERCENT_EXAMPLE + " for this skill, that would give the player " + BONUS_PERCENTAGE_EXAMPLE + "% added to the repair amount on the item before other bonuses." + "\n and the player was level " + PLAYER_LEVEL_FIFTY_PERCENT_EXAMPLE + " for this skill, that would give the player " + BONUS_PERCENTAGE_EXAMPLE + "% added to the repair amount on the item before other bonuses." +
"\n-- NOTE: This setting is only valid for standard level scaling. --" + "\n-- NOTE: This setting is only valid for standard level scaling. --" +
"\nDefault value: "+MAX_BONUS_PERCENTAGE) "\nDefault value: "+MAX_BONUS_PERCENTAGE)
private double maxBonusPercentage = MAX_BONUS_PERCENTAGE; public double maxBonusPercentage = MAX_BONUS_PERCENTAGE;
public int getMaxBonusLevel() {
return maxBonusLevel;
}
public double getMaxBonusPercentage() {
return maxBonusPercentage;
}
} }