Config validation rewrite part 1

This commit is contained in:
nossr50 2022-01-30 15:31:52 -08:00
parent 86e7bfbf89
commit 16e90da8fd
16 changed files with 293 additions and 263 deletions

View File

@ -14,7 +14,6 @@ public class AdvancedConfig extends BukkitConfig {
public AdvancedConfig(File dataFolder) {
super("advanced.yml", dataFolder);
validate();
}
@Override
@ -23,125 +22,125 @@ public class AdvancedConfig extends BukkitConfig {
}
@Override
protected boolean validateKeys() {
// Validate all the settings!
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
List<String> reason = new ArrayList<>();
/* GENERAL */
if (getAbilityLength() < 1) {
reason.add("Skills.General.Ability.Length.<mode>.IncreaseLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.General.Ability.Length.<mode>.IncreaseLevel should be at least 1!");
}
if (getEnchantBuff() < 1) {
reason.add("Skills.General.Ability.EnchantBuff should be at least 1!");
mcMMO.p.getLogger().warning("Skills.General.Ability.EnchantBuff should be at least 1!");
}
/* ACROBATICS */
if (getMaximumProbability(SubSkillType.ACROBATICS_DODGE) < 1) {
reason.add("Skills.Acrobatics.Dodge.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Acrobatics.Dodge.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.ACROBATICS_DODGE) < 1) {
reason.add("Skills.Acrobatics.Dodge.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Acrobatics.Dodge.MaxBonusLevel should be at least 1!");
}
if (getDodgeDamageModifier() <= 1) {
reason.add("Skills.Acrobatics.Dodge.DamageModifier should be greater than 1!");
mcMMO.p.getLogger().warning("Skills.Acrobatics.Dodge.DamageModifier should be greater than 1!");
}
if (getMaximumProbability(SubSkillType.ACROBATICS_ROLL) < 1) {
reason.add("Skills.Acrobatics.Roll.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Acrobatics.Roll.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL) < 1) {
reason.add("Skills.Acrobatics.Roll.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Acrobatics.Roll.MaxBonusLevel should be at least 1!");
}
if (getRollDamageThreshold() < 0) {
reason.add("Skills.Acrobatics.Roll.DamageThreshold should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Acrobatics.Roll.DamageThreshold should be at least 0!");
}
if (getGracefulRollDamageThreshold() < 0) {
reason.add("Skills.Acrobatics.GracefulRoll.DamageThreshold should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Acrobatics.GracefulRoll.DamageThreshold should be at least 0!");
}
if (getCatalysisMinSpeed() <= 0) {
reason.add("Skills.Alchemy.Catalysis.MinSpeed must be greater than 0!");
mcMMO.p.getLogger().warning("Skills.Alchemy.Catalysis.MinSpeed must be greater than 0!");
}
if (getCatalysisMaxSpeed() < getCatalysisMinSpeed()) {
reason.add("Skills.Alchemy.Catalysis.MaxSpeed should be at least Skills.Alchemy.Catalysis.MinSpeed!");
mcMMO.p.getLogger().warning("Skills.Alchemy.Catalysis.MaxSpeed should be at least Skills.Alchemy.Catalysis.MinSpeed!");
}
/* ARCHERY */
if (getSkillShotRankDamageMultiplier() <= 0) {
reason.add("Skills.Archery.SkillShot.RankDamageMultiplier should be greater than 0!");
mcMMO.p.getLogger().warning("Skills.Archery.SkillShot.RankDamageMultiplier should be greater than 0!");
}
if (getMaximumProbability(SubSkillType.ARCHERY_DAZE) < 1) {
reason.add("Skills.Archery.Daze.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Archery.Daze.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.ARCHERY_DAZE) < 1) {
reason.add("Skills.Archery.Daze.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Archery.Daze.MaxBonusLevel should be at least 1!");
}
if (getDazeBonusDamage() < 0) {
reason.add("Skills.Archery.Daze.BonusDamage should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Archery.Daze.BonusDamage should be at least 0!");
}
if (getMaximumProbability(SubSkillType.ARCHERY_ARROW_RETRIEVAL) < 1) {
reason.add("Skills.Archery.Retrieve.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Archery.Retrieve.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.ARCHERY_ARROW_RETRIEVAL) < 1) {
reason.add("Skills.Archery.Retrieve.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Archery.Retrieve.MaxBonusLevel should be at least 1!");
}
if (getForceMultiplier() < 0) {
reason.add("Skills.Archery.ForceMultiplier should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Archery.ForceMultiplier should be at least 0!");
}
/* AXES */
if (getAxeMasteryRankDamageMultiplier() < 0) {
reason.add("Skills.Axes.AxeMastery.RankDamageMultiplier should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Axes.AxeMastery.RankDamageMultiplier should be at least 0!");
}
if (getMaximumProbability(SubSkillType.AXES_CRITICAL_STRIKES) < 1) {
reason.add("Skills.Axes.CriticalHit.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Axes.CriticalHit.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.AXES_CRITICAL_STRIKES) < 1) {
reason.add("Skills.Axes.CriticalHit.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Axes.CriticalHit.MaxBonusLevel should be at least 1!");
}
if (getCriticalStrikesPVPModifier() < 1) {
reason.add("Skills.Axes.CriticalStrikes.PVP_Modifier should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Axes.CriticalStrikes.PVP_Modifier should be at least 1!");
}
if (getCriticalStrikesPVPModifier() < 1) {
reason.add("Skills.Axes.CriticalStrikes.PVE_Modifier should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Axes.CriticalStrikes.PVE_Modifier should be at least 1!");
}
if (getGreaterImpactChance() < 1) {
reason.add("Skills.Axes.GreaterImpact.Chance should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Axes.GreaterImpact.Chance should be at least 1!");
}
if (getGreaterImpactModifier() < 1) {
reason.add("Skills.Axes.GreaterImpact.KnockbackModifier should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Axes.GreaterImpact.KnockbackModifier should be at least 1!");
}
if (getGreaterImpactBonusDamage() < 1) {
reason.add("Skills.Axes.GreaterImpact.BonusDamage should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Axes.GreaterImpact.BonusDamage should be at least 1!");
}
if (getImpactChance() < 1) {
reason.add("Skills.Axes.ArmorImpact.Chance should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Axes.ArmorImpact.Chance should be at least 1!");
}
if (getSkullSplitterModifier() < 1) {
reason.add("Skills.Axes.SkullSplitter.DamageModifier should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Axes.SkullSplitter.DamageModifier should be at least 1!");
}
/* FISHING */
@ -149,262 +148,261 @@ public class AdvancedConfig extends BukkitConfig {
for (int rank : fishingTierList) {
if (getFishingTierLevel(tier) < 0) {
reason.add("Skills.Fishing.Rank_Levels.Rank_" + rank + " should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Fishing.Rank_Levels.Rank_" + rank + " should be at least 0!");
}
if (getShakeChance(tier) < 0) {
reason.add("Skills.Fishing.Shake_Chance.Rank_" + rank + " should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Fishing.Shake_Chance.Rank_" + rank + " should be at least 0!");
}
if (getFishingVanillaXPModifier(tier) < 0) {
reason.add("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank + " should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank + " should be at least 0!");
}
if (tier != Fishing.Tier.EIGHT) {
Fishing.Tier nextTier = fishingTierList.get(fishingTierList.indexOf(tier) - 1);
if (getFishingTierLevel(tier) > getFishingTierLevel(nextTier)) {
reason.add("Skills.Fishing.Rank_Levels.Rank_" + rank + " should be less than or equal to Skills.Fishing.Rank_Levels.Rank_" + nextrank + "!");
mcMMO.p.getLogger().warning("Skills.Fishing.Rank_Levels.Rank_" + rank + " should be less than or equal to Skills.Fishing.Rank_Levels.Rank_" + nextrank + "!");
}
if (getShakeChance(tier) > getShakeChance(nextTier)) {
reason.add("Skills.Fishing.Shake_Chance.Rank_" + rank + " should be less than or equal to Skills.Fishing.Shake_Chance.Rank_" + nextrank + "!");
mcMMO.p.getLogger().warning("Skills.Fishing.Shake_Chance.Rank_" + rank + " should be less than or equal to Skills.Fishing.Shake_Chance.Rank_" + nextrank + "!");
}
if (getFishingVanillaXPModifier(tier) > getFishingVanillaXPModifier(nextTier)) {
reason.add("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank + " should be less than or equal to Skills.Fishing.VanillaXPMultiplier.Rank_" + nextrank + "!");
mcMMO.p.getLogger().warning("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank + " should be less than or equal to Skills.Fishing.VanillaXPMultiplier.Rank_" + nextrank + "!");
}
}
}*/
if (getFishermanDietRankChange() < 1) {
reason.add("Skills.Fishing.FishermansDiet.RankChange should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Fishing.FishermansDiet.RankChange should be at least 1!");
}
/*if (getIceFishingUnlockLevel() < 0) {
reason.add("Skills.Fishing.IceFishing.UnlockLevel should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Fishing.IceFishing.UnlockLevel should be at least 0!");
}
if (getMasterAnglerUnlockLevel() < 0) {
reason.add("Skills.Fishing.MasterAngler.UnlockLevel should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Fishing.MasterAngler.UnlockLevel should be at least 0!");
}*/
if (getMasterAnglerBoatModifier() < 1) {
reason.add("Skills.Fishing.MasterAngler.BoatModifier should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Fishing.MasterAngler.BoatModifier should be at least 1!");
}
if (getMasterAnglerBiomeModifier() < 1) {
reason.add("Skills.Fishing.MasterAngler.BiomeModifier should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Fishing.MasterAngler.BiomeModifier should be at least 1!");
}
/* HERBALISM */
if (getFarmerDietRankChange() < 1) {
reason.add("Skills.Herbalism.FarmersDiet.RankChange should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Herbalism.FarmersDiet.RankChange should be at least 1!");
}
if (getGreenThumbStageChange() < 1) {
reason.add("Skills.Herbalism.GreenThumb.StageChange should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Herbalism.GreenThumb.StageChange should be at least 1!");
}
if (getMaximumProbability(SubSkillType.HERBALISM_GREEN_THUMB) < 1) {
reason.add("Skills.Herbalism.GreenThumb.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Herbalism.GreenThumb.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.HERBALISM_GREEN_THUMB) < 1) {
reason.add("Skills.Herbalism.GreenThumb.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Herbalism.GreenThumb.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.HERBALISM_DOUBLE_DROPS) < 1) {
reason.add("Skills.Herbalism.DoubleDrops.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Herbalism.DoubleDrops.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.HERBALISM_DOUBLE_DROPS) < 1) {
reason.add("Skills.Herbalism.DoubleDrops.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Herbalism.DoubleDrops.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.HERBALISM_HYLIAN_LUCK) < 1) {
reason.add("Skills.Herbalism.HylianLuck.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Herbalism.HylianLuck.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.HERBALISM_HYLIAN_LUCK) < 1) {
reason.add("Skills.Herbalism.HylianLuck.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Herbalism.HylianLuck.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.HERBALISM_SHROOM_THUMB) < 1) {
reason.add("Skills.Herbalism.ShroomThumb.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Herbalism.ShroomThumb.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.HERBALISM_SHROOM_THUMB) < 1) {
reason.add("Skills.Herbalism.ShroomThumb.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Herbalism.ShroomThumb.MaxBonusLevel should be at least 1!");
}
/* MINING */
if (getMaximumProbability(SubSkillType.MINING_DOUBLE_DROPS) < 1) {
reason.add("Skills.Mining.DoubleDrops.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Mining.DoubleDrops.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.MINING_DOUBLE_DROPS) < 1) {
reason.add("Skills.Mining.DoubleDrops.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Mining.DoubleDrops.MaxBonusLevel should be at least 1!");
}
/* REPAIR */
if (getRepairMasteryMaxBonus() < 1) {
reason.add("Skills.Repair.RepairMastery.MaxBonusPercentage should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Repair.RepairMastery.MaxBonusPercentage should be at least 1!");
}
if (getRepairMasteryMaxLevel() < 1) {
reason.add("Skills.Repair.RepairMastery.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Repair.RepairMastery.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.REPAIR_SUPER_REPAIR) < 1) {
reason.add("Skills.Repair.SuperRepair.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Repair.SuperRepair.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.REPAIR_SUPER_REPAIR) < 1) {
reason.add("Skills.Repair.SuperRepair.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Repair.SuperRepair.MaxBonusLevel should be at least 1!");
}
/* SMELTING */
if (getBurnModifierMaxLevel() < 1) {
reason.add("Skills.Smelting.FuelEfficiency.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Smelting.FuelEfficiency.MaxBonusLevel should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.SMELTING_SECOND_SMELT) < 1) {
reason.add("Skills.Smelting.SecondSmelt.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Smelting.SecondSmelt.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.SMELTING_SECOND_SMELT) < 1) {
reason.add("Skills.Smelting.SecondSmelt.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Smelting.SecondSmelt.ChanceMax should be at least 1!");
}
if (getFluxMiningChance() < 1) {
reason.add("Skills.Smelting.FluxMining.Chance should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Smelting.FluxMining.Chance should be at least 1!");
}
/* SWORDS */
if (getMaximumProbability(SubSkillType.SWORDS_COUNTER_ATTACK) < 1) {
reason.add("Skills.Swords.CounterAttack.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Swords.CounterAttack.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.SWORDS_COUNTER_ATTACK) < 1) {
reason.add("Skills.Swords.CounterAttack.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Swords.CounterAttack.MaxBonusLevel should be at least 1!");
}
if (getCounterModifier() < 1) {
reason.add("Skills.Swords.CounterAttack.DamageModifier should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Swords.CounterAttack.DamageModifier should be at least 1!");
}
if (getSerratedStrikesModifier() < 1) {
reason.add("Skills.Swords.SerratedStrikes.DamageModifier should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Swords.SerratedStrikes.DamageModifier should be at least 1!");
}
if (getSerratedStrikesTicks() < 1) {
reason.add("Skills.Swords.SerratedStrikes.RuptureTicks should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Swords.SerratedStrikes.RuptureTicks should be at least 1!");
}
/* TAMING */
if (getMaximumProbability(SubSkillType.TAMING_GORE) < 1) {
reason.add("Skills.Taming.Gore.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Taming.Gore.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.TAMING_GORE) < 1) {
reason.add("Skills.Taming.Gore.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Taming.Gore.MaxBonusLevel should be at least 1!");
}
/*if (getGoreRuptureTicks() < 1) {
reason.add("Skills.Taming.Gore.RuptureTicks should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Taming.Gore.RuptureTicks should be at least 1!");
}*/
if (getGoreModifier() < 1) {
reason.add("Skills.Taming.Gore.Modifier should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Taming.Gore.Modifier should be at least 1!");
}
/*if (getFastFoodUnlock() < 0) {
reason.add("Skills.Taming.FastFood.UnlockLevel should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Taming.FastFood.UnlockLevel should be at least 0!");
}*/
if (getFastFoodChance() < 1) {
reason.add("Skills.Taming.FastFood.Chance should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Taming.FastFood.Chance should be at least 1!");
}
/*if (getEnviromentallyAwareUnlock() < 0) {
reason.add("Skills.Taming.EnvironmentallyAware.UnlockLevel should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Taming.EnvironmentallyAware.UnlockLevel should be at least 0!");
}*/
/*if (getThickFurUnlock() < 0) {
reason.add("Skills.Taming.ThickFur.UnlockLevel should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Taming.ThickFur.UnlockLevel should be at least 0!");
}*/
if (getThickFurModifier() < 1) {
reason.add("Skills.Taming.ThickFur.Modifier should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Taming.ThickFur.Modifier should be at least 1!");
}
/*if (getHolyHoundUnlock() < 0) {
reason.add("Skills.Taming.HolyHound.UnlockLevel should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Taming.HolyHound.UnlockLevel should be at least 0!");
}
if (getShockProofUnlock() < 0) {
reason.add("Skills.Taming.ShockProof.UnlockLevel should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Taming.ShockProof.UnlockLevel should be at least 0!");
}*/
if (getShockProofModifier() < 1) {
reason.add("Skills.Taming.ShockProof.Modifier should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Taming.ShockProof.Modifier should be at least 1!");
}
/*if (getSharpenedClawsUnlock() < 0) {
reason.add("Skills.Taming.SharpenedClaws.UnlockLevel should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Taming.SharpenedClaws.UnlockLevel should be at least 0!");
}*/
if (getSharpenedClawsBonus() < 1) {
reason.add("Skills.Taming.SharpenedClaws.Bonus should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Taming.SharpenedClaws.Bonus should be at least 1!");
}
if (getMaxHorseJumpStrength() < 0 || getMaxHorseJumpStrength() > 2) {
reason.add("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength should be between 0 and 2!");
mcMMO.p.getLogger().warning("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength should be between 0 and 2!");
}
/* UNARMED */
if (getMaximumProbability(SubSkillType.UNARMED_DISARM) < 1) {
reason.add("Skills.Unarmed.Disarm.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Unarmed.Disarm.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.UNARMED_DISARM) < 1) {
reason.add("Skills.Unarmed.Disarm.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Unarmed.Disarm.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.UNARMED_ARROW_DEFLECT) < 1) {
reason.add("Skills.Unarmed.ArrowDeflect.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Unarmed.ArrowDeflect.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.UNARMED_ARROW_DEFLECT) < 1) {
reason.add("Skills.Unarmed.ArrowDeflect.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Unarmed.ArrowDeflect.MaxBonusLevel should be at least 1!");
}
if (getMaximumProbability(SubSkillType.UNARMED_IRON_GRIP) < 1) {
reason.add("Skills.Unarmed.IronGrip.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Unarmed.IronGrip.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.UNARMED_IRON_GRIP) < 1) {
reason.add("Skills.Unarmed.IronGrip.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Unarmed.IronGrip.MaxBonusLevel should be at least 1!");
}
/* WOODCUTTING */
/*if (getLeafBlowUnlockLevel() < 0) {
reason.add("Skills.Woodcutting.LeafBlower.UnlockLevel should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Woodcutting.LeafBlower.UnlockLevel should be at least 0!");
}*/
if (getMaximumProbability(SubSkillType.WOODCUTTING_HARVEST_LUMBER) < 1) {
reason.add("Skills.Woodcutting.HarvestLumber.ChanceMax should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Woodcutting.HarvestLumber.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.WOODCUTTING_HARVEST_LUMBER) < 1) {
reason.add("Skills.Woodcutting.HarvestLumber.MaxBonusLevel should be at least 1!");
mcMMO.p.getLogger().warning("Skills.Woodcutting.HarvestLumber.MaxBonusLevel should be at least 1!");
}
return noErrorsInConfig(reason);
}
@Override

View File

@ -7,18 +7,18 @@ import org.jetbrains.annotations.NotNull;
import java.io.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public abstract class BukkitConfig {
public static final String CONFIG_PATCH_PREFIX = "ConfigPatchVersion:";
public static final String CURRENT_CONFIG_PATCH_VER = "ConfigPatchVersion: 2";
public static final char COMMENT_PREFIX = '#';
protected static final String CONFIG_PATCH_PREFIX = "ConfigPatchVersion:";
protected static final String CURRENT_CONFIG_PATCH_VER = "ConfigPatchVersion: 2";
protected static final char COMMENT_PREFIX = '#';
protected final String fileName;
protected final File configFile;
protected YamlConfiguration config;
protected @NotNull
final File dataFolder;
protected boolean unmodifiedConfig = true; //Used to mark when we have made a fix that needs an immediate save
public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder) {
mcMMO.p.getLogger().info("[config] Initializing config: " + fileName);
@ -30,6 +30,7 @@ public abstract class BukkitConfig {
initDefaults();
updateFile();
mcMMO.p.getLogger().info("[config] Config initialized: " + fileName);
validate();
}
@Deprecated
@ -83,23 +84,28 @@ public abstract class BukkitConfig {
protected abstract void loadKeys();
protected boolean validateKeys() {
return true;
protected abstract void validateConfigKeys();
protected void fixConfigKey(@NotNull String key, @NotNull String value, @NotNull String reason) {
mcMMO.p.getLogger().warning(reason);
config.set(key, value);
this.unmodifiedConfig = false; //flag to save config
}
protected boolean noErrorsInConfig(List<String> issues) {
for (String issue : issues) {
mcMMO.p.getLogger().warning(issue);
}
private void validate() {
//TODO: Rewrite legacy validation code
validateConfigKeys();
return issues.isEmpty();
}
protected void validate() {
if (validateKeys()) {
if (unmodifiedConfig) {
mcMMO.p.debug("No errors found in " + fileName + "!");
} else {
mcMMO.p.getLogger().warning("Errors were found in " + fileName + ", overwriting invalid values!");
mcMMO.p.getLogger().warning("Errors were found in " + fileName + ", overwriting invalid values with defaults");
try {
config.save(configFile);
unmodifiedConfig = true;
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -9,7 +9,6 @@ public class ChatConfig extends BukkitConfig {
private ChatConfig() {
super("chat.yml");
validate();
}
public static ChatConfig getInstance() {
@ -26,8 +25,8 @@ public class ChatConfig extends BukkitConfig {
}
@Override
protected boolean validateKeys() {
return true;
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
public boolean isChatEnabled() {

View File

@ -79,7 +79,6 @@ public abstract class ConfigLoader {
} else {
mcMMO.p.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
mcMMO.p.getServer().getPluginManager().disablePlugin(mcMMO.p);
mcMMO.p.noErrorsInConfigFiles = false;
}
}

View File

@ -9,7 +9,6 @@ public class CoreSkillsConfig extends BukkitConfig {
public CoreSkillsConfig() {
super("coreskills.yml");
validate();
}
public static CoreSkillsConfig getInstance() {
@ -25,9 +24,8 @@ public class CoreSkillsConfig extends BukkitConfig {
}
@Override
protected boolean validateKeys() {
return true;
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
/*

View File

@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
@ -22,7 +23,6 @@ public class GeneralConfig extends BukkitConfig {
public GeneralConfig(@NotNull File dataFolder) {
super("config.yml", dataFolder);
validate();
}
@Override
@ -31,127 +31,125 @@ public class GeneralConfig extends BukkitConfig {
}
@Override
protected boolean validateKeys() {
// Validate all the settings!
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
List<String> reason = new ArrayList<>();
/* General Settings */
if (getSaveInterval() <= 0) {
reason.add("General.Save_Interval should be greater than 0!");
mcMMO.p.getLogger().info("General.Save_Interval should be greater than 0!");
}
/* MySQL Settings */
for (PoolIdentifier identifier : PoolIdentifier.values()) {
if (getMySQLMaxConnections(identifier) <= 0) {
reason.add("MySQL.Database.MaxConnections." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
mcMMO.p.getLogger().warning("MySQL.Database.MaxConnections." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
}
if (getMySQLMaxPoolSize(identifier) <= 0) {
reason.add("MySQL.Database.MaxPoolSize." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
mcMMO.p.getLogger().warning("MySQL.Database.MaxPoolSize." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
}
}
/* Mob Healthbar */
if (getMobHealthbarTime() == 0) {
reason.add("Mob_Healthbar.Display_Time cannot be 0! Set to -1 to disable or set a valid value.");
mcMMO.p.getLogger().warning("Mob_Healthbar.Display_Time cannot be 0! Set to -1 to disable or set a valid value.");
}
/* Database Purging */
if (getPurgeInterval() < -1) {
reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
mcMMO.p.getLogger().warning("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
}
if (getOldUsersCutoff() != -1 && getOldUsersCutoff() <= 0) {
reason.add("Database_Purging.Old_User_Cutoff should be greater than 0 or -1!");
mcMMO.p.getLogger().warning("Database_Purging.Old_User_Cutoff should be greater than 0 or -1!");
}
/* Hardcore Mode */
if (getHardcoreDeathStatPenaltyPercentage() < 0.01 || getHardcoreDeathStatPenaltyPercentage() > 100) {
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 0.01 to 100!");
mcMMO.p.getLogger().warning("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 0.01 to 100!");
}
if (getHardcoreVampirismStatLeechPercentage() < 0.01 || getHardcoreVampirismStatLeechPercentage() > 100) {
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 0.01 to 100!");
mcMMO.p.getLogger().warning("Hardcore.Vampirism.Leech_Percentage only accepts values from 0.01 to 100!");
}
/* Items */
if (getChimaeraUseCost() < 1 || getChimaeraUseCost() > 64) {
reason.add("Items.Chimaera_Wing.Use_Cost only accepts values from 1 to 64!");
mcMMO.p.getLogger().warning("Items.Chimaera_Wing.Use_Cost only accepts values from 1 to 64!");
}
if (getChimaeraRecipeCost() < 1 || getChimaeraRecipeCost() > 9) {
reason.add("Items.Chimaera_Wing.Recipe_Cost only accepts values from 1 to 9!");
mcMMO.p.getLogger().warning("Items.Chimaera_Wing.Recipe_Cost only accepts values from 1 to 9!");
}
if (getChimaeraItem() == null) {
reason.add("Items.Chimaera_Wing.Item_Name is invalid!");
mcMMO.p.getLogger().warning("Items.Chimaera_Wing.Item_Name is invalid!");
}
/* Particles */
if (getLevelUpEffectsTier() < 1) {
reason.add("Particles.LevelUp_Tier should be at least 1!");
mcMMO.p.getLogger().warning("Particles.LevelUp_Tier should be at least 1!");
}
/* PARTY SETTINGS */
if (getAutoPartyKickInterval() < -1) {
reason.add("Party.AutoKick_Interval should be at least -1!");
mcMMO.p.getLogger().warning("Party.AutoKick_Interval should be at least -1!");
}
if (getAutoPartyKickTime() < 0) {
reason.add("Party.Old_Party_Member_Cutoff should be at least 0!");
mcMMO.p.getLogger().warning("Party.Old_Party_Member_Cutoff should be at least 0!");
}
if (getPartyShareBonusBase() <= 0) {
reason.add("Party.Sharing.ExpShare_bonus_base should be greater than 0!");
mcMMO.p.getLogger().warning("Party.Sharing.ExpShare_bonus_base should be greater than 0!");
}
if (getPartyShareBonusIncrease() < 0) {
reason.add("Party.Sharing.ExpShare_bonus_increase should be at least 0!");
mcMMO.p.getLogger().warning("Party.Sharing.ExpShare_bonus_increase should be at least 0!");
}
if (getPartyShareBonusCap() <= 0) {
reason.add("Party.Sharing.ExpShare_bonus_cap should be greater than 0!");
mcMMO.p.getLogger().warning("Party.Sharing.ExpShare_bonus_cap should be greater than 0!");
}
if (getPartyShareRange() <= 0) {
reason.add("Party.Sharing.Range should be greater than 0!");
mcMMO.p.getLogger().warning("Party.Sharing.Range should be greater than 0!");
}
if (getPartyXpCurveMultiplier() < 1) {
reason.add("Party.Leveling.Xp_Curve_Modifier should be at least 1!");
mcMMO.p.getLogger().warning("Party.Leveling.Xp_Curve_Modifier should be at least 1!");
}
for (PartyFeature partyFeature : PartyFeature.values()) {
if (getPartyFeatureUnlockLevel(partyFeature) < 0) {
reason.add("Party.Leveling." + StringUtils.getPrettyPartyFeatureString(partyFeature).replace(" ", "") + "_UnlockLevel should be at least 0!");
mcMMO.p.getLogger().warning("Party.Leveling." + StringUtils.getPrettyPartyFeatureString(partyFeature).replace(" ", "") + "_UnlockLevel should be at least 0!");
}
}
/* Inspect command distance */
if (getInspectDistance() <= 0) {
reason.add("Commands.inspect.Max_Distance should be greater than 0!");
mcMMO.p.getLogger().warning("Commands.inspect.Max_Distance should be greater than 0!");
}
if (getTreeFellerThreshold() <= 0) {
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
mcMMO.p.getLogger().warning("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
}
if (getFishingLureModifier() < 0) {
reason.add("Abilities.Fishing.Lure_Modifier should be at least 0!");
mcMMO.p.getLogger().warning("Abilities.Fishing.Lure_Modifier should be at least 0!");
}
if (getRepairAnvilMaterial() == null) {
reason.add("Skills.Repair.Anvil_Type is invalid!!");
mcMMO.p.getLogger().warning("Skills.Repair.Anvil_Type is invalid!!");
}
if (getSalvageAnvilMaterial() == null) {
reason.add("Skills.Repair.Salvage_Anvil_Type is invalid!");
mcMMO.p.getLogger().warning("Skills.Repair.Salvage_Anvil_Type is invalid!");
}
if (getRepairAnvilMaterial() == getSalvageAnvilMaterial()) {
reason.add("Cannot use the same item for Repair and Salvage anvils!");
mcMMO.p.getLogger().warning("Cannot use the same item for Repair and Salvage anvils!");
}
return noErrorsInConfig(reason);
}
/*

View File

@ -7,7 +7,6 @@ public class PersistentDataConfig extends BukkitConfig {
private PersistentDataConfig() {
super("persistent_data.yml");
validate();
}
public static PersistentDataConfig getInstance() {
@ -24,8 +23,8 @@ public class PersistentDataConfig extends BukkitConfig {
}
@Override
protected boolean validateKeys() {
return true;
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
//Persistent Data Toggles

View File

@ -8,7 +8,6 @@ public class SoundConfig extends BukkitConfig {
public SoundConfig() {
super("sounds.yml");
validate();
instance = this;
}
@ -25,22 +24,24 @@ public class SoundConfig extends BukkitConfig {
}
@Override
protected boolean validateKeys() {
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
for (SoundType soundType : SoundType.values()) {
if (config.getDouble("Sounds." + soundType.toString() + ".Volume") < 0) {
mcMMO.p.getLogger().info("[mcMMO] Sound volume cannot be below 0 for " + soundType);
return false;
//TODO: Rewrite legacy validation code
//return false;
}
//Sounds with custom pitching don't use pitch values
if (!soundType.usesCustomPitch()) {
if (config.getDouble("Sounds." + soundType + ".Pitch") < 0) {
mcMMO.p.getLogger().info("[mcMMO] Sound pitch cannot be below 0 for " + soundType);
return false;
//TODO: Rewrite legacy validation code
//return false;
}
}
}
return true;
}
public float getMasterVolume() {

View File

@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.MaterialType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -13,16 +14,17 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
public class ExperienceConfig extends BukkitConfig {
private static ExperienceConfig instance;
private ExperienceConfig() {
super("experience.yml");
validate();
}
public static ExperienceConfig getInstance() {
@ -33,12 +35,18 @@ public class ExperienceConfig extends BukkitConfig {
return instance;
}
@Override
public void initDefaults() {
super.initDefaults();
}
@Override
protected void loadKeys() {
}
@Override
protected boolean validateKeys() {
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
List<String> reason = new ArrayList<>();
/*
@ -46,41 +54,48 @@ public class ExperienceConfig extends BukkitConfig {
*/
/* Curve values */
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
}
final BiConsumer<String, Object> consumer = (String str, Object obj) -> config.set(str, obj);
if (getMultiplier(FormulaType.LINEAR) <= 0) {
reason.add("Experience_Formula.Linear_Values.multiplier should be greater than 0!");
mcMMO.p.getLogger().warning("Experience_Formula.Linear_Values.multiplier should be greater than 0!");
config.set("Experience_Formula." + StringUtils.getCapitalized(FormulaType.LINEAR.toString()) + "_Values.multiplier", 0.1);
}
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
mcMMO.p.getLogger().warning("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
config.set("Experience_Formula." + StringUtils.getCapitalized(FormulaType.EXPONENTIAL.toString()) + "_Values.multiplier", 0.1);
}
if (getExponent(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.exponent should be greater than 0!");
mcMMO.p.getLogger().warning("Experience_Formula.Exponential_Values.exponent should be greater than 0!");
config.set("Experience_Formula." + StringUtils.getCapitalized(FormulaType.EXPONENTIAL.toString()) + "_Values.exponent", 1.80);
}
/* Global modifier */
if (getExperienceGainsGlobalMultiplier() <= 0) {
reason.add("Experience_Formula.Multiplier.Global should be greater than 0!");
mcMMO.p.getLogger().warning("Experience_Formula.Multiplier.Global should be at least 0!");
config.set("Experience_Formula.Multiplier.Global", 1.0);
}
/* PVP modifier */
if (getPlayerVersusPlayerXP() < 0) {
reason.add("Experience_Formula.Multiplier.PVP should be at least 0!");
mcMMO.p.getLogger().warning("Experience_Formula.Multiplier.PVP should be at least 0!");
}
/* Spawned Mob modifier */
if (getSpawnedMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
mcMMO.p.getLogger().warning("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
}
/* Bred Mob modifier */
if (getBredMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Breeding.Multiplier should be at least 0!");
mcMMO.p.getLogger().warning("Experience_Formula.Breeding.Multiplier should be at least 0!");
}
/* Conversion */
if (getExpModifier() <= 0) {
reason.add("Conversion.Exp_Modifier should be greater than 0!");
mcMMO.p.getLogger().warning("Conversion.Exp_Modifier should be greater than 0!");
}
/*
@ -90,54 +105,52 @@ public class ExperienceConfig extends BukkitConfig {
/* Alchemy */
for (PotionStage potionStage : PotionStage.values()) {
if (getPotionXP(potionStage) < 0) {
reason.add("Experience_Values.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
mcMMO.p.getLogger().warning("Experience_Values.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
}
}
/* Archery */
if (getArcheryDistanceMultiplier() < 0) {
reason.add("Experience_Values.Archery.Distance_Multiplier should be at least 0!");
mcMMO.p.getLogger().warning("Experience_Values.Archery.Distance_Multiplier should be at least 0!");
}
/* Combat XP Multipliers */
if (getAnimalsXP() < 0) {
reason.add("Experience_Values.Combat.Multiplier.Animals should be at least 0!");
mcMMO.p.getLogger().warning("Experience_Values.Combat.Multiplier.Animals should be at least 0!");
}
if (getDodgeXPModifier() < 0) {
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
}
if (getRollXPModifier() < 0) {
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
}
if (getFallXPModifier() < 0) {
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
mcMMO.p.getLogger().warning("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
}
/* Fishing */
// TODO: Add validation for each fish type once enum is available.
if (getFishingShakeXP() <= 0) {
reason.add("Experience_Values.Fishing.Shake should be greater than 0!");
mcMMO.p.getLogger().warning("Experience_Values.Fishing.Shake should be greater than 0!");
}
/* Repair */
if (getRepairXPBase() <= 0) {
reason.add("Experience_Values.Repair.Base should be greater than 0!");
mcMMO.p.getLogger().warning("Experience_Values.Repair.Base should be greater than 0!");
}
/* Taming */
if (getTamingXP(EntityType.WOLF) <= 0) {
reason.add("Experience_Values.Taming.Animal_Taming.Wolf should be greater than 0!");
mcMMO.p.getLogger().warning("Experience_Values.Taming.Animal_Taming.Wolf should be greater than 0!");
}
if (getTamingXP(EntityType.OCELOT) <= 0) {
reason.add("Experience_Values.Taming.Animal_Taming.Ocelot should be greater than 0!");
mcMMO.p.getLogger().warning("Experience_Values.Taming.Animal_Taming.Ocelot should be greater than 0!");
}
return noErrorsInConfig(reason);
}
public boolean isEarlyGameBoostEnabled() {

View File

@ -22,6 +22,11 @@ public class ItemWeightConfig extends BukkitConfig {
return instance;
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
public int getItemWeight(Material material) {
return config.getInt("Item_Weights." + StringUtils.getPrettyItemString(material).replace(" ", "_"), config.getInt("Item_Weights.Default"));
}

View File

@ -23,6 +23,11 @@ public class RepairConfig extends BukkitConfig {
loadKeys();
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
@Override
protected void loadKeys() {
repairables = new ArrayList<>();
@ -81,7 +86,7 @@ public class RepairConfig extends BukkitConfig {
try {
repairMaterialType = MaterialType.valueOf(repairMaterialTypeString);
} catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
mcMMO.p.getLogger().warning(key + " has an invalid MaterialType of " + repairMaterialTypeString);
}
}
@ -102,7 +107,7 @@ public class RepairConfig extends BukkitConfig {
}
if (maximumDurability <= 0) {
reason.add("Maximum durability of " + key + " must be greater than 0!");
mcMMO.p.getLogger().warning("Maximum durability of " + key + " must be greater than 0!");
}
// Item Type
@ -121,7 +126,7 @@ public class RepairConfig extends BukkitConfig {
try {
repairItemType = ItemType.valueOf(repairItemTypeString);
} catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
mcMMO.p.getLogger().warning(key + " has an invalid ItemType of " + repairItemTypeString);
}
}
@ -129,7 +134,7 @@ public class RepairConfig extends BukkitConfig {
double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
if (minimumLevel < 0) {
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
mcMMO.p.getLogger().warning(key + " has an invalid MinimumLevel of " + minimumLevel);
}
// Minimum Quantity

View File

@ -26,6 +26,11 @@ public class SalvageConfig extends BukkitConfig {
loadKeys();
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
@Override
protected void loadKeys() {
salvageables = new HashSet<>();
@ -97,7 +102,7 @@ public class SalvageConfig extends BukkitConfig {
try {
salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid MaterialType of " + salvageMaterialTypeString);
mcMMO.p.getLogger().warning(key + " has an invalid MaterialType of " + salvageMaterialTypeString);
}
}
@ -129,7 +134,7 @@ public class SalvageConfig extends BukkitConfig {
try {
salvageItemType = ItemType.valueOf(salvageItemTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid ItemType of " + salvageItemTypeString);
mcMMO.p.getLogger().warning(key + " has an invalid ItemType of " + salvageItemTypeString);
}
}
@ -137,7 +142,7 @@ public class SalvageConfig extends BukkitConfig {
double xpMultiplier = config.getDouble("Salvageables." + key + ".XpMultiplier", 1);
if (minimumLevel < 0) {
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
mcMMO.p.getLogger().warning(key + " has an invalid MinimumLevel of " + minimumLevel);
}
// Maximum Quantity
@ -154,7 +159,7 @@ public class SalvageConfig extends BukkitConfig {
}
if (maximumQuantity <= 0) {
reason.add("Maximum quantity of " + key + " must be greater than 0!");
mcMMO.p.getLogger().warning("Maximum quantity of " + key + " must be greater than 0!");
}
if (noErrorsInSalvageable(reason)) {

View File

@ -30,7 +30,6 @@ public class FishingTreasureConfig extends BukkitConfig {
private FishingTreasureConfig() {
super(FILENAME);
loadKeys();
validate();
}
public static FishingTreasureConfig getInstance() {
@ -42,8 +41,8 @@ public class FishingTreasureConfig extends BukkitConfig {
}
@Override
protected boolean validateKeys() {
// Validate all the settings!
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
List<String> reason = new ArrayList<>();
ConfigurationSection enchantment_drop_rates = config.getConfigurationSection("Enchantment_Drop_Rates");
@ -57,11 +56,11 @@ public class FishingTreasureConfig extends BukkitConfig {
double itemDropRate = config.getDouble("Item_Drop_Rates." + tier + "." + rarity);
if ((enchantDropRate < 0.0 || enchantDropRate > 100.0)) {
reason.add("The enchant drop rate for " + tier + " items that are " + rarity + "should be between 0.0 and 100.0!");
mcMMO.p.getLogger().warning("The enchant drop rate for " + tier + " items that are " + rarity + "should be between 0.0 and 100.0!");
}
if (itemDropRate < 0.0 || itemDropRate > 100.0) {
reason.add("The item drop rate for " + tier + " items that are " + rarity + "should be between 0.0 and 100.0!");
mcMMO.p.getLogger().warning("The item drop rate for " + tier + " items that are " + rarity + "should be between 0.0 and 100.0!");
}
totalEnchantDropRate += enchantDropRate;
@ -69,18 +68,16 @@ public class FishingTreasureConfig extends BukkitConfig {
}
if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) {
reason.add("The total enchant drop rate for " + tier + " should be between 0.0 and 100.0!");
mcMMO.p.getLogger().warning("The total enchant drop rate for " + tier + " should be between 0.0 and 100.0!");
}
if (totalItemDropRate < 0 || totalItemDropRate > 100.0) {
reason.add("The total item drop rate for " + tier + " should be between 0.0 and 100.0!");
mcMMO.p.getLogger().warning("The total item drop rate for " + tier + " should be between 0.0 and 100.0!");
}
}
} else {
mcMMO.p.getLogger().warning("Your fishing treasures config is empty, is this intentional? Delete it to regenerate.");
}
return noErrorsInConfig(reason);
}
@Override
@ -141,7 +138,7 @@ public class FishingTreasureConfig extends BukkitConfig {
short data = (treasureInfo.length == 2) ? Short.parseShort(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
if (material == null) {
reason.add("Cannot find matching item type in this version of MC, skipping - " + materialName);
mcMMO.p.getLogger().warning("Cannot find matching item type in this version of MC, skipping - " + materialName);
continue;
}
@ -150,7 +147,7 @@ public class FishingTreasureConfig extends BukkitConfig {
}
if (material.isBlock() && (data > 127 || data < -128)) {
reason.add("Data of " + treasureName + " is invalid! " + data);
mcMMO.p.getLogger().warning("Data of " + treasureName + " is invalid! " + data);
}
/*
@ -162,15 +159,15 @@ public class FishingTreasureConfig extends BukkitConfig {
int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
if (xp < 0) {
reason.add(treasureName + " has an invalid XP value: " + xp);
mcMMO.p.getLogger().warning(treasureName + " has an invalid XP value: " + xp);
}
if (dropChance < 0.0D) {
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
mcMMO.p.getLogger().warning(treasureName + " has an invalid Drop_Chance: " + dropChance);
}
if (dropLevel < 0) {
reason.add("Fishing Config: " + treasureName + " has an invalid Drop_Level: " + dropLevel);
mcMMO.p.getLogger().warning("Fishing Config: " + treasureName + " has an invalid Drop_Level: " + dropLevel);
}
/*
@ -205,7 +202,7 @@ public class FishingTreasureConfig extends BukkitConfig {
if (materialName.contains("POTION")) {
Material mat = Material.matchMaterial(materialName);
if (mat == null) {
reason.add("Potion format for " + FILENAME + " has changed");
mcMMO.p.getLogger().warning("Potion format for " + FILENAME + " has changed");
} else {
item = new ItemStack(mat, amount, data);
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
@ -219,7 +216,7 @@ public class FishingTreasureConfig extends BukkitConfig {
try {
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
} catch (IllegalArgumentException ex) {
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
mcMMO.p.getLogger().warning("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
}
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
@ -282,7 +279,8 @@ public class FishingTreasureConfig extends BukkitConfig {
}
if (noErrorsInConfig(reason)) {
//TODO: Rewrite legacy validation code
// Look into what needs to change for this
if (isFishing) {
addFishingTreasure(rarity, new FishingTreasure(item, xp));
} else if (isShake) {
@ -293,7 +291,6 @@ public class FishingTreasureConfig extends BukkitConfig {
}
}
}
}
private void addShakeTreasure(@NotNull ShakeTreasure shakeTreasure, @NotNull EntityType entityType) {
if (!shakeMap.containsKey(entityType))

View File

@ -37,7 +37,6 @@ public class TreasureConfig extends BukkitConfig {
private TreasureConfig() {
super(FILENAME);
loadKeys();
validate();
}
public static TreasureConfig getInstance() {
@ -49,11 +48,8 @@ public class TreasureConfig extends BukkitConfig {
}
@Override
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<>();
return noErrorsInConfig(reason);
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
@Override
@ -95,7 +91,7 @@ public class TreasureConfig extends BukkitConfig {
short data = (treasureInfo.length == 2) ? Short.parseShort(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
if (material == null) {
reason.add("Invalid material: " + materialName);
mcMMO.p.getLogger().warning("Invalid material: " + materialName);
}
if (amount <= 0) {
@ -103,7 +99,7 @@ public class TreasureConfig extends BukkitConfig {
}
if (material != null && material.isBlock() && (data > 127 || data < -128)) {
reason.add("Data of " + treasureName + " is invalid! " + data);
mcMMO.p.getLogger().warning("Data of " + treasureName + " is invalid! " + data);
}
/*
@ -147,11 +143,11 @@ public class TreasureConfig extends BukkitConfig {
}
if (xp < 0) {
reason.add(treasureName + " has an invalid XP value: " + xp);
mcMMO.p.getLogger().warning(treasureName + " has an invalid XP value: " + xp);
}
if (dropChance < 0.0D) {
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
mcMMO.p.getLogger().warning(treasureName + " has an invalid Drop_Chance: " + dropChance);
}
/*
@ -162,7 +158,7 @@ public class TreasureConfig extends BukkitConfig {
if (materialName.contains("POTION")) {
Material mat = Material.matchMaterial(materialName);
if (mat == null) {
reason.add("Potion format for " + FILENAME + " has changed");
mcMMO.p.getLogger().warning("Potion format for " + FILENAME + " has changed");
} else {
item = new ItemStack(mat, amount, data);
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
@ -171,7 +167,7 @@ public class TreasureConfig extends BukkitConfig {
try {
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
} catch (IllegalArgumentException ex) {
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
mcMMO.p.getLogger().warning("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
}
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
@ -210,7 +206,8 @@ public class TreasureConfig extends BukkitConfig {
}
}
if (noErrorsInConfig(reason)) {
//TODO: Rewrite legacy validation code
// Look into what needs to change for this
if (isExcavation) {
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
@ -255,7 +252,6 @@ public class TreasureConfig extends BukkitConfig {
}
}
}
}
//Apply our fix
if (shouldWeUpdateFile) {

View File

@ -15,6 +15,11 @@ public class ChildConfig extends BukkitConfig {
loadKeys();
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
@Override
protected void loadKeys() {
config.setDefaults(YamlConfiguration.loadConfiguration(mcMMO.p.getResourceAsReader("child.yml")));

View File

@ -19,6 +19,12 @@ public class UpgradeManager extends BukkitConfig {
loadKeys();
}
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
// Look into what needs to change for this
}
/**
* Check if the given {@link UpgradeType} is necessary.
*