diff --git a/main/src/main/java/net/citizensnpcs/util/PlayerAnimation.java b/main/src/main/java/net/citizensnpcs/util/PlayerAnimation.java index 3b6d74ad9..220ee88ab 100644 --- a/main/src/main/java/net/citizensnpcs/util/PlayerAnimation.java +++ b/main/src/main/java/net/citizensnpcs/util/PlayerAnimation.java @@ -95,8 +95,14 @@ public enum PlayerAnimation { NMS.sleep(player, false); } return; - } else if (this == START_USE_MAINHAND_ITEM || this == START_USE_OFFHAND_ITEM) { + } else if (this == STOP_USE_ITEM || this == START_USE_MAINHAND_ITEM || this == START_USE_OFFHAND_ITEM) { NMS.playAnimation(this, player, radius); + if (player.hasMetadata("citizens-using-item-id")) { + Bukkit.getScheduler().cancelTask(player.getMetadata("citizens-using-item-id").get(0).asInt()); + player.removeMetadata("citizens-using-item-id", CitizensAPI.getPlugin()); + } + if (this == STOP_USE_ITEM) + return; if (player.hasMetadata("citizens-using-item-remaining-ticks")) { int remainingTicks = player.getMetadata("citizens-using-item-remaining-ticks").get(0).asInt(); new BukkitRunnable() { @@ -106,6 +112,7 @@ public enum PlayerAnimation { cancel(); return; } + NMS.playAnimation(PlayerAnimation.STOP_USE_ITEM, player, radius); NMS.playAnimation(PlayerAnimation.this, player, radius); if (!player.hasMetadata("citizens-using-item-id")) { player.setMetadata("citizens-using-item-id", @@ -116,13 +123,6 @@ public enum PlayerAnimation { Math.max(1, remainingTicks + 1)); } return; - } else if (this == STOP_USE_ITEM) { - NMS.playAnimation(this, player, radius); - if (player.hasMetadata("citizens-using-item-id")) { - Bukkit.getScheduler().cancelTask(player.getMetadata("citizens-using-item-id").get(0).asInt()); - player.removeMetadata("citizens-using-item-id", CitizensAPI.getPlugin()); - } - return; } NMS.playAnimation(this, player, radius); } diff --git a/v1_19_R2/src/main/java/net/citizensnpcs/nms/v1_19_R2/util/PlayerAnimationImpl.java b/v1_19_R2/src/main/java/net/citizensnpcs/nms/v1_19_R2/util/PlayerAnimationImpl.java index 38ef6682f..8a6801a75 100644 --- a/v1_19_R2/src/main/java/net/citizensnpcs/nms/v1_19_R2/util/PlayerAnimationImpl.java +++ b/v1_19_R2/src/main/java/net/citizensnpcs/nms/v1_19_R2/util/PlayerAnimationImpl.java @@ -37,6 +37,8 @@ public class PlayerAnimationImpl { case START_USE_MAINHAND_ITEM: player.startUsingItem(InteractionHand.MAIN_HAND); sendEntityData(radius, player); + player.getBukkitEntity().setMetadata("citizens-using-item-remaining-ticks", + new FixedMetadataValue(CitizensAPI.getPlugin(), player.getUseItemRemainingTicks())); break; case START_USE_OFFHAND_ITEM: player.startUsingItem(InteractionHand.OFF_HAND);