3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/patches/api/0288-Adds-PlayerArmSwingEvent.patch

54 Zeilen
2.2 KiB
Diff

2021-07-09 15:56:30 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Fri, 12 Mar 2021 19:20:03 -0800
Subject: [PATCH] Adds PlayerArmSwingEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..84dfb8da90c5f21d0f8899eca57bcb8b58614ca9
2021-07-09 15:56:30 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java
2024-02-01 10:15:57 +01:00
@@ -0,0 +1,29 @@
2021-07-09 15:56:30 +02:00
+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;
2024-02-01 10:15:57 +01:00
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
2021-07-09 15:56:30 +02:00
+
+@NullMarked
2021-07-09 15:56:30 +02:00
+public class PlayerArmSwingEvent extends PlayerAnimationEvent {
+
+ private final EquipmentSlot equipmentSlot;
+
2024-02-01 10:15:57 +01:00
+ @ApiStatus.Internal
+ public PlayerArmSwingEvent(final Player player, final EquipmentSlot equipmentSlot) {
+ super(player, equipmentSlot == EquipmentSlot.HAND ? PlayerAnimationType.ARM_SWING : PlayerAnimationType.OFF_ARM_SWING);
2021-07-09 15:56:30 +02:00
+ this.equipmentSlot = equipmentSlot;
+ }
+
+ /**
+ * Returns the hand of the arm swing.
+ *
+ * @return the hand
+ */
+ public EquipmentSlot getHand() {
+ return this.equipmentSlot;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java b/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java
index eb722a1e3b987b86fae2fa8346606fa15fada26f..11c27b1a4a749e129ed4b2d906c315d97a4b66e7 100644
2021-07-09 15:56:30 +02:00
--- a/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java
@@ -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();