diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index fa12fe770..4e85d3679 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -16,6 +16,7 @@ import com.gmail.nossr50.skills.misc.Repair; import com.gmail.nossr50.spout.SpoutSounds; import com.gmail.nossr50.util.BlockChecks; import com.gmail.nossr50.util.ItemChecks; +import com.gmail.nossr50.util.ModChecks; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Skills; import com.gmail.nossr50.util.Users; @@ -185,7 +186,14 @@ public class BlockListener implements Listener { } if (PP.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.getInstance().treeFeller(player) && ItemChecks.isAxe(inhand)) { - WoodCutting.treeFeller(event); + if (Config.getInstance().getToolModsEnabled()) { + if ((ItemChecks.isCustomTool(inhand) && ModChecks.toolAbilityEnabled(inhand)) || !ItemChecks.isCustomTool(inhand)) { + WoodCutting.treeFeller(event); + } + } + else { + WoodCutting.treeFeller(event); + } } /* @@ -252,12 +260,27 @@ public class BlockListener implements Listener { * ABILITY TRIGGER CHECKS */ if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.getInstance().greenTerra(player) && BlockChecks.makeMossy(block)) { - Herbalism.greenTerra(player, block); + if (Config.getInstance().getToolModsEnabled()) { + if ((ItemChecks.isCustomTool(inhand) && ModChecks.toolAbilityEnabled(inhand)) || !ItemChecks.isCustomTool(inhand)) { + Herbalism.greenTerra(player, block); + } + } + else { + Herbalism.greenTerra(player, block); + } } else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) { if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) { - event.setInstaBreak(true); - Excavation.gigaDrillBreaker(player, block); + if (Config.getInstance().getToolModsEnabled()) { + if ((ItemChecks.isCustomTool(inhand) && ModChecks.toolAbilityEnabled(inhand)) || !ItemChecks.isCustomTool(inhand)) { + event.setInstaBreak(true); + Excavation.gigaDrillBreaker(player, block); + } + } + else { + event.setInstaBreak(true); + Excavation.gigaDrillBreaker(player, block); + } } else if (!Config.getInstance().getExcavationRequiresTool()) { event.setInstaBreak(true); @@ -277,10 +300,18 @@ public class BlockListener implements Listener { } } else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) { - if(!player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { + if (!player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { //TODO: Why are we checking this? if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isPickaxe(inhand)) { - event.setInstaBreak(true); - Mining.SuperBreakerBlockCheck(player, block); + if (Config.getInstance().getToolModsEnabled()) { + if ((ItemChecks.isCustomTool(inhand) && ModChecks.toolAbilityEnabled(inhand)) || !ItemChecks.isCustomTool(inhand)) { + event.setInstaBreak(true); + Mining.SuperBreakerBlockCheck(player, block); + } + } + else { + event.setInstaBreak(true); + Mining.SuperBreakerBlockCheck(player, block); + } } else if (!Config.getInstance().getMiningRequiresTool()) { event.setInstaBreak(true); diff --git a/src/main/java/com/gmail/nossr50/util/Combat.java b/src/main/java/com/gmail/nossr50/util/Combat.java index 63a913b96..64d4fac62 100644 --- a/src/main/java/com/gmail/nossr50/util/Combat.java +++ b/src/main/java/com/gmail/nossr50/util/Combat.java @@ -366,6 +366,14 @@ public class Combat { * @param type The type of skill being used */ private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) { + ItemStack inHand = attacker.getItemInHand(); + + if (Config.getInstance().getToolModsEnabled()) { + if (ItemChecks.isCustomTool(inHand) && !ModChecks.toolAbilityEnabled(inHand)) { + return; + } + } + int numberOfTargets = Misc.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit int damageAmount = damage; @@ -373,6 +381,7 @@ public class Combat { damageAmount = 1; } + //TODO: Looking at this, I think it's busted. Need to test to confirm. for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) { if (!(entity instanceof LivingEntity)) { continue; diff --git a/src/main/java/com/gmail/nossr50/util/ModChecks.java b/src/main/java/com/gmail/nossr50/util/ModChecks.java new file mode 100644 index 000000000..a5b8a5537 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/ModChecks.java @@ -0,0 +1,25 @@ +package com.gmail.nossr50.util; + +import org.bukkit.inventory.ItemStack; + +import com.gmail.nossr50.config.mods.LoadCustomTools; +import com.gmail.nossr50.datatypes.mods.CustomTool; + +public class ModChecks { + + /** + * Check if this custom tool can use abilities. + * + * @param item The custom item to check + * @return true if the tool can use abilities, false otherwise + */ + public static boolean toolAbilityEnabled(ItemStack item) { + for (CustomTool tool : LoadCustomTools.getInstance().customTools) { + if (tool.getItemID() == item.getTypeId()) { + return tool.isAbilityEnabled(); + } + } + + return false; + } +}