mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-18 11:22:15 +01:00
Add PlayerArmSwingEvent (#5353)
This commit is contained in:
parent
d81fd123ce
commit
fc955009ca
2 changed files with 90 additions and 0 deletions
patches
71
patches/api/Adds-PlayerArmSwingEvent.patch
Normal file
71
patches/api/Adds-PlayerArmSwingEvent.patch
Normal file
|
@ -0,0 +1,71 @@
|
|||
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..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/player/PlayerArmSwingEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java
|
||||
@@ -0,0 +0,0 @@ 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();
|
||||
@@ -0,0 +0,0 @@ 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
|
19
patches/server/Adds-PlayerArmSwingEvent.patch
Normal file
19
patches/server/Adds-PlayerArmSwingEvent.patch
Normal file
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 12 Mar 2021 19:22:21 -0800
|
||||
Subject: [PATCH] Adds PlayerArmSwingEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
}
|
||||
|
||||
// Arm swing animation
|
||||
- PlayerAnimationEvent event = new PlayerAnimationEvent(this.getCraftPlayer());
|
||||
+ io.papermc.paper.event.player.PlayerArmSwingEvent event = new io.papermc.paper.event.player.PlayerArmSwingEvent(this.getCraftPlayer(), packet.getHand() == InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND); // Paper
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) return;
|
Loading…
Add table
Reference in a new issue