From bd497a5e7f18ffcf6907a3f4ab38a18b1cf7527d Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Thu, 1 Feb 2018 21:49:47 +0000 Subject: [PATCH] Updating permissions and such --- .../sekwah/advancedportals/spigot/Listeners.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/com/sekwah/advancedportals/spigot/Listeners.java b/src/com/sekwah/advancedportals/spigot/Listeners.java index 6c5dcfc7..57bb9a10 100644 --- a/src/com/sekwah/advancedportals/spigot/Listeners.java +++ b/src/com/sekwah/advancedportals/spigot/Listeners.java @@ -1,9 +1,13 @@ package com.sekwah.advancedportals.spigot; import com.sekwah.advancedportals.core.CoreListeners; +import com.sekwah.advancedportals.core.data.PortalLocation; import com.sekwah.advancedportals.coreconnector.container.PlayerContainer; +import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; public class Listeners implements Listener { @@ -21,4 +25,15 @@ public class Listeners implements Listener { coreListeners.playerJoin(new PlayerContainer(event.getPlayer())); } + @EventHandler + public void onItemInteract(PlayerInteractEvent event) { + if ((event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) && event.getItem() != null) { + Location blockloc = event.getClickedBlock().getLocation(); + this.coreListeners.playerInteractWithBlock(new PlayerContainer(event.getPlayer()), event.getMaterial().toString(), + event.getItem().getItemMeta().getDisplayName(), + new PortalLocation(blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ()), + event.getAction() == Action.LEFT_CLICK_BLOCK); + } + } + }