Repair Config Pt 3

This commit is contained in:
nossr50 2019-03-21 20:16:16 -07:00
parent ff986ec97d
commit ef6bec4ffc
7 changed files with 181 additions and 40 deletions

View File

@ -45,6 +45,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.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;
import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager; import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager;
@ -92,6 +93,8 @@ public final class ConfigManager {
/* MISC MANAGERS */ /* MISC MANAGERS */
SkillPropertiesManager skillPropertiesManager;
private ExperienceMapManager experienceMapManager; private ExperienceMapManager experienceMapManager;
//private ModManager modManager; //private ModManager modManager;
@ -212,7 +215,6 @@ public final class ConfigManager {
TypeSerializers.getDefaultSerializers().registerType(new TypeToken<Material>() {}, new CustomEnumValueSerializer()); TypeSerializers.getDefaultSerializers().registerType(new TypeToken<Material>() {}, new CustomEnumValueSerializer());
TypeSerializers.getDefaultSerializers().registerType(new TypeToken<PartyFeature>() {}, new CustomEnumValueSerializer()); TypeSerializers.getDefaultSerializers().registerType(new TypeToken<PartyFeature>() {}, new CustomEnumValueSerializer());
mcMMO.p.getLogger().info("Deserializing configs..."); mcMMO.p.getLogger().info("Deserializing configs...");
//TODO: Not sure about the order of MainConfig //TODO: Not sure about the order of MainConfig
//Serialized Configs //Serialized Configs
@ -254,6 +256,9 @@ public final class ConfigManager {
//Serialized Data //Serialized Data
partyData = new SerializedConfigLoader<>(ConfigPartyData.class, "partydata.conf", "PartyData", null); partyData = new SerializedConfigLoader<>(ConfigPartyData.class, "partydata.conf", "PartyData", null);
skillPropertiesManager = new SkillPropertiesManager();
skillPropertiesManager.fillRegisters();
//Assign Maps //Assign Maps
partyItemWeights = Maps.newHashMap(configParty.getConfig().getPartyItemShare().getItemShareMap()); //Item Share Weights partyItemWeights = Maps.newHashMap(configParty.getConfig().getPartyItemShare().getItemShareMap()); //Item Share Weights
partyFeatureUnlocks = Maps.newHashMap(configParty.getConfig().getPartyXP().getPartyLevel().getPartyFeatureUnlockMap()); //Party Progression partyFeatureUnlocks = Maps.newHashMap(configParty.getConfig().getPartyXP().getPartyLevel().getPartyFeatureUnlockMap()); //Party Progression
@ -585,4 +590,14 @@ public final class ConfigManager {
public ConfigSalvage getConfigSalvage() { public ConfigSalvage getConfigSalvage() {
return configSalvage.getConfig(); return configSalvage.getConfig();
} }
public double getSkillMaxBonusLevel(SubSkillType subSkillType)
{
return skillPropertiesManager.getMaxBonusLevel(subSkillType);
}
public double getSkillMaxChance(SubSkillType subSkillType)
{
return skillPropertiesManager.getMaxChance(subSkillType);
}
} }

View File

@ -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<SubSkillType, Double> maxChanceMap;
private HashMap<SubSkillType, Double> maxBonusLevelMap;
private HashMap<SubSkillType, Double> 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());
}
}

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.config.hocon.skills; package com.gmail.nossr50.config.hocon.skills;
import com.gmail.nossr50.mcMMO;
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;
@ -30,4 +31,22 @@ public class ConfigSubSkillScalingRNG {
public ConfigScalingSubSkillRetro getRetroSettings() { public ConfigScalingSubSkillRetro getRetroSettings() {
return retroSettings; 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();
}
} }

View File

