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) { public AdvancedConfig(File dataFolder) {
super("advanced.yml", dataFolder); super("advanced.yml", dataFolder);
validate();
} }
@Override @Override
@ -23,125 +22,125 @@ public class AdvancedConfig extends BukkitConfig {
} }
@Override @Override
protected boolean validateKeys() { protected void validateConfigKeys() {
// Validate all the settings! //TODO: Rewrite legacy validation code
List<String> reason = new ArrayList<>(); List<String> reason = new ArrayList<>();
/* GENERAL */ /* GENERAL */
if (getAbilityLength() < 1) { 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) { 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 */ /* ACROBATICS */
if (getMaximumProbability(SubSkillType.ACROBATICS_DODGE) < 1) { 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) { 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) { 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) { 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) { 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) { 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) { 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) { 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()) { 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 */ /* ARCHERY */
if (getSkillShotRankDamageMultiplier() <= 0) { 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) { 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) { 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) { 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) { 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) { 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) { 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 */ /* AXES */
if (getAxeMasteryRankDamageMultiplier() < 0) { 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) { 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) { 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) { 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) { 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) { 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) { 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) { 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) { 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) { 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 */ /* FISHING */
@ -149,262 +148,261 @@ public class AdvancedConfig extends BukkitConfig {
for (int rank : fishingTierList) { for (int rank : fishingTierList) {
if (getFishingTierLevel(tier) < 0) { 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) { 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) { 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) { if (tier != Fishing.Tier.EIGHT) {
Fishing.Tier nextTier = fishingTierList.get(fishingTierList.indexOf(tier) - 1); Fishing.Tier nextTier = fishingTierList.get(fishingTierList.indexOf(tier) - 1);
if (getFishingTierLevel(tier) > getFishingTierLevel(nextTier)) { 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)) { 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)) { 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) { 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) { /*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) { 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) { 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) { 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 */ /* HERBALISM */
if (getFarmerDietRankChange() < 1) { 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) { 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) { 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) { 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) { 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) { 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) { 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) { 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) { 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) { 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 */ /* MINING */
if (getMaximumProbability(SubSkillType.MINING_DOUBLE_DROPS) < 1) { 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) { 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 */ /* REPAIR */
if (getRepairMasteryMaxBonus() < 1) { 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) { 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) { 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) { 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 */ /* SMELTING */
if (getBurnModifierMaxLevel() < 1) { 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) { 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) { 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) { 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 */ /* SWORDS */
if (getMaximumProbability(SubSkillType.SWORDS_COUNTER_ATTACK) < 1) { 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) { 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) { 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) { 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) { 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 */ /* TAMING */
if (getMaximumProbability(SubSkillType.TAMING_GORE) < 1) { 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) { 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) { /*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) { 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) { /*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) { 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) { /*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) { /*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) { 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) { /*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) { 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) { 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) { /*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) { 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) { 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 */ /* UNARMED */
if (getMaximumProbability(SubSkillType.UNARMED_DISARM) < 1) { 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) { 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) { 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) { 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) { 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) { 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 */ /* WOODCUTTING */
/*if (getLeafBlowUnlockLevel() < 0) { /*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) { 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) { 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 @Override

View File

@ -7,18 +7,18 @@ import org.jetbrains.annotations.NotNull;
import java.io.*; import java.io.*;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
public abstract class BukkitConfig { public abstract class BukkitConfig {
public static final String CONFIG_PATCH_PREFIX = "ConfigPatchVersion:"; protected static final String CONFIG_PATCH_PREFIX = "ConfigPatchVersion:";
public static final String CURRENT_CONFIG_PATCH_VER = "ConfigPatchVersion: 2"; protected static final String CURRENT_CONFIG_PATCH_VER = "ConfigPatchVersion: 2";
public static final char COMMENT_PREFIX = '#'; protected static final char COMMENT_PREFIX = '#';
protected final String fileName; protected final String fileName;
protected final File configFile; protected final File configFile;
protected YamlConfiguration config; protected YamlConfiguration config;
protected @NotNull protected @NotNull
final File dataFolder; 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) { public BukkitConfig(@NotNull String fileName, @NotNull File dataFolder) {
mcMMO.p.getLogger().info("[config] Initializing config: " + fileName); mcMMO.p.getLogger().info("[config] Initializing config: " + fileName);
@ -30,6 +30,7 @@ public abstract class BukkitConfig {
initDefaults(); initDefaults();
updateFile(); updateFile();
mcMMO.p.getLogger().info("[config] Config initialized: " + fileName); mcMMO.p.getLogger().info("[config] Config initialized: " + fileName);
validate();
} }
@Deprecated @Deprecated
@ -83,23 +84,28 @@ public abstract class BukkitConfig {
protected abstract void loadKeys(); protected abstract void loadKeys();
protected boolean validateKeys() { protected abstract void validateConfigKeys();
return true;
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) { private void validate() {
for (String issue : issues) { //TODO: Rewrite legacy validation code
mcMMO.p.getLogger().warning(issue); validateConfigKeys();
}
return issues.isEmpty(); if (unmodifiedConfig) {
}
protected void validate() {
if (validateKeys()) {
mcMMO.p.debug("No errors found in " + fileName + "!"); mcMMO.p.debug("No errors found in " + fileName + "!");
} else { } 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() { private ChatConfig() {
super("chat.yml"); super("chat.yml");
validate();
} }
public static ChatConfig getInstance() { public static ChatConfig getInstance() {
@ -26,8 +25,8 @@ public class ChatConfig extends BukkitConfig {
} }
@Override @Override
protected boolean validateKeys() { protected void validateConfigKeys() {
return true; //TODO: Rewrite legacy validation code
} }
public boolean isChatEnabled() { public boolean isChatEnabled() {

View File

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

View File

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

View File

@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.MobHealthbarType;
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.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.text.StringUtils; import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
@ -22,7 +23,6 @@ public class GeneralConfig extends BukkitConfig {
public GeneralConfig(@NotNull File dataFolder) { public GeneralConfig(@NotNull File dataFolder) {
super("config.yml", dataFolder); super("config.yml", dataFolder);
validate();
} }
@Override @Override
@ -31,127 +31,125 @@ public class GeneralConfig extends BukkitConfig {
} }
@Override @Override
protected boolean validateKeys() { protected void validateConfigKeys() {
// Validate all the settings! //TODO: Rewrite legacy validation code
List<String> reason = new ArrayList<>(); List<String> reason = new ArrayList<>();
/* General Settings */ /* General Settings */
if (getSaveInterval() <= 0) { 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 */ /* MySQL Settings */
for (PoolIdentifier identifier : PoolIdentifier.values()) { for (PoolIdentifier identifier : PoolIdentifier.values()) {
if (getMySQLMaxConnections(identifier) <= 0) { 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) { 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 */ /* Mob Healthbar */
if (getMobHealthbarTime() == 0) { 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 */ /* Database Purging */
if (getPurgeInterval() < -1) { 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) { 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 */ /* Hardcore Mode */
if (getHardcoreDeathStatPenaltyPercentage() < 0.01 || getHardcoreDeathStatPenaltyPercentage() > 100) { 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) { 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 */ /* Items */
if (getChimaeraUseCost() < 1 || getChimaeraUseCost() > 64) { 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) { 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) { if (getChimaeraItem() == null) {
reason.add("Items.Chimaera_Wing.Item_Name is invalid!"); mcMMO.p.getLogger().warning("Items.Chimaera_Wing.Item_Name is invalid!");
} }
/* Particles */ /* Particles */
if (getLevelUpEffectsTier() < 1) { 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 */ /* PARTY SETTINGS */
if (getAutoPartyKickInterval() < -1) { 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) { 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) { 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) { 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) { 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) { 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) { 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()) { for (PartyFeature partyFeature : PartyFeature.values()) {
if (getPartyFeatureUnlockLevel(partyFeature) < 0) { 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 */ /* Inspect command distance */
if (getInspectDistance() <= 0) { 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) { 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) { 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) { if (getRepairAnvilMaterial() == null) {
reason.add("Skills.Repair.Anvil_Type is invalid!!"); mcMMO.p.getLogger().warning("Skills.Repair.Anvil_Type is invalid!!");
} }
if (getSalvageAnvilMaterial() == null) { 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()) { 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() { private PersistentDataConfig() {
super("persistent_data.yml"); super("persistent_data.yml");
validate();
} }
public static PersistentDataConfig getInstance() { public static PersistentDataConfig getInstance() {
@ -24,8 +23,8 @@ public class PersistentDataConfig extends BukkitConfig {
} }
@Override @Override
protected boolean validateKeys() { protected void validateConfigKeys() {
return true; //TODO: Rewrite legacy validation code
} }
//Persistent Data Toggles //Persistent Data Toggles

View File

@ -8,7 +8,6 @@ public class SoundConfig extends BukkitConfig {
public SoundConfig() { public SoundConfig() {
super("sounds.yml"); super("sounds.yml");
validate();
instance = this; instance = this;
} }
@ -25,22 +24,24 @@ public class SoundConfig extends BukkitConfig {
} }
@Override @Override
protected boolean validateKeys() { protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
for (SoundType soundType : SoundType.values()) { for (SoundType soundType : SoundType.values()) {
if (config.getDouble("Sounds." + soundType.toString() + ".Volume") < 0) { if (config.getDouble("Sounds." + soundType.toString() + ".Volume") < 0) {
mcMMO.p.getLogger().info("[mcMMO] Sound volume cannot be below 0 for " + soundType); 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 //Sounds with custom pitching don't use pitch values
if (!soundType.usesCustomPitch()) { if (!soundType.usesCustomPitch()) {
if (config.getDouble("Sounds." + soundType + ".Pitch") < 0) { if (config.getDouble("Sounds." + soundType + ".Pitch") < 0) {
mcMMO.p.getLogger().info("[mcMMO] Sound pitch cannot be below 0 for " + soundType); 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() { 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.MaterialType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage; import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.text.StringUtils; import com.gmail.nossr50.util.text.StringUtils;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -13,16 +14,17 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor; import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle; import org.bukkit.boss.BarStyle;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.BiConsumer;
public class ExperienceConfig extends BukkitConfig { public class ExperienceConfig extends BukkitConfig {
private static ExperienceConfig instance; private static ExperienceConfig instance;
private ExperienceConfig() { private ExperienceConfig() {
super("experience.yml"); super("experience.yml");
validate();
} }
public static ExperienceConfig getInstance() { public static ExperienceConfig getInstance() {
@ -33,12 +35,18 @@ public class ExperienceConfig extends BukkitConfig {
return instance; return instance;
} }
@Override
public void initDefaults() {
super.initDefaults();
}
@Override @Override
protected void loadKeys() { protected void loadKeys() {
} }
@Override @Override
protected boolean validateKeys() { protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
List<String> reason = new ArrayList<>(); List<String> reason = new ArrayList<>();
/* /*
@ -46,41 +54,48 @@ public class ExperienceConfig extends BukkitConfig {
*/ */
/* Curve values */ /* Curve values */
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) { final BiConsumer<String, Object> consumer = (String str, Object obj) -> config.set(str, obj);
reason.add("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
}
if (getMultiplier(FormulaType.LINEAR) <= 0) { 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) { 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 */ /* Global modifier */
if (getExperienceGainsGlobalMultiplier() <= 0) { 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 */ /* PVP modifier */
if (getPlayerVersusPlayerXP() < 0) { 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 */ /* Spawned Mob modifier */
if (getSpawnedMobXpMultiplier() < 0) { 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 */ /* Bred Mob modifier */
if (getBredMobXpMultiplier() < 0) { 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 */ /* Conversion */
if (getExpModifier() <= 0) { 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 */ /* Alchemy */
for (PotionStage potionStage : PotionStage.values()) { for (PotionStage potionStage : PotionStage.values()) {
if (getPotionXP(potionStage) < 0) { 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 */ /* Archery */
if (getArcheryDistanceMultiplier() < 0) { 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 */ /* Combat XP Multipliers */
if (getAnimalsXP() < 0) { 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) { 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) { 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) { 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 */ /* Fishing */
// TODO: Add validation for each fish type once enum is available. // TODO: Add validation for each fish type once enum is available.
if (getFishingShakeXP() <= 0) { 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 */ /* Repair */
if (getRepairXPBase() <= 0) { 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 */ /* Taming */
if (getTamingXP(EntityType.WOLF) <= 0) { 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) { 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() { public boolean isEarlyGameBoostEnabled() {

View File

@ -22,6 +22,11 @@ public class ItemWeightConfig extends BukkitConfig {
return instance; return instance;
} }
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
public int getItemWeight(Material material) { public int getItemWeight(Material material) {
return config.getInt("Item_Weights." + StringUtils.getPrettyItemString(material).replace(" ", "_"), config.getInt("Item_Weights.Default")); 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(); loadKeys();
} }
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
@Override @Override
protected void loadKeys() { protected void loadKeys() {
repairables = new ArrayList<>(); repairables = new ArrayList<>();
@ -81,7 +86,7 @@ public class RepairConfig extends BukkitConfig {
try { try {
repairMaterialType = MaterialType.valueOf(repairMaterialTypeString); repairMaterialType = MaterialType.valueOf(repairMaterialTypeString);
} catch (IllegalArgumentException ex) { } 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) { 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 // Item Type
@ -121,7 +126,7 @@ public class RepairConfig extends BukkitConfig {
try { try {
repairItemType = ItemType.valueOf(repairItemTypeString); repairItemType = ItemType.valueOf(repairItemTypeString);
} catch (IllegalArgumentException ex) { } 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); double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
if (minimumLevel < 0) { 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 // Minimum Quantity

View File

@ -26,6 +26,11 @@ public class SalvageConfig extends BukkitConfig {
loadKeys(); loadKeys();
} }
@Override
protected void validateConfigKeys() {
//TODO: Rewrite legacy validation code
}
@Override @Override
protected void loadKeys() { protected void loadKeys() {
salvageables = new HashSet<>(); salvageables = new HashSet<>();
@ -97,7 +102,7 @@ public class SalvageConfig extends BukkitConfig {
try { try {
salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH)); salvageMaterialType = MaterialType.valueOf(salvageMaterialTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException ex) { } 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 { try {
salvageItemType = ItemType.valueOf(salvageItemTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH)); salvageItemType = ItemType.valueOf(salvageItemTypeString.replace(" ", "_").toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException ex) { } 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); double xpMultiplier = config.getDouble("Salvageables." + key + ".XpMultiplier", 1);
if (minimumLevel < 0) { 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 // Maximum Quantity
@ -154,7 +159,7 @@ public class SalvageConfig extends BukkitConfig {
} }
if (maximumQuantity <= 0) { 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)) { if (noErrorsInSalvageable(reason)) {

View File

@ -30,7 +30,6 @@ public class FishingTreasureConfig extends BukkitConfig {
private FishingTreasureConfig() { private FishingTreasureConfig() {
super(FILENAME); super(FILENAME);
loadKeys(); loadKeys();
validate();
} }
public static FishingTreasureConfig getInstance() { public static FishingTreasureConfig getInstance() {
@ -42,8 +41,8 @@ public class FishingTreasureConfig extends BukkitConfig {
} }
@Override @Override
protected boolean validateKeys() { protected void validateConfigKeys() {
// Validate all the settings! //TODO: Rewrite legacy validation code
List<String> reason = new ArrayList<>(); List<String> reason = new ArrayList<>();
ConfigurationSection enchantment_drop_rates = config.getConfigurationSection("Enchantment_Drop_Rates"); 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); double itemDropRate = config.getDouble("Item_Drop_Rates." + tier + "." + rarity);
if ((enchantDropRate < 0.0 || enchantDropRate > 100.0)) { 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) { 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; totalEnchantDropRate += enchantDropRate;
@ -69,18 +68,16 @@ public class FishingTreasureConfig extends BukkitConfig {
} }
if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) { 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) { 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 { } else {
mcMMO.p.getLogger().warning("Your fishing treasures config is empty, is this intentional? Delete it to regenerate."); mcMMO.p.getLogger().warning("Your fishing treasures config is empty, is this intentional? Delete it to regenerate.");
} }
return noErrorsInConfig(reason);
} }
@Override @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"); short data = (treasureInfo.length == 2) ? Short.parseShort(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
if (material == null) { 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; continue;
} }
@ -150,7 +147,7 @@ public class FishingTreasureConfig extends BukkitConfig {
} }
if (material.isBlock() && (data > 127 || data < -128)) { 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"); int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
if (xp < 0) { 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) { 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) { 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")) { if (materialName.contains("POTION")) {
Material mat = Material.matchMaterial(materialName); Material mat = Material.matchMaterial(materialName);
if (mat == null) { if (mat == null) {
reason.add("Potion format for " + FILENAME + " has changed"); mcMMO.p.getLogger().warning("Potion format for " + FILENAME + " has changed");
} else { } else {
item = new ItemStack(mat, amount, data); item = new ItemStack(mat, amount, data);
PotionMeta itemMeta = (PotionMeta) item.getItemMeta(); PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
@ -219,7 +216,7 @@ public class FishingTreasureConfig extends BukkitConfig {
try { try {
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER")); potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
} catch (IllegalArgumentException ex) { } 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 extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false); boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
@ -282,15 +279,15 @@ public class FishingTreasureConfig extends BukkitConfig {
} }
if (noErrorsInConfig(reason)) { //TODO: Rewrite legacy validation code
if (isFishing) { // Look into what needs to change for this
addFishingTreasure(rarity, new FishingTreasure(item, xp)); if (isFishing) {
} else if (isShake) { addFishingTreasure(rarity, new FishingTreasure(item, xp));
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel); } else if (isShake) {
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
EntityType entityType = EntityType.valueOf(type.substring(6)); EntityType entityType = EntityType.valueOf(type.substring(6));
addShakeTreasure(shakeTreasure, entityType); addShakeTreasure(shakeTreasure, entityType);
}
} }
} }
} }

View File

@ -37,7 +37,6 @@ public class TreasureConfig extends BukkitConfig {
private TreasureConfig() { private TreasureConfig() {
super(FILENAME); super(FILENAME);
loadKeys(); loadKeys();
validate();
} }
public static TreasureConfig getInstance() { public static TreasureConfig getInstance() {
@ -49,11 +48,8 @@ public class TreasureConfig extends BukkitConfig {
} }
@Override @Override
protected boolean validateKeys() { protected void validateConfigKeys() {
// Validate all the settings! //TODO: Rewrite legacy validation code
List<String> reason = new ArrayList<>();
return noErrorsInConfig(reason);
} }
@Override @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"); short data = (treasureInfo.length == 2) ? Short.parseShort(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
if (material == null) { if (material == null) {
reason.add("Invalid material: " + materialName); mcMMO.p.getLogger().warning("Invalid material: " + materialName);
} }
if (amount <= 0) { if (amount <= 0) {
@ -103,7 +99,7 @@ public class TreasureConfig extends BukkitConfig {
} }
if (material != null && material.isBlock() && (data > 127 || data < -128)) { 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) { 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) { 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")) { if (materialName.contains("POTION")) {
Material mat = Material.matchMaterial(materialName); Material mat = Material.matchMaterial(materialName);
if (mat == null) { if (mat == null) {
reason.add("Potion format for " + FILENAME + " has changed"); mcMMO.p.getLogger().warning("Potion format for " + FILENAME + " has changed");
} else { } else {
item = new ItemStack(mat, amount, data); item = new ItemStack(mat, amount, data);
PotionMeta itemMeta = (PotionMeta) item.getItemMeta(); PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
@ -171,7 +167,7 @@ public class TreasureConfig extends BukkitConfig {
try { try {
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER")); potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
} catch (IllegalArgumentException ex) { } 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 extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false); boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
@ -210,49 +206,49 @@ public class TreasureConfig extends BukkitConfig {
} }
} }
if (noErrorsInConfig(reason)) { //TODO: Rewrite legacy validation code
if (isExcavation) { // Look into what needs to change for this
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel); if (isExcavation) {
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From"); ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
for (String blockType : dropList) { for (String blockType : dropList) {
if (!excavationMap.containsKey(blockType)) if (!excavationMap.containsKey(blockType))
excavationMap.put(blockType, new ArrayList<>()); excavationMap.put(blockType, new ArrayList<>());
excavationMap.get(blockType).add(excavationTreasure); excavationMap.get(blockType).add(excavationTreasure);
}
} else if (isHylian) {
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
for (String dropper : dropList) {
if (dropper.equals("Bushes")) {
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.FERN), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.TALL_GRASS), hylianTreasure);
for (Material species : Tag.SAPLINGS.getValues())
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DEAD_BUSH), hylianTreasure);
continue;
} }
} else if (isHylian) { if (dropper.equals("Flowers")) {
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel); AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.POPPY), hylianTreasure);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From"); AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DANDELION), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.BLUE_ORCHID), hylianTreasure);
for (String dropper : dropList) { AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.ALLIUM), hylianTreasure);
if (dropper.equals("Bushes")) { AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.AZURE_BLUET), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.FERN), hylianTreasure); AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.ORANGE_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.TALL_GRASS), hylianTreasure); AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.PINK_TULIP), hylianTreasure);
for (Material species : Tag.SAPLINGS.getValues()) AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.RED_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure); AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.WHITE_TULIP), hylianTreasure);
continue;
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DEAD_BUSH), hylianTreasure);
continue;
}
if (dropper.equals("Flowers")) {
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.POPPY), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DANDELION), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.BLUE_ORCHID), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.ALLIUM), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.AZURE_BLUET), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.ORANGE_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.PINK_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.RED_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.WHITE_TULIP), hylianTreasure);
continue;
}
if (dropper.equals("Pots")) {
for (Material species : Tag.FLOWER_POTS.getValues())
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure);
continue;
}
AddHylianTreasure(dropper, hylianTreasure);
} }
if (dropper.equals("Pots")) {
for (Material species : Tag.FLOWER_POTS.getValues())
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure);
continue;
}
AddHylianTreasure(dropper, hylianTreasure);
} }
} }
} }

View File

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

View File

@ -19,6 +19,12 @@ public class UpgradeManager extends BukkitConfig {
loadKeys(); 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. * Check if the given {@link UpgradeType} is necessary.
* *