mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-23 16:41:43 +01:00
Further tweaks to using item animations
This commit is contained in:
parent
f759c81763
commit
2a64529bb1
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user