diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index 557d8fdc5..5c64ead85 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -44,6 +44,7 @@ import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig; import com.gmail.nossr50.config.treasure.FishingTreasureConfig; import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig; 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.mcMMO; import com.gmail.nossr50.skills.repair.repairables.Repairable; @@ -112,6 +113,8 @@ public final class ConfigManager { private SerializedConfigLoader configAdmin; private SerializedConfigLoader configMobs; + private HashMap skillConfigLoaders; + private SerializedConfigLoader configAcrobatics; private SerializedConfigLoader configAlchemy; private SerializedConfigLoader configArchery; @@ -223,20 +226,20 @@ public final class ConfigManager { configAdmin = new SerializedConfigLoader<>(ConfigAdmin.class, "admin.conf", "Admin", null); configMobs = new SerializedConfigLoader<>(ConfigMobs.class, "creatures.conf", "Creatures", null); - configAcrobatics = new SerializedConfigLoader<>(ConfigAcrobatics.class, "acrobatics.conf", "Acrobatics", null); - configSalvage = new SerializedConfigLoader<>(ConfigSalvage.class, "salvage.conf", "Salvage", null); - configArchery = new SerializedConfigLoader<>(ConfigArchery.class, "archery.conf", "Archery", null); - configAxes = new SerializedConfigLoader<>(ConfigAxes.class, "axes.conf", "Axes", null); - configExcavation = new SerializedConfigLoader<>(ConfigExcavation.class, "excavation.conf", "Excavation", null); - configFishing = new SerializedConfigLoader<>(ConfigFishing.class, "fishing.conf", "Fishing", null); - configHerbalism = new SerializedConfigLoader<>(ConfigHerbalism.class, "herbalism.conf", "Herbalism", null); - configMining = new SerializedConfigLoader<>(ConfigMining.class, "mining.conf", "Mining", null); - configRepair = new SerializedConfigLoader<>(ConfigRepair.class, "repair.conf", "Repair", null); - configSwords = new SerializedConfigLoader<>(ConfigSwords.class, "swords.conf", "Swords", null); - configTaming = new SerializedConfigLoader<>(ConfigTaming.class, "taming.conf", "Taming", null); - configUnarmed = new SerializedConfigLoader<>(ConfigUnarmed.class, "unarmed.conf", "Unarmed", null); - configWoodcutting = new SerializedConfigLoader<>(ConfigWoodcutting.class, "woodcutting.conf", "Woodcutting", null); - configSmelting = new SerializedConfigLoader<>(ConfigSmelting.class, "smelting.conf", "Smelting", null); + registerSkillConfig(PrimarySkillType.ACROBATICS, ConfigAcrobatics.class); + registerSkillConfig(PrimarySkillType.SALVAGE, ConfigSalvage.class); + registerSkillConfig(PrimarySkillType.ARCHERY, ConfigArchery.class); + registerSkillConfig(PrimarySkillType.AXES, ConfigAxes.class); + registerSkillConfig(PrimarySkillType.EXCAVATION, ConfigExcavation.class); + registerSkillConfig(PrimarySkillType.FISHING, ConfigFishing.class); + registerSkillConfig(PrimarySkillType.HERBALISM, ConfigHerbalism.class); + registerSkillConfig(PrimarySkillType.MINING, ConfigMining.class); + registerSkillConfig(PrimarySkillType.REPAIR, ConfigRepair.class); + registerSkillConfig(PrimarySkillType.SWORDS, ConfigSwords.class); + registerSkillConfig(PrimarySkillType.TAMING, ConfigTaming.class); + registerSkillConfig(PrimarySkillType.UNARMED, ConfigUnarmed.class); + registerSkillConfig(PrimarySkillType.WOODCUTTING, ConfigWoodcutting.class); + registerSkillConfig(PrimarySkillType.SMELTING, ConfigSmelting.class); //Serialized Data partyData = new SerializedConfigLoader<>(ConfigPartyData.class, "partydata.conf", "PartyData", null); @@ -280,6 +283,11 @@ public final class ConfigManager { initCollectionManagers(); } + private void registerSkillConfig(PrimarySkillType primarySkillType, Class clazz) + { + skillConfigLoaders.put(primarySkillType, SkillConfigFactory.initSkillConfig(primarySkillType, clazz)); + } + /** * Misc managers */ diff --git a/src/main/java/com/gmail/nossr50/config/SkillConfigFactory.java b/src/main/java/com/gmail/nossr50/config/SkillConfigFactory.java new file mode 100644 index 000000000..c392d5a77 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/SkillConfigFactory.java @@ -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); + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/repairmastery/RepairMasterySettings.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/repairmastery/RepairMasterySettings.java index d36bd824e..6d68af6f7 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/repairmastery/RepairMasterySettings.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/repairmastery/RepairMasterySettings.java @@ -1,5 +1,7 @@ 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.serialize.ConfigSerializable; diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/repairmastery/RepairMasteryStandard.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/repairmastery/RepairMasteryStandard.java index 9beb49af7..72add35af 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/repairmastery/RepairMasteryStandard.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/repairmastery/RepairMasteryStandard.java @@ -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-- NOTE: This setting is only valid for standard level scaling. --" + "\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\"." + "\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-- NOTE: This setting is only valid for standard level scaling. --" + "\nDefault value: "+MAX_BONUS_PERCENTAGE) - private double maxBonusPercentage = MAX_BONUS_PERCENTAGE; - - public int getMaxBonusLevel() { - return maxBonusLevel; - } - - public double getMaxBonusPercentage() { - return maxBonusPercentage; - } + public double maxBonusPercentage = MAX_BONUS_PERCENTAGE; } \ No newline at end of file