From 1284f0bf53d5d15545412dc94168d563cf66b7dc Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 12 Mar 2021 19:20:03 -0800 Subject: [PATCH] Adds PlayerArmSwingEvent --- .../event/player/PlayerArmSwingEvent.java | 29 +++++++++++++++++++ .../event/player/PlayerAnimationEvent.java | 1 + 2 files changed, 30 insertions(+) create mode 100644 paper-api/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java diff --git a/paper-api/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java b/paper-api/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java new file mode 100644 index 0000000000..84dfb8da90 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java @@ -0,0 +1,29 @@ +package io.papermc.paper.event.player; + +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerAnimationEvent; +import org.bukkit.event.player.PlayerAnimationType; +import org.bukkit.inventory.EquipmentSlot; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class PlayerArmSwingEvent extends PlayerAnimationEvent { + + private final EquipmentSlot equipmentSlot; + + @ApiStatus.Internal + public PlayerArmSwingEvent(final Player player, final EquipmentSlot equipmentSlot) { + super(player, equipmentSlot == EquipmentSlot.HAND ? PlayerAnimationType.ARM_SWING : PlayerAnimationType.OFF_ARM_SWING); + this.equipmentSlot = equipmentSlot; + } + + /** + * Returns the hand of the arm swing. + * + * @return the hand + */ + public EquipmentSlot getHand() { + return this.equipmentSlot; + } +} diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java index 1f2d3b3e97..0c7e3a0c4d 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java @@ -7,6 +7,7 @@ import org.jetbrains.annotations.NotNull; /** * Represents a player animation event + *
Use {@link io.papermc.paper.event.player.PlayerArmSwingEvent} for determining which arm was swung. */ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList();