changed how action delay works

This commit is contained in:
D3v1s0m 2023-08-13 12:30:58 +05:30
parent 12e2c2963d
commit 1e0739e73f
No known key found for this signature in database
GPG Key ID: FA1F770C7B1D40C1

@ -46,19 +46,12 @@ public class InteractionPacketListener implements PacketListener {
Bukkit.getPluginManager().callEvent(interactEvent); Bukkit.getPluginManager().callEvent(interactEvent);
if (interactEvent.isCancelled()) return; if (interactEvent.isCancelled()) return;
scheduler.runSyncGlobal(() -> {
for (InteractionAction action : npc.getActions()) { for (InteractionAction action : npc.getActions()) {
if (action.getInteractionType() != InteractionType.ANY_CLICK && action.getInteractionType() != type) continue; if (action.getInteractionType() != InteractionType.ANY_CLICK && action.getInteractionType() != type) continue;
if (action.getCooldown() > 0 && !user.actionCooldownCheck(action)) continue; if (action.getCooldown() > 0 && !user.actionCooldownCheck(action)) continue;
action.run(user.getPlayer()); scheduler.runLaterAsync(() -> action.run(player), action.getDelay());
try {
Thread.sleep(action.getDelay());
} catch (InterruptedException e) {
e.printStackTrace();
} }
} }
});
}
private InteractionType wrapClickType(WrapperPlayClientInteractEntity.InteractAction action) { private InteractionType wrapClickType(WrapperPlayClientInteractEntity.InteractAction action) {
switch (action) { switch (action) {