@ -19,7 +19,7 @@ public class ConfigDodge {
@Setting(value = "RNG-Settings", comment = "Settings related to random chance elements for this Sub-Skill.") @Setting(value = "RNG-Settings", comment = "Settings related to random chance elements for this Sub-Skill.")
private ConfigSubSkillScalingRNG rng = new ConfigSubSkillScalingRNG(); private ConfigSubSkillScalingRNG rng = new ConfigSubSkillScalingRNG();
public ConfigSubSkillScalingRNG getRng() { public ConfigSubSkillScalingRNG getRNGSettings() {
return rng; return rng;
} }

View File

@ -8,34 +8,33 @@ import java.util.HashMap;
@ConfigSerializable @ConfigSerializable
public class ConfigRepairArcaneForging { public class ConfigRepairArcaneForging {
public static final boolean LOSE_ENCHANTS_DEFAULT = true; public static final HashMap<Integer, Double> KEEP_ENCHANT_MAP;
public static final boolean DOWNGRADES_ENABLED_DEFAULT = true; public static final HashMap<Integer, Double> DOWNGRADE_MAP_DEFAULT;
public static final HashMap<Integer, Double> FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT;
public static final HashMap<Integer, Double> PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT;
static { static {
FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT = new HashMap<>(); KEEP_ENCHANT_MAP = new HashMap<>();
PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT = 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); DOWNGRADE_MAP_DEFAULT = new HashMap<>();
FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(2, 5.0); DOWNGRADE_MAP_DEFAULT.put(1, 75.0D);
FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(3, 7.5); DOWNGRADE_MAP_DEFAULT.put(2, 50.0D);
FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(4, 10.0); DOWNGRADE_MAP_DEFAULT.put(3, 40.0D);
FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(5, 12.5); DOWNGRADE_MAP_DEFAULT.put(4, 30.0D);
FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(6, 17.5); DOWNGRADE_MAP_DEFAULT.put(5, 25.0D);
FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(7, 25.0); DOWNGRADE_MAP_DEFAULT.put(6, 20.0D);
FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT.put(8, 32.5); DOWNGRADE_MAP_DEFAULT.put(7, 15.0D);
DOWNGRADE_MAP_DEFAULT.put(8, 10.0D);
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);
} }
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" + @Setting(value = "May-Lose-Enchants", comment = "With this on, players have a chance to have enchantments stripped from" +
"\n their item when repairing." + "\n their item when repairing." +
@ -48,13 +47,19 @@ public class ConfigRepairArcaneForging {
"\nDefault value: "+DOWNGRADES_ENABLED_DEFAULT) "\nDefault value: "+DOWNGRADES_ENABLED_DEFAULT)
private boolean downgradesEnabled = 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." + @Setting(value = "Downgrade-Chance-Per-Rank", comment = "Chance to downgrade enchants per rank in this Sub-Skill.")
"\nIf this fails, a check to see if you can extract a downgraded version of the enchantment executes.") private HashMap<Integer, Double> downgradeChanceMap = DOWNGRADE_MAP_DEFAULT;
private HashMap<Integer, Double> 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." + @Setting(value = "Keep-Enchant-Chance-Per-Rank", comment = "Chance to keep the enchant without any downgrades per rank in this Sub-Skill")
"\nThis check happens if you fail to extract the full enchant from the item.") private HashMap<Integer, Double> keepEnchantChanceMap = KEEP_ENCHANT_MAP;
private HashMap<Integer, Double> extractPartialEnchantChance = PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT;
public HashMap<Integer, Double> getDowngradeChanceMap() {
return downgradeChanceMap;
}
public HashMap<Integer, Double> getKeepEnchantChanceMap() {
return keepEnchantChanceMap;
}
public boolean isMayLoseEnchants() { public boolean isMayLoseEnchants() {
return mayLoseEnchants; return mayLoseEnchants;
@ -64,11 +69,4 @@ public class ConfigRepairArcaneForging {
return downgradesEnabled; return downgradesEnabled;
} }
public HashMap<Integer, Double> getExtractFullEnchantChance() {
return extractFullEnchantChance;
}
public HashMap<Integer, Double> getExtractPartialEnchantChance() {
return extractPartialEnchantChance;
}
} }

View File

@ -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<Integer, Double> FULL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT;
public static final HashMap<Integer, Double> 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<Integer, Double> 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<Integer, Double> extractPartialEnchantChance = PARTIAL_ENCHANT_INTEGER_DOUBLE_HASH_MAP_DEFAULT;
public HashMap<Integer, Double> getExtractFullEnchantChance() {
return extractFullEnchantChance;
}
public HashMap<Integer, Double> getExtractPartialEnchantChance() {
return extractPartialEnchantChance;
}
}

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.util.random;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; 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.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -35,7 +36,7 @@ public class RandomChanceSkill implements RandomChanceExecution {
public RandomChanceSkill(Player player, SubSkillType subSkillType, boolean hasCap) public RandomChanceSkill(Player player, SubSkillType subSkillType, boolean hasCap)
{ {
if(hasCap) if(hasCap)
this.probabilityCap = AdvancedConfig.getInstance().getMaximumProbability(subSkillType); this.probabilityCap = mcMMO.getConfigManager().getSkillMaxChance(subSkillType);
else else
this.probabilityCap = RandomChanceUtil.LINEAR_CURVE_VAR; 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 * @return the maximum bonus from skill level for this skill
*/ */
public double getMaximumBonusLevelCap() { public double getMaximumBonusLevelCap() {
return AdvancedConfig.getInstance().getMaxBonusLevel(subSkillType); return mcMMO.getConfigManager().getSkillMaxBonusLevel(subSkillType);
} }
/** /**