Fire UseItemEvent when fishing rod is cast.

This apparently no longer throws an interact.

Fixes WORLDGUARD-4018.
This commit is contained in:
wizjany 2019-02-25 23:46:31 -05:00
parent a233be1df8
commit 090a00d6d8

View File

@ -679,7 +679,12 @@ public void onBlockExp(BlockExpEvent event) {
@EventHandler(ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) {
if (event.getState() == PlayerFishEvent.State.CAUGHT_FISH) {
if (event.getState() == PlayerFishEvent.State.FISHING) {
if (Events.fireAndTestCancel(new UseItemEvent(event, create(event.getPlayer(), event.getHook()),
event.getPlayer().getWorld(), event.getPlayer().getInventory().getItemInMainHand()))) {
event.setCancelled(true);
}
} else if (event.getState() == PlayerFishEvent.State.CAUGHT_FISH) {
if (Events.fireAndTestCancel(new SpawnEntityEvent(event, create(event.getPlayer(), event.getHook()), event.getHook().getLocation(), EntityType.EXPERIENCE_ORB))) {
event.setExpToDrop(0);
}