Fix Blast Mining and /mining command

This commit is contained in:
nossr50 2019-06-16 05:17:12 -07:00
parent a1e3bb18a4
commit 2d1472b913
5 changed files with 126 additions and 52 deletions

View File

@ -42,6 +42,7 @@ Version 2.2.0
Fixed some tab completion bugs for /mcconvert command 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 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 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") 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. Note: Admins are players who are an operator or have adminchat permission.

View File

@ -5,11 +5,17 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import org.bukkit.Material; import org.bukkit.Material;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
@ConfigSerializable @ConfigSerializable
public class ConfigMiningBlastMining { public class ConfigMiningBlastMining {
public static final ArrayList<String> DETONATORS_DEFAULT; private static final ArrayList<String> DETONATORS_DEFAULT;
private static final HashMap<Integer, Double> DAMAGE_DECREASE_RANK_MAP;
private static final HashMap<Integer, Double> OREBONUS_RANK_MAP;
private static final HashMap<Integer, Double> DEBRIS_REDUCTION_MAP;
private static final HashMap<Integer, Integer> DROP_MULTIPLIER_MAP;
private static final HashMap<Integer, Double> RADIUS_MAP;
static { static {
DETONATORS_DEFAULT = new ArrayList<>(); DETONATORS_DEFAULT = new ArrayList<>();
@ -18,12 +24,117 @@ public class ConfigMiningBlastMining {
DETONATORS_DEFAULT.add(Material.GOLDEN_PICKAXE.getKey().toString()); DETONATORS_DEFAULT.add(Material.GOLDEN_PICKAXE.getKey().toString());
DETONATORS_DEFAULT.add(Material.IRON_PICKAXE.getKey().toString()); DETONATORS_DEFAULT.add(Material.IRON_PICKAXE.getKey().toString());
DETONATORS_DEFAULT.add(Material.WOODEN_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") @Setting(value = "Detonators", comment = "Items that can be used to activate Blast-Mining")
private ArrayList<String> detonators = DETONATORS_DEFAULT; private ArrayList<String> detonators = DETONATORS_DEFAULT;
@Setting(value = "Damage-Decrease-Per-Rank")
private HashMap<Integer, Double> damageDecreaseMap = DAMAGE_DECREASE_RANK_MAP;
@Setting(value = "Ore-Bonus-Per-Rank")
private HashMap<Integer, Double> orebonusMap = OREBONUS_RANK_MAP;
@Setting(value = "Debris-Decrease-Per-Rank")
private HashMap<Integer, Double> debrisReductionMap = DEBRIS_REDUCTION_MAP;
@Setting(value = "Radius-Increase-Per-Rank")
private HashMap<Integer, Double> radiusMap = RADIUS_MAP;
@Setting(value = "Drop-Multiplier-Per-Rank")
private HashMap<Integer, Integer> dropMultiplierMap = DROP_MULTIPLIER_MAP;
public ArrayList<String> getDetonators() { public ArrayList<String> getDetonators() {
return detonators; 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<Integer, Double> getDamageDecreaseMap() {
return damageDecreaseMap;
}
public HashMap<Integer, Double> getOrebonusMap() {
return orebonusMap;
}
public HashMap<Integer, Double> getDebrisReductionMap() {
return debrisReductionMap;
}
public HashMap<Integer, Double> getRadiusMap() {
return radiusMap;
}
public HashMap<Integer, Integer> getDropMultiplierMap() {
return dropMultiplierMap;
}
} }

View File

@ -13,4 +13,11 @@ public class ConfigMiningDoubleDrops {
@Setting(value = ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME) @Setting(value = ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME)
private MaxBonusLevel maxBonusLevel = new AbstractMaxBonusLevel(100); 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;
}
} }

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.skills.mining; package com.gmail.nossr50.skills.mining;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@ -12,55 +11,20 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
public class BlastMining { 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 final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
public static double getBlastRadiusModifier(int rank) { public static double getBlastRadiusModifier(int rank) {
return AdvancedConfig.getInstance().getBlastRadiusModifier(rank); return mcMMO.getConfigManager().getConfigMining().getBlastMining().getRadius(rank);
} }
public static double getBlastDamageDecrease(int rank) { public static double getBlastDamageDecrease(int rank) {
return AdvancedConfig.getInstance().getBlastDamageDecrease(rank); return mcMMO.getConfigManager().getConfigMining().getBlastMining().getDamageDecrease(rank);
} }
public static int getDemolitionExpertUnlockLevel() { public static int getDemolitionExpertUnlockLevel() {
/*List<Tier> 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++) { for (int i = 0; i < SubSkillType.MINING_BLAST_MINING.getNumRanks() - 1; i++) {
if (getBlastDamageDecrease(i + 1) > 0) if (getBlastDamageDecrease(i + 1) > 0)
@ -71,14 +35,6 @@ public class BlastMining {
} }
public static int getBiggerBombsUnlockLevel() { public static int getBiggerBombsUnlockLevel() {
/*List<Tier> 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++) { for (int i = 0; i < SubSkillType.MINING_BLAST_MINING.getNumRanks() - 1; i++) {
if (getBlastRadiusModifier(i + 1) > 0) if (getBlastRadiusModifier(i + 1) > 0)

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.skills.mining; package com.gmail.nossr50.skills.mining;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
@ -35,15 +34,15 @@ public class MiningManager extends SkillManager {
} }
public static double getOreBonus(int rank) { public static double getOreBonus(int rank) {
return AdvancedConfig.getInstance().getOreBonus(rank); return mcMMO.getConfigManager().getConfigMining().getBlastMining().getOreBonus(rank);
} }
public static double getDebrisReduction(int 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) { public static int getDropMultiplier(int rank) {
return AdvancedConfig.getInstance().getDropMultiplier(rank); return mcMMO.getConfigManager().getConfigMining().getBlastMining().getDropMultiplier(rank);
} }
public boolean canUseDemolitionsExpertise() { public boolean canUseDemolitionsExpertise() {
@ -97,7 +96,7 @@ public class MiningManager extends SkillManager {
boolean silkTouch = player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH); boolean silkTouch = player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH);
if (silkTouch && !AdvancedConfig.getInstance().getDoubleDropSilkTouchEnabled()) if (silkTouch && !mcMMO.getConfigManager().getConfigMining().getMiningSubskills().getDoubleDrops().isAllowSilkTouchDoubleDrops())
return; return;
//TODO: Make this readable //TODO: Make this readable