diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index af69d5f1b..b3cdc7b2e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -34,7 +34,7 @@ import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.smelting.SmeltingManager; -import com.gmail.nossr50.skills.unarmed.Unarmed; +import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.ItemUtils; @@ -354,8 +354,10 @@ public class BlockListener implements Listener { } } // Another perm check for the cracked blocks activation - else if (BlockUtils.affectedByBlockCracker(blockState) && Permissions.blockCracker(player)) { - if (Unarmed.blockCracker(player, blockState)) { + else if (BlockUtils.affectedByBlockCracker(blockState)) { + UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager(); + + if (unarmedManager.canUseBlockCracker() && SkillUtils.blockBreakSimulate(block, player, false) && unarmedManager.blockCrackerCheck(blockState)) { blockState.update(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java index 2078bfb9f..d33f3089d 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java @@ -1,12 +1,7 @@ package com.gmail.nossr50.skills.unarmed; -import org.bukkit.Material; -import org.bukkit.block.BlockState; -import org.bukkit.entity.Player; - import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.util.skills.SkillUtils; public class Unarmed { public static int ironArmMaxBonusDamage = AdvancedConfig.getInstance().getIronArmMaxBonus(); @@ -24,23 +19,4 @@ public class Unarmed { public static boolean blockCrackerSmoothBrick = Config.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked(); public static double berserkDamageModifier = 1.5; - - public static boolean blockCracker(Player player, BlockState blockState) { - if (SkillUtils.blockBreakSimulate(blockState.getBlock(), player, false)) { - Material type = blockState.getType(); - - switch (type) { - case SMOOTH_BRICK: - if (blockCrackerSmoothBrick && blockState.getRawData() == (byte) 0x0) { - blockState.setRawData((byte) 0x2); - } - return true; - - default: - return false; - } - } - - return false; - } } diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index 101aa45de..631092193 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.skills.unarmed; import org.bukkit.Material; +import org.bukkit.block.BlockState; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -44,6 +45,25 @@ public class UnarmedManager extends SkillManager { return player.getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect(player); } + public boolean canUseBlockCracker() { + return Permissions.blockCracker(getPlayer()); + } + + public boolean blockCrackerCheck(BlockState blockState) { + Material type = blockState.getType(); + + switch (type) { + case SMOOTH_BRICK: + if (Unarmed.blockCrackerSmoothBrick && blockState.getRawData() == (byte) 0x0) { + blockState.setRawData((byte) 0x2); + } + return true; + + default: + return false; + } + } + /** * Check for disarm. *