From 1e0739e73fe8f7ee0931a8ca591b2828e5e36a90 Mon Sep 17 00:00:00 2001 From: D3v1s0m Date: Sun, 13 Aug 2023 12:30:58 +0530 Subject: [PATCH] changed how action delay works --- .../interaction/InteractionPacketListener.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/interaction/InteractionPacketListener.java b/plugin/src/main/java/lol/pyr/znpcsplus/interaction/InteractionPacketListener.java index bf4736d..c27f3b6 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/interaction/InteractionPacketListener.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/interaction/InteractionPacketListener.java @@ -46,18 +46,11 @@ public class InteractionPacketListener implements PacketListener { Bukkit.getPluginManager().callEvent(interactEvent); if (interactEvent.isCancelled()) return; - scheduler.runSyncGlobal(() -> { - for (InteractionAction action : npc.getActions()) { - if (action.getInteractionType() != InteractionType.ANY_CLICK && action.getInteractionType() != type) continue; - if (action.getCooldown() > 0 && !user.actionCooldownCheck(action)) continue; - action.run(user.getPlayer()); - try { - Thread.sleep(action.getDelay()); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); + for (InteractionAction action : npc.getActions()) { + if (action.getInteractionType() != InteractionType.ANY_CLICK && action.getInteractionType() != type) continue; + if (action.getCooldown() > 0 && !user.actionCooldownCheck(action)) continue; + scheduler.runLaterAsync(() -> action.run(player), action.getDelay()); + } } private InteractionType wrapClickType(WrapperPlayClientInteractEntity.InteractAction action) {