From e3e400f37627ddc17c21b63042be4240c4182292 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 3 Jun 2012 14:38:33 -0700 Subject: [PATCH] This should make us AntiCheat friendly. --- Changelog.txt | 1 + .../nossr50/events/fake/FakeBlockBreakEvent.java | 2 +- .../nossr50/events/fake/FakeBlockDamageEvent.java | 14 ++++++++++++++ src/main/java/com/gmail/nossr50/util/Misc.java | 14 ++++++++------ 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/events/fake/FakeBlockDamageEvent.java diff --git a/Changelog.txt b/Changelog.txt index 2275a95c8..75bee4dd8 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,6 +8,7 @@ Key: - Removal Version 1.3.09 + + Added compatibility with AntiCheat (Which I highly recommend to prevent cheating) + Added several permission nodes to give individual users special perks (Double/Triple/Quadruple XP) + Added API for plugins to add custom tools directly via Spout = Fixed issue with NoCheatPlus and Serrated Strikes / Skull Splitter (fight.noswing) diff --git a/src/main/java/com/gmail/nossr50/events/fake/FakeBlockBreakEvent.java b/src/main/java/com/gmail/nossr50/events/fake/FakeBlockBreakEvent.java index cdccfb07e..0a81eab92 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakeBlockBreakEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeBlockBreakEvent.java @@ -12,4 +12,4 @@ public class FakeBlockBreakEvent extends BlockBreakEvent { public FakeBlockBreakEvent(Block theBlock, Player player) { super(theBlock, player); } -} +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/events/fake/FakeBlockDamageEvent.java b/src/main/java/com/gmail/nossr50/events/fake/FakeBlockDamageEvent.java new file mode 100644 index 000000000..1de98ce03 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeBlockDamageEvent.java @@ -0,0 +1,14 @@ +package com.gmail.nossr50.events.fake; + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.inventory.ItemStack; + +public class FakeBlockDamageEvent extends BlockDamageEvent { + + public FakeBlockDamageEvent(Player player, Block block, + ItemStack itemInHand, boolean instaBreak) { + super(player, block, itemInHand, instaBreak); + } +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index 7c8be0be2..aad6c163b 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -13,6 +13,7 @@ import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; +import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; import com.gmail.nossr50.events.items.McMMOItemSpawnEvent; @@ -110,14 +111,15 @@ public class Misc { FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player); mcMMO.p.getServer().getPluginManager().callEvent(armswing); } + + FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getItemInHand(), true); + mcMMO.p.getServer().getPluginManager().callEvent(damageEvent); + FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player); + mcMMO.p.getServer().getPluginManager().callEvent(breakEvent); - FakeBlockBreakEvent event = new FakeBlockBreakEvent(block, player); - mcMMO.p.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { + if (!damageEvent.isCancelled() || !breakEvent.isCancelled()) { return true; - } - else { + } else { return false; } }