aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLemonCaramel <[email protected]>2021-08-08 09:50:49 +0900
committerGitHub <[email protected]>2021-08-08 00:50:49 +0000
commit92cea848236b1e07443bc9ee99e9ed8b443342ed (patch)
tree81da9c0305836d0bef812106d64c167a91de21e7
parentfadeabe9e3ae600af58a3cc70578f05d69b0caee (diff)
downloadPaper-92cea848236b1e07443bc9ee99e9ed8b443342ed.tar.gz
Paper-92cea848236b1e07443bc9ee99e9ed8b443342ed.zip
Backport Add PlayerArmSwingEvent to 1.16 (#6197)
-rw-r--r--Spigot-API-Patches/0318-Adds-PlayerArmSwingEvent.patch71
-rw-r--r--Spigot-Server-Patches/0763-Adds-PlayerArmSwingEvent.patch31
2 files changed, 102 insertions, 0 deletions
diff --git a/Spigot-API-Patches/0318-Adds-PlayerArmSwingEvent.patch b/Spigot-API-Patches/0318-Adds-PlayerArmSwingEvent.patch
new file mode 100644
index 0000000000..75e45a71f8
--- /dev/null
+++ b/Spigot-API-Patches/0318-Adds-PlayerArmSwingEvent.patch
@@ -0,0 +1,71 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+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..1a4550a73e89f9cf92d2831d21bcfb46f92fd189
+--- /dev/null
++++ b/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java
+@@ -0,0 +1,27 @@
++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.NotNull;
++
++public class PlayerArmSwingEvent extends PlayerAnimationEvent {
++
++ private final EquipmentSlot equipmentSlot;
++
++ public PlayerArmSwingEvent(@NotNull Player player, @NotNull EquipmentSlot equipmentSlot) {
++ super(player, PlayerAnimationType.ARM_SWING);
++ this.equipmentSlot = equipmentSlot;
++ }
++
++ /**
++ * Returns the hand of the arm swing.
++ *
++ * @return the hand
++ */
++ @NotNull
++ 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 6cd236cd1fa10ec37e6e0228c7bbd4415b39399d..4d18b0f2984b301bb2d909c9c362de4cbd4366fe 100644
+--- 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();
+@@ -18,12 +19,19 @@ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable {
+ *
+ * @param player The player instance
+ */
++ @Deprecated // Paper
+ public PlayerAnimationEvent(@NotNull final Player player) {
+ super(player);
+
+ // Only supported animation type for now:
+ animationType = PlayerAnimationType.ARM_SWING;
+ }
++ // Paper start
++ public PlayerAnimationEvent(@NotNull final Player player, @NotNull PlayerAnimationType animationType) {
++ super(player);
++ this.animationType = animationType;
++ }
++ // Paper end
+
+ /**
+ * Get the type of this animation event
diff --git a/Spigot-Server-Patches/0763-Adds-PlayerArmSwingEvent.patch b/Spigot-Server-Patches/0763-Adds-PlayerArmSwingEvent.patch
new file mode 100644
index 0000000000..c50c711729
--- /dev/null
+++ b/Spigot-Server-Patches/0763-Adds-PlayerArmSwingEvent.patch
@@ -0,0 +1,31 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+Date: Fri, 12 Mar 2021 19:22:21 -0800
+Subject: [PATCH] Adds PlayerArmSwingEvent
+
+
+diff --git a/src/main/java/net/minecraft/network/protocol/game/PacketPlayInArmAnimation.java b/src/main/java/net/minecraft/network/protocol/game/PacketPlayInArmAnimation.java
+index ab9ef34782f483bb297a8cdd82eb3388bd2df706..a463aca7279e1ae69598b609fad2a08ceda1e23b 100644
+--- a/src/main/java/net/minecraft/network/protocol/game/PacketPlayInArmAnimation.java
++++ b/src/main/java/net/minecraft/network/protocol/game/PacketPlayInArmAnimation.java
+@@ -29,6 +29,7 @@ public class PacketPlayInArmAnimation implements Packet<PacketListenerPlayIn> {
+ packetlistenerplayin.a(this);
+ }
+
++ public EnumHand getHand() { return b(); } // Paper - OBFHELPER
+ public EnumHand b() {
+ return this.a;
+ }
+diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
+index 4001078e2a408dfd5a93c21f55a58c1fde32abbb..7044620e7fb5874913e7911adb606668a76ac0de 100644
+--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
++++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
+@@ -2224,7 +2224,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
+ }
+
+ // Arm swing animation
+- PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer());
++ io.papermc.paper.event.player.PlayerArmSwingEvent event = new io.papermc.paper.event.player.PlayerArmSwingEvent(this.getPlayer(), packetplayinarmanimation.getHand() == EnumHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND); // Paper
+ this.server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) return;