From 09e77c8c94841b86fac4a9467b77fa16624a98b5 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 29 Jul 2013 08:29:10 -0400 Subject: [PATCH] Move break event to the initial check. --- .../com/gmail/nossr50/listeners/PlayerListener.java | 7 ------- .../gmail/nossr50/skills/fishing/FishingManager.java | 12 +++++++++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index ed127c09d..70d15e79e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -222,13 +222,6 @@ public class PlayerListener implements Listener { Block block = player.getTargetBlock(null, 100); if (fishingManager.canIceFish(block)) { - FakeBlockBreakEvent blockBreakEvent = new FakeBlockBreakEvent(block, player); - plugin.getServer().getPluginManager().callEvent(blockBreakEvent); - - if (blockBreakEvent.isCancelled()) { - return; - } - event.setCancelled(true); fishingManager.iceFishing(event.getHook(), block); } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index debe81cd2..6ae459fd5 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -38,6 +38,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.treasure.FishingTreasure; import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; +import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.events.fake.FakePlayerFishEvent; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent; @@ -188,7 +189,16 @@ public class FishingManager extends SkillManager { return false; } - return Permissions.iceFishing(getPlayer()); + Player player = getPlayer(); + + if (!Permissions.iceFishing(player)) { + return false; + } + + FakeBlockBreakEvent blockBreakEvent = new FakeBlockBreakEvent(block, player); + mcMMO.p.getServer().getPluginManager().callEvent(blockBreakEvent); + + return !blockBreakEvent.isCancelled(); } /**