diff --git a/Changelog.txt b/Changelog.txt index 828303cfc..a129367b6 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -84,6 +84,7 @@ Version 2.2.0 Super Ability conifg options will now be found in "skill_super_abilities.conf" Super Abilities now have a default max length cap of one minute Blast Mining default cooldown increased from 60 seconds to 120 seconds + You can now configure multiple items as detonators for Blast Mining Exploit related config options will now be found in "exploit-prevention" Exploit Prevention's "EndermanEndermiteFarms" renamed -> "Endermen-Endermite-Fix" diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMining.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMining.java index ce4b4e5b3..3a7c7c592 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMining.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMining.java @@ -48,7 +48,24 @@ public class ConfigMining { "\nUse Minecraft friendly names for entries, not Bukkit material names.") private ArrayList bonusDrops = DEFAULT_BONUS_DROPS; + @Setting(value = "Sub-Skills") + private ConfigMiningSubskills miningSubskills = new ConfigMiningSubskills(); + + public ConfigMiningSubskills getMiningSubskills() { + return miningSubskills; + } + + public ConfigMiningBlastMining getBlastMining() { + return miningSubskills.getBlastMining(); + } + + public ArrayList getDetonators() { + return getBlastMining().getDetonators(); + } + public ArrayList getBonusDrops() { return bonusDrops; } + + } \ No newline at end of file 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 new file mode 100644 index 000000000..94d514bc4 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMiningBlastMining.java @@ -0,0 +1,29 @@ +package com.gmail.nossr50.config.hocon.skills.mining; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; +import org.bukkit.Material; + +import java.util.ArrayList; + +@ConfigSerializable +public class ConfigMiningBlastMining { + + public static final ArrayList DETONATORS_DEFAULT; + + static { + DETONATORS_DEFAULT = new ArrayList<>(); + DETONATORS_DEFAULT.add(Material.FLINT_AND_STEEL.getKey().toString()); + DETONATORS_DEFAULT.add(Material.DIAMOND_PICKAXE.getKey().toString()); + DETONATORS_DEFAULT.add(Material.GOLDEN_PICKAXE.getKey().toString()); + DETONATORS_DEFAULT.add(Material.IRON_PICKAXE.getKey().toString()); + DETONATORS_DEFAULT.add(Material.WOODEN_PICKAXE.getKey().toString()); + } + + @Setting(value = "Detonators", comment = "Items that can be used to activate Blast-Mining") + private ArrayList detonators = DETONATORS_DEFAULT; + + public ArrayList getDetonators() { + return detonators; + } +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMiningSubskills.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMiningSubskills.java new file mode 100644 index 000000000..115ae0e09 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/mining/ConfigMiningSubskills.java @@ -0,0 +1,15 @@ +package com.gmail.nossr50.config.hocon.skills.mining; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigMiningSubskills { + + @Setting(value = "Blast-Mining", comment = "Settings for Blast Mining") + public ConfigMiningBlastMining blastMining = new ConfigMiningBlastMining(); + + public ConfigMiningBlastMining getBlastMining() { + return blastMining; + } +} \ No newline at end of file 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 36112ca66..9fe836b00 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java @@ -41,8 +41,6 @@ public class BlastMining { }*/ - public static Material detonator = MainConfig.getInstance().getDetonatorItem(); - public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100; public static double getBlastRadiusModifier(int rank) { diff --git a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java index 262eb79c6..572efb4f5 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java @@ -2,13 +2,51 @@ package com.gmail.nossr50.skills.mining; import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; +import net.royawesome.jlibnoise.module.combiner.Min; import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.inventory.ItemStack; +import java.util.List; + public class Mining { + private List detonators; + private static Mining instance; + + public static Mining getInstance() { + if(instance == null) + instance = new Mining(); + + return instance; + } + + public Mining() { + //Init detonators + this.detonators = ItemUtils.matchMaterials(mcMMO.getConfigManager().getConfigMining().getDetonators()); + } + + /** + * Retrieve a list of Blast Mining detonator types + * @return blast mining detonator materials + */ + public List getDetonators() { + return detonators; + } + + /** + * Check if an itemStack is a valid blast mining detonator + * @param itemStack target itemstack + * @return true if valid blast mining detonator + */ + public Boolean isDetonator(ItemStack itemStack) + { + return getDetonators().contains(itemStack.getType()); + } + /** * Calculate XP gain for Mining. * 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 817158645..6301798bb 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -43,7 +43,7 @@ public class MiningManager extends SkillManager { Player player = getPlayer(); return canUseBlastMining() && player.isSneaking() - && (ItemUtils.isPickaxe(getPlayer().getInventory().getItemInMainHand()) || player.getInventory().getItemInMainHand().getType() == Config.getInstance().getDetonatorItem()) + && Mining.getInstance().isDetonator(player.getInventory().getItemInMainHand()) && Permissions.remoteDetonation(player); }