From f481741bb5892ef2d6ed96da1808afc740077e0c Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 25 Feb 2012 04:27:09 -0800 Subject: [PATCH] This should make us fully NoCheat compatible. --- .../nossr50/listeners/mcBlockListener.java | 17 +++++++---------- .../nossr50/listeners/mcPlayerListener.java | 2 +- src/main/java/com/gmail/nossr50/m.java | 10 +++++++++- .../com/gmail/nossr50/skills/WoodCutting.java | 6 +----- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java index e7a584420..2188c7f24 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java @@ -25,7 +25,6 @@ import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; @@ -37,7 +36,6 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.inventory.ItemStack; import org.getspout.spoutapi.SpoutManager; @@ -86,7 +84,8 @@ public class mcBlockListener implements Listener //Only needed for blocks that use their block data (wood, pumpkins, etc.) boolean shouldBeChanged = true; - switch(mat){ + switch(mat) + { case CACTUS: case GLOWING_REDSTONE_ORE: case JACK_O_LANTERN: @@ -95,7 +94,7 @@ public class mcBlockListener implements Listener case REDSTONE_ORE: case SUGAR_CANE_BLOCK: case VINE: - shouldBeChanged = false; + shouldBeChanged = false; //We don't want these added to changeQueue plugin.misc.blockWatchList.add(block); break; case BROWN_MUSHROOM: @@ -251,7 +250,7 @@ public class mcBlockListener implements Listener /* * GIGA DRILL BREAKER CHECKS */ - if(PP.getGigaDrillBreakerMode() && Excavation.canBeGigaDrillBroken(block) && m.blockBreakSimulate(block, player) && mcPermissions.getInstance().excavationAbility(player)) + if(PP.getGigaDrillBreakerMode() && Excavation.canBeGigaDrillBroken(block) && m.blockBreakSimulate(block, player, true) && mcPermissions.getInstance().excavationAbility(player)) { if(LoadProperties.excavationRequiresShovel && m.isShovel(inhand)) { @@ -278,14 +277,12 @@ public class mcBlockListener implements Listener * BERSERK MODE CHECKS */ if(PP.getBerserkMode() - && m.blockBreakSimulate(block, player) + && m.blockBreakSimulate(block, player, true) && player.getItemInHand().getTypeId() == 0 && (Excavation.canBeGigaDrillBroken(block) || id == 78) && mcPermissions.getInstance().unarmedAbility(player)) { event.setInstaBreak(true); - PlayerAnimationEvent armswing = new PlayerAnimationEvent(player); - Bukkit.getPluginManager().callEvent(armswing); if(LoadProperties.spoutEnabled) SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); @@ -296,7 +293,7 @@ public class mcBlockListener implements Listener */ if(PP.getSuperBreakerMode() && Mining.canBeSuperBroken(block) - && m.blockBreakSimulate(block, player) + && m.blockBreakSimulate(block, player, true) && mcPermissions.getInstance().miningAbility(player)) { if(LoadProperties.miningrequirespickaxe) @@ -328,7 +325,7 @@ public class mcBlockListener implements Listener if(id == 18 && mcPermissions.getInstance().woodcutting(player) && PP.getSkillLevel(SkillType.WOODCUTTING) >= 100 - && m.blockBreakSimulate(block, player)) + && m.blockBreakSimulate(block, player, true)) { if(LoadProperties.woodcuttingrequiresaxe) { diff --git a/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java index 21224de7c..afd6ea353 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java @@ -260,7 +260,7 @@ public class mcPlayerListener implements Listener if(block.getType() == Material.DIRT || block.getType() == Material.COBBLESTONE || block.getType() == Material.SMOOTH_BRICK) { - if(Math.random() * 1500 <= PP.getSkillLevel(SkillType.HERBALISM) && m.blockBreakSimulate(block, player)) + if(Math.random() * 1500 <= PP.getSkillLevel(SkillType.HERBALISM) && m.blockBreakSimulate(block, player, false)) { switch(block.getType()) { diff --git a/src/main/java/com/gmail/nossr50/m.java b/src/main/java/com/gmail/nossr50/m.java index f3b2a6963..df6359c36 100644 --- a/src/main/java/com/gmail/nossr50/m.java +++ b/src/main/java/com/gmail/nossr50/m.java @@ -26,6 +26,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.*; +import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.*; import com.gmail.nossr50.datatypes.PlayerProfile; @@ -149,8 +150,15 @@ public class m return x; } - public static boolean blockBreakSimulate(Block block, Player player) + public static boolean blockBreakSimulate(Block block, Player player, Boolean shouldArmSwing) { + //Support for NoCheat + if(shouldArmSwing) + { + PlayerAnimationEvent armswing = new PlayerAnimationEvent(player); + Bukkit.getPluginManager().callEvent(armswing); + } + FakeBlockBreakEvent event = new FakeBlockBreakEvent(block, player); if(block != null && player != null){ Bukkit.getServer().getPluginManager().callEvent(event); diff --git a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java index 9b721a786..071875a41 100644 --- a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java @@ -75,11 +75,7 @@ public class WoodCutting for(Block x : toBeFelled) { - //Stupid NoCheat compatibility stuff - PlayerAnimationEvent armswing = new PlayerAnimationEvent(player); - Bukkit.getPluginManager().callEvent(armswing); - - if(m.blockBreakSimulate(x, player)) + if(m.blockBreakSimulate(x, player, true)) { if(x.getType() == Material.LOG) {