From 2d1472b91361f51d2a34cc6ff45ffebd0957d1db Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 16 Jun 2019 05:17:12 -0700 Subject: [PATCH] Fix Blast Mining and /mining command --- Changelog.txt | 1 + .../mining/ConfigMiningBlastMining.java | 113 +++++++++++++++++- .../mining/ConfigMiningDoubleDrops.java | 7 ++ .../nossr50/skills/mining/BlastMining.java | 48 +------- .../nossr50/skills/mining/MiningManager.java | 9 +- 5 files changed, 126 insertions(+), 52 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 24e3337d3..7d2138fa9 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -42,6 +42,7 @@ Version 2.2.0 Fixed some tab completion bugs for /mcconvert command Nearby players using super abilities is now sent to your chat instead of the action bar by default Increased the default recipe cost for Chimaera Wing from 5 to 40 + Blast Mining Damage Decrease now scales more smoothly from ranks 1-8 Admins will now be notified if a player trips over-fishing exploit detection 3+ times in a row (Locale: "Fishing.OverFishingDetected") Note: Admins are players who are an operator or have adminchat permission. diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMiningBlastMining.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMiningBlastMining.java index 94d514bc4..352f3519d 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMiningBlastMining.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMiningBlastMining.java @@ -5,11 +5,17 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import org.bukkit.Material; import java.util.ArrayList; +import java.util.HashMap; @ConfigSerializable public class ConfigMiningBlastMining { - public static final ArrayList DETONATORS_DEFAULT; + private static final ArrayList DETONATORS_DEFAULT; + private static final HashMap DAMAGE_DECREASE_RANK_MAP; + private static final HashMap OREBONUS_RANK_MAP; + private static final HashMap DEBRIS_REDUCTION_MAP; + private static final HashMap DROP_MULTIPLIER_MAP; + private static final HashMap RADIUS_MAP; static { DETONATORS_DEFAULT = new ArrayList<>(); @@ -18,12 +24,117 @@ public class ConfigMiningBlastMining { DETONATORS_DEFAULT.add(Material.GOLDEN_PICKAXE.getKey().toString()); DETONATORS_DEFAULT.add(Material.IRON_PICKAXE.getKey().toString()); DETONATORS_DEFAULT.add(Material.WOODEN_PICKAXE.getKey().toString()); + + DAMAGE_DECREASE_RANK_MAP = new HashMap<>(); + DAMAGE_DECREASE_RANK_MAP.put(1, 5.0); + DAMAGE_DECREASE_RANK_MAP.put(2, 10.0); + DAMAGE_DECREASE_RANK_MAP.put(3, 15.0); + DAMAGE_DECREASE_RANK_MAP.put(4, 25.0); + DAMAGE_DECREASE_RANK_MAP.put(5, 35.0); + DAMAGE_DECREASE_RANK_MAP.put(6, 50.0); + DAMAGE_DECREASE_RANK_MAP.put(7, 75.0); + DAMAGE_DECREASE_RANK_MAP.put(8, 100.0); + + OREBONUS_RANK_MAP = new HashMap<>(); + OREBONUS_RANK_MAP.put(1, 35.0); + OREBONUS_RANK_MAP.put(2, 40.0); + OREBONUS_RANK_MAP.put(3, 45.0); + OREBONUS_RANK_MAP.put(4, 50.0); + OREBONUS_RANK_MAP.put(5, 55.0); + OREBONUS_RANK_MAP.put(6, 60.0); + OREBONUS_RANK_MAP.put(7, 65.0); + OREBONUS_RANK_MAP.put(8, 70.0); + + DEBRIS_REDUCTION_MAP = new HashMap<>(); + DEBRIS_REDUCTION_MAP.put(1, 5.0); + DEBRIS_REDUCTION_MAP.put(2, 10.0); + DEBRIS_REDUCTION_MAP.put(3, 15.0); + DEBRIS_REDUCTION_MAP.put(4, 20.0); + DEBRIS_REDUCTION_MAP.put(5, 25.0); + DEBRIS_REDUCTION_MAP.put(6, 30.0); + DEBRIS_REDUCTION_MAP.put(7, 35.0); + DEBRIS_REDUCTION_MAP.put(8, 40.0); + + DROP_MULTIPLIER_MAP = new HashMap<>(); + DROP_MULTIPLIER_MAP.put(1, 1); + DROP_MULTIPLIER_MAP.put(2, 1); + DROP_MULTIPLIER_MAP.put(3, 1); + DROP_MULTIPLIER_MAP.put(4, 1); + DROP_MULTIPLIER_MAP.put(5, 2); + DROP_MULTIPLIER_MAP.put(6, 2); + DROP_MULTIPLIER_MAP.put(7, 3); + DROP_MULTIPLIER_MAP.put(8, 3); + + RADIUS_MAP = new HashMap<>(); + RADIUS_MAP.put(1, 1.0); + RADIUS_MAP.put(2, 1.0); + RADIUS_MAP.put(3, 2.0); + RADIUS_MAP.put(4, 2.0); + RADIUS_MAP.put(5, 3.0); + RADIUS_MAP.put(6, 3.0); + RADIUS_MAP.put(7, 4.0); + RADIUS_MAP.put(8, 4.0); } @Setting(value = "Detonators", comment = "Items that can be used to activate Blast-Mining") private ArrayList detonators = DETONATORS_DEFAULT; + @Setting(value = "Damage-Decrease-Per-Rank") + private HashMap damageDecreaseMap = DAMAGE_DECREASE_RANK_MAP; + + @Setting(value = "Ore-Bonus-Per-Rank") + private HashMap orebonusMap = OREBONUS_RANK_MAP; + + @Setting(value = "Debris-Decrease-Per-Rank") + private HashMap debrisReductionMap = DEBRIS_REDUCTION_MAP; + + @Setting(value = "Radius-Increase-Per-Rank") + private HashMap radiusMap = RADIUS_MAP; + + @Setting(value = "Drop-Multiplier-Per-Rank") + private HashMap dropMultiplierMap = DROP_MULTIPLIER_MAP; + public ArrayList getDetonators() { return detonators; } + + public double getDamageDecrease(int rank) { + return damageDecreaseMap.get(rank); + } + + public double getOreBonus(int rank) { + return orebonusMap.get(rank); + } + + public double getDebrisReduction(int rank) { + return debrisReductionMap.get(rank); + } + + public double getRadius(int rank) { + return radiusMap.get(rank); + } + + public int getDropMultiplier(int rank) { + return dropMultiplierMap.get(rank); + } + + public HashMap getDamageDecreaseMap() { + return damageDecreaseMap; + } + + public HashMap getOrebonusMap() { + return orebonusMap; + } + + public HashMap getDebrisReductionMap() { + return debrisReductionMap; + } + + public HashMap getRadiusMap() { + return radiusMap; + } + + public HashMap getDropMultiplierMap() { + return dropMultiplierMap; + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMiningDoubleDrops.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMiningDoubleDrops.java index 67cf9cd8e..e580c52eb 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMiningDoubleDrops.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMiningDoubleDrops.java @@ -13,4 +13,11 @@ public class ConfigMiningDoubleDrops { @Setting(value = ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME) private MaxBonusLevel maxBonusLevel = new AbstractMaxBonusLevel(100); + + @Setting(value = "Silk-Touch-Double-Drops", comment = "Allow silk touch to benefit from double drops.") + private boolean allowSilkTouchDoubleDrops = true; + + public boolean isAllowSilkTouchDoubleDrops() { + return allowSilkTouchDoubleDrops; + } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java index 82d643620..b4bf56553 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.mining; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; @@ -12,55 +11,20 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; public class BlastMining { - // The order of the values is extremely important, a few methods depend on it to work properly - /* public enum Tier { - EIGHT(8), - SEVEN(7), - SIX(6), - FIVE(5), - FOUR(4), - THREE(3), - TWO(2), - ONE(1); - - int numerical; - - private Tier(int numerical) { - this.numerical = numerical; - } - - public int toNumerical() { - return numerical; - } - - protected int getLevel() { - return AdvancedConfig.getInstance().getBlastMiningRankLevel(this); - } - - - }*/ public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100; public static double getBlastRadiusModifier(int rank) { - return AdvancedConfig.getInstance().getBlastRadiusModifier(rank); + return mcMMO.getConfigManager().getConfigMining().getBlastMining().getRadius(rank); } public static double getBlastDamageDecrease(int rank) { - return AdvancedConfig.getInstance().getBlastDamageDecrease(rank); + return mcMMO.getConfigManager().getConfigMining().getBlastMining().getDamageDecrease(rank); } public static int getDemolitionExpertUnlockLevel() { - /*List tierList = Arrays.asList(Tier.values()); - for (Tier tier : tierList) { - if (tier.getBlastDamageDecrease() > 0) { - continue; - } - - return tier == Tier.EIGHT ? tier.getLevel() : tierList.get(tierList.indexOf(tier) - 1).getLevel(); - }*/ for (int i = 0; i < SubSkillType.MINING_BLAST_MINING.getNumRanks() - 1; i++) { if (getBlastDamageDecrease(i + 1) > 0) @@ -71,14 +35,6 @@ public class BlastMining { } public static int getBiggerBombsUnlockLevel() { - /*List tierList = Arrays.asList(Tier.values()); - for (Tier tier : tierList) { - if (tier.getBlastRadiusModifier() > 1.0) { - continue; - } - - return tier == Tier.EIGHT ? tier.getLevel() : tierList.get(tierList.indexOf(tier) - 1).getLevel(); - }*/ for (int i = 0; i < SubSkillType.MINING_BLAST_MINING.getNumRanks() - 1; i++) { if (getBlastRadiusModifier(i + 1) > 0) diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index d9498e2bb..55d897920 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.mining; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.interactions.NotificationType; @@ -35,15 +34,15 @@ public class MiningManager extends SkillManager { } public static double getOreBonus(int rank) { - return AdvancedConfig.getInstance().getOreBonus(rank); + return mcMMO.getConfigManager().getConfigMining().getBlastMining().getOreBonus(rank); } public static double getDebrisReduction(int rank) { - return AdvancedConfig.getInstance().getDebrisReduction(rank); + return mcMMO.getConfigManager().getConfigMining().getBlastMining().getDebrisReduction(rank); } public static int getDropMultiplier(int rank) { - return AdvancedConfig.getInstance().getDropMultiplier(rank); + return mcMMO.getConfigManager().getConfigMining().getBlastMining().getDropMultiplier(rank); } public boolean canUseDemolitionsExpertise() { @@ -97,7 +96,7 @@ public class MiningManager extends SkillManager { boolean silkTouch = player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH); - if (silkTouch && !AdvancedConfig.getInstance().getDoubleDropSilkTouchEnabled()) + if (silkTouch && !mcMMO.getConfigManager().getConfigMining().getMiningSubskills().getDoubleDrops().isAllowSilkTouchDoubleDrops()) return; //TODO: Make this readable