Move break event to the initial check.

This commit is contained in:
GJ 2013-07-29 08:29:10 -04:00
parent f5c58f3679
commit 09e77c8c94
2 changed files with 11 additions and 8 deletions

View File

@ -222,13 +222,6 @@ public class PlayerListener implements Listener {
Block block = player.getTargetBlock(null, 100); Block block = player.getTargetBlock(null, 100);
if (fishingManager.canIceFish(block)) { if (fishingManager.canIceFish(block)) {
FakeBlockBreakEvent blockBreakEvent = new FakeBlockBreakEvent(block, player);
plugin.getServer().getPluginManager().callEvent(blockBreakEvent);
if (blockBreakEvent.isCancelled()) {
return;
}
event.setCancelled(true); event.setCancelled(true);
fishingManager.iceFishing(event.getHook(), block); fishingManager.iceFishing(event.getHook(), block);
} }

View File

@ -38,6 +38,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure; import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; 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.fake.FakePlayerFishEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
@ -188,7 +189,16 @@ public class FishingManager extends SkillManager {
return false; 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();
} }
/** /**