From e6752903b40718c1af41b142a36751388f37a6ba Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 16 Nov 2018 16:10:32 +1300 Subject: [PATCH] Call event in scheduler as listener is async --- .../packetlisteners/PacketListenerClientInteract.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packetlisteners/PacketListenerClientInteract.java b/src/main/java/me/libraryaddict/disguise/utilities/packetlisteners/PacketListenerClientInteract.java index c3032658..1b82e45a 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packetlisteners/PacketListenerClientInteract.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packetlisteners/PacketListenerClientInteract.java @@ -21,6 +21,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.*; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; public class PacketListenerClientInteract extends PacketAdapter { public PacketListenerClientInteract(LibsDisguises plugin) { @@ -69,7 +70,12 @@ public class PacketListenerClientInteract extends PacketAdapter { DisguiseInteractEvent selfEvent = new DisguiseInteractEvent((TargetedDisguise) disguise, handUsed, interactType == EnumWrappers.EntityUseAction.ATTACK); - Bukkit.getPluginManager().callEvent(selfEvent); + new BukkitRunnable() { + @Override + public void run() { + Bukkit.getPluginManager().callEvent(selfEvent); + } + }.runTask(LibsDisguises.getInstance()); } }