diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index c8abe2085..7b763ede2 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -45,6 +45,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.SubSkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager; @@ -92,6 +93,8 @@ public final class ConfigManager { /* MISC MANAGERS */ + SkillPropertiesManager skillPropertiesManager; + private ExperienceMapManager experienceMapManager; //private ModManager modManager; @@ -212,7 +215,6 @@ public final class ConfigManager { TypeSerializers.getDefaultSerializers().registerType(new TypeToken() {}, new CustomEnumValueSerializer()); TypeSerializers.getDefaultSerializers().registerType(new TypeToken() {}, new CustomEnumValueSerializer()); - mcMMO.p.getLogger().info("Deserializing configs..."); //TODO: Not sure about the order of MainConfig //Serialized Configs @@ -254,6 +256,9 @@ public final class ConfigManager { //Serialized Data partyData = new SerializedConfigLoader<>(ConfigPartyData.class, "partydata.conf", "PartyData", null); + skillPropertiesManager = new SkillPropertiesManager(); + skillPropertiesManager.fillRegisters(); + //Assign Maps partyItemWeights = Maps.newHashMap(configParty.getConfig().getPartyItemShare().getItemShareMap()); //Item Share Weights partyFeatureUnlocks = Maps.newHashMap(configParty.getConfig().getPartyXP().getPartyLevel().getPartyFeatureUnlockMap()); //Party Progression @@ -585,4 +590,14 @@ public final class ConfigManager { public ConfigSalvage getConfigSalvage() { return configSalvage.getConfig(); } + + public double getSkillMaxBonusLevel(SubSkillType subSkillType) + { + return skillPropertiesManager.getMaxBonusLevel(subSkillType); + } + + public double getSkillMaxChance(SubSkillType subSkillType) + { + return skillPropertiesManager.getMaxChance(subSkillType); + } } diff --git a/src/main/java/com/gmail/nossr50/config/SkillPropertiesManager.java b/src/main/java/com/gmail/nossr50/config/SkillPropertiesManager.java new file mode 100644 index 000000000..e1d254e33 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/SkillPropertiesManager.java @@ -0,0 +1,56 @@ +package com.gmail.nossr50.config; + +import com.gmail.nossr50.config.hocon.skills.ConfigSubSkillScalingRNG; +import com.gmail.nossr50.datatypes.skills.SubSkillType; +import com.gmail.nossr50.mcMMO; + +import java.util.HashMap; + +/** + * Hacky way to do this until I rewrite the skill system fully + */ +public class SkillPropertiesManager { + private HashMap maxChanceMap; + private HashMap maxBonusLevelMap; + private HashMap maxBonusPercentage; + + public SkillPropertiesManager() + { + maxChanceMap = new HashMap<>(); + maxBonusLevelMap = new HashMap<>(); + maxBonusPercentage = new HashMap<>(); + } + + public void registerRNG(SubSkillType subSkillType, ConfigSubSkillScalingRNG config) + { + maxChanceMap.put(subSkillType, config.getMaxChance()); + maxBonusLevelMap.put(subSkillType, config.getMaxBonusLevel()); + } + + public double getMaxChance(SubSkillType subSkillType) + { + return maxChanceMap.get(subSkillType); + } + + public double getMaxBonusLevel(SubSkillType subSkillType) + { + return maxBonusLevelMap.get(subSkillType); + } + + public void fillRegisters() + { + + fillRNGRegisters(); + } + + private void fillRNGRegisters() + { + //Acrobatics + registerRNG(SubSkillType.ACROBATICS_DODGE, mcMMO.getConfigManager().getConfigAcrobatics().getDodge().getRNGSettings()); + registerRNG(SubSkillType.ACROBATICS_DODGE, mcMMO.getConfigManager().getConfigAcrobatics().getRoll().getRNGSettings()); + + //Repair + registerRNG(SubSkillType.REPAIR_SUPER_REPAIR, mcMMO.getConfigManager().getConfigRepair().getSuperRepair().getSuperRepair()); + } + +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigSubSkillScalingRNG.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigSubSkillScalingRNG.java index 01dca3273..0f400c8dd 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigSubSkillScalingRNG.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigSubSkillScalingRNG.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.config.hocon.skills; +import com.gmail.nossr50.mcMMO; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @@ -30,4 +31,22 @@ public class ConfigSubSkillScalingRNG { public ConfigScalingSubSkillRetro getRetroSettings() { return retroSettings; } + + /** + * The max chance for the RNG component of a subskill from the user config + * @return the max chance for the RNG component of a subskill + */ + public double getMaxChance() { + if(mcMMO.getConfigManager().getConfigLeveling().getConfigSectionLevelingGeneral().getConfigSectionLevelScaling().isRetroModeEnabled()) + return getRetroSettings().getChanceAtMaxSkill(); + else + return getStandardSettings().getChanceAtMaxSkill(); + } + + public double getMaxBonusLevel() { + if(mcMMO.getConfigManager().getConfigLeveling().getConfigSectionLevelingGeneral().getConfigSectionLevelScaling().isRetroModeEnabled()) + return getRetroSettings().getMaxBonusLevel(); + else + return getStandardSettings().getMaxBonusLevel(); + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/dodge/ConfigDodge.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/dodge/ConfigDodge.java index adb607caf..a23933aa6 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/dodge/ConfigDodge.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/dodge/ConfigDodge.java @@ -19,7 +19,7 @@ public class ConfigDodge { @Setting(value = "RNG-Settings", comment = "Settings related to random chance elements for this Sub-Skill.") private ConfigSubSkillScalingRNG rng = new ConfigSubSkillScalingRNG(); - public ConfigSubSkillScalingRNG getRng() { + public ConfigSubSkillScalingRNG getRNGSettings() { return rng; } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepairArcaneForging.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepairArcaneForging.java index f8d9cdf6a..83f9f04b0 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepairArcaneForging.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepairArcaneForging.java @@ -8,34 +8,33 @@ import java.util.HashMap; @ConfigSerializable public class ConfigRepairArcaneForging { - public static final boolean LOSE_ENCHANTS_DEFAULT = true; - public static final boolean DOWNGRADES_ENABLED_DEFAULT = true; - public static final HashMap FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT; - public static final HashMap PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT; + public static final HashMap KEEP_ENCHANT_MAP; + public static final HashMap DOWNGRADE_MAP_DEFAULT; static { - FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT = new HashMap<>(); - PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT = new HashMap<>(); + KEEP_ENCHANT_MAP = new HashMap<>(); + KEEP_ENCHANT_MAP.put(1, 10.0D); + KEEP_ENCHANT_MAP.put(2, 20.0D); + KEEP_ENCHANT_MAP.put(3, 30.0D); + KEEP_ENCHANT_MAP.put(4, 40.0D); + KEEP_ENCHANT_MAP.put(5, 50.0D); + KEEP_ENCHANT_MAP.put(6, 55.0D); + KEEP_ENCHANT_MAP.put(7, 60.0D); + KEEP_ENCHANT_MAP.put(8, 65.0D); - FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(1, 2.5); - FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(2, 5.0); - FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(3, 7.5); - FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(4, 10.0); - FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(5, 12.5); - FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(6, 17.5); - FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(7, 25.0); - FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(8, 32.5); - - PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(1, 2.0); - PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(2, 2.5); - PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(3, 5.0); - PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(4, 7.5); - PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(5, 10.0); - PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(6, 12.5); - PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(7, 15.0); - PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(8, 17.5); + DOWNGRADE_MAP_DEFAULT = new HashMap<>(); + DOWNGRADE_MAP_DEFAULT.put(1, 75.0D); + DOWNGRADE_MAP_DEFAULT.put(2, 50.0D); + DOWNGRADE_MAP_DEFAULT.put(3, 40.0D); + DOWNGRADE_MAP_DEFAULT.put(4, 30.0D); + DOWNGRADE_MAP_DEFAULT.put(5, 25.0D); + DOWNGRADE_MAP_DEFAULT.put(6, 20.0D); + DOWNGRADE_MAP_DEFAULT.put(7, 15.0D); + DOWNGRADE_MAP_DEFAULT.put(8, 10.0D); } + public static final boolean LOSE_ENCHANTS_DEFAULT = true; + public static final boolean DOWNGRADES_ENABLED_DEFAULT = true; @Setting(value = "May-Lose-Enchants", comment = "With this on, players have a chance to have enchantments stripped from" + "\n their item when repairing." + @@ -48,13 +47,19 @@ public class ConfigRepairArcaneForging { "\nDefault value: "+DOWNGRADES_ENABLED_DEFAULT) private boolean downgradesEnabled = DOWNGRADES_ENABLED_DEFAULT; - @Setting(value = "Extract-Full-Enchant-Percentage-Chance-Per-Rank", comment = "The chance to extract the enchantment from the item during salvage without any downgrade." + - "\nIf this fails, a check to see if you can extract a downgraded version of the enchantment executes.") - private HashMap extractFullEnchantChance = FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT; + @Setting(value = "Downgrade-Chance-Per-Rank", comment = "Chance to downgrade enchants per rank in this Sub-Skill.") + private HashMap downgradeChanceMap = DOWNGRADE_MAP_DEFAULT; - @Setting(value = "Extract-Partial-Enchant-Percentage-Chance-Per-Rank", comment = "The chance to extract a downgraded enchantment from the item during salvage." + - "\nThis check happens if you fail to extract the full enchant from the item.") - private HashMap extractPartialEnchantChance = PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT; + @Setting(value = "Keep-Enchant-Chance-Per-Rank", comment = "Chance to keep the enchant without any downgrades per rank in this Sub-Skill") + private HashMap keepEnchantChanceMap = KEEP_ENCHANT_MAP; + + public HashMap getDowngradeChanceMap() { + return downgradeChanceMap; + } + + public HashMap getKeepEnchantChanceMap() { + return keepEnchantChanceMap; + } public boolean isMayLoseEnchants() { return mayLoseEnchants; @@ -64,11 +69,4 @@ public class ConfigRepairArcaneForging { return downgradesEnabled; } - public HashMap getExtractFullEnchantChance() { - return extractFullEnchantChance; - } - - public HashMap getExtractPartialEnchantChance() { - return extractPartialEnchantChance; - } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/salvage/ConfigArcaneSalvage.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/salvage/ConfigArcaneSalvage.java new file mode 100644 index 000000000..78ef272c9 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/salvage/ConfigArcaneSalvage.java @@ -0,0 +1,52 @@ +package com.gmail.nossr50.config.hocon.skills.salvage; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +import java.util.HashMap; + +@ConfigSerializable +public class ConfigArcaneSalvage { + public static final HashMap FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT; + public static final HashMap PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT; + + static { + FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT = new HashMap<>(); + PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT = new HashMap<>(); + + FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(1, 2.5); + FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(2, 5.0); + FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(3, 7.5); + FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(4, 10.0); + FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(5, 12.5); + FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(6, 17.5); + FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(7, 25.0); + FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(8, 32.5); + + PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(1, 2.0); + PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(2, 2.5); + PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(3, 5.0); + PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(4, 7.5); + PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(5, 10.0); + PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(6, 12.5); + PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(7, 15.0); + PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(8, 17.5); + } + + @Setting(value = "Extract-Full-Enchant-Percentage-Chance-Per-Rank", comment = "The chance to extract the enchantment from the item during salvage without any downgrade." + + "\nIf this fails, a check to see if you can extract a downgraded version of the enchantment executes.") + private HashMap extractFullEnchantChance = FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT; + + @Setting(value = "Extract-Partial-Enchant-Percentage-Chance-Per-Rank", comment = "The chance to extract a downgraded enchantment from the item during salvage." + + "\nThis check happens if you fail to extract the full enchant from the item.") + private HashMap extractPartialEnchantChance = PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT; + + + public HashMap getExtractFullEnchantChance() { + return extractFullEnchantChance; + } + + public HashMap getExtractPartialEnchantChance() { + return extractPartialEnchantChance; + } +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/util/random/RandomChanceSkill.java b/src/main/java/com/gmail/nossr50/util/random/RandomChanceSkill.java index 3502e84bc..c0972d24b 100644 --- a/src/main/java/com/gmail/nossr50/util/random/RandomChanceSkill.java +++ b/src/main/java/com/gmail/nossr50/util/random/RandomChanceSkill.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.util.random; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.entity.Player; @@ -35,7 +36,7 @@ public class RandomChanceSkill implements RandomChanceExecution { public RandomChanceSkill(Player player, SubSkillType subSkillType, boolean hasCap) { if(hasCap) - this.probabilityCap = AdvancedConfig.getInstance().getMaximumProbability(subSkillType); + this.probabilityCap = mcMMO.getConfigManager().getSkillMaxChance(subSkillType); else this.probabilityCap = RandomChanceUtil.LINEAR_CURVE_VAR; @@ -86,7 +87,7 @@ public class RandomChanceSkill implements RandomChanceExecution { * @return the maximum bonus from skill level for this skill */ public double getMaximumBonusLevelCap() { - return AdvancedConfig.getInstance().getMaxBonusLevel(subSkillType); + return mcMMO.getConfigManager().getSkillMaxBonusLevel(subSkillType); } /**