Adds PlayerArmSwingEvent

This commit is contained in:
Jake Potrebic 2021-03-12 19:20:03 -08:00
parent a2a581ba6b
commit 1284f0bf53
2 changed files with 30 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -7,6 +7,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents a player animation event
* <br>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();