updated listener

This commit is contained in:
sekwah 2018-02-22 02:59:12 +00:00 committed by Sekwah
parent b55952942a
commit bed94dc936

View File

@ -27,12 +27,13 @@ public class Listeners implements Listener {
@EventHandler @EventHandler
public void onItemInteract(PlayerInteractEvent event) { public void onItemInteract(PlayerInteractEvent event) {
if ((event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) && event.getItem() != null) { if (!event.isCancelled() && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) && event.getItem() != null) {
Location blockloc = event.getClickedBlock().getLocation(); Location blockloc = event.getClickedBlock().getLocation();
this.coreListeners.playerInteractWithBlock(new PlayerContainer(event.getPlayer()), event.getMaterial().toString(), boolean allowEvent = this.coreListeners.playerInteractWithBlock(new PlayerContainer(event.getPlayer()), event.getMaterial().toString(),
event.getItem().getItemMeta().getDisplayName(), event.getItem().getItemMeta().getDisplayName(),
new PortalLocation(blockloc.getWorld().getName(), blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ()), new PortalLocation(blockloc.getWorld().getName(), blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ()),
event.getAction() == Action.LEFT_CLICK_BLOCK); event.getAction() == Action.LEFT_CLICK_BLOCK);
event.setCancelled(!allowEvent);
} }
} }