1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2024-12-22 22:45:31 +01:00
PaperMC/patches/api/0241-Add-dropLeash-variable-to-EntityUnleashEvent.patch

79 lines
3 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nassim Jahnke <nassim@njahnke.dev>
2021-06-11 14:02:28 +02:00
Date: Fri, 29 Jan 2021 15:13:04 +0100
Subject: [PATCH] Add dropLeash variable to EntityUnleashEvent
diff --git a/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java b/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java
index a33986a0c437a673435206fc337031a7eebdab3b..e0e068799a1868c8e561869015f41f553ef4fbdb 100644
--- a/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java
+++ b/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java
@@ -10,10 +10,19 @@ import org.jetbrains.annotations.NotNull;
public class EntityUnleashEvent extends EntityEvent {
private static final HandlerList handlers = new HandlerList();
private final UnleashReason reason;
+ private boolean dropLeash; // Paper
+ // Paper start - drop leash variable
+ @Deprecated
public EntityUnleashEvent(@NotNull Entity entity, @NotNull UnleashReason reason) {
+ this(entity, reason, false);
+ }
+
+ public EntityUnleashEvent(@NotNull Entity entity, @NotNull UnleashReason reason, boolean dropLeash) {
super(entity);
+ // Paper end
this.reason = reason;
+ this.dropLeash = dropLeash; // Paper
}
/**
@@ -26,6 +35,26 @@ public class EntityUnleashEvent extends EntityEvent {
return reason;
}
+ // Paper start
+ /**
+ * Returns whether a leash item will be dropped.
+ *
+ * @return Whether the leash item will be dropped
+ */
+ public boolean isDropLeash() {
+ return dropLeash;
+ }
+
+ /**
+ * Sets whether a leash item should be dropped.
+ *
+ * @param dropLeash Whether the leash item should be dropped
+ */
+ public void setDropLeash(boolean dropLeash) {
+ this.dropLeash = dropLeash;
+ }
+ // Paper end
+
@NotNull
@Override
public HandlerList getHandlers() {
diff --git a/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java b/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java
2024-12-03 17:58:41 +01:00
index e6b4ffea8835e248431fe8594eac136c11bf6be0..ade7b268934019e9134a660d88e977f8146ecbc0 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java
@@ -17,8 +17,15 @@ public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Canc
2021-06-11 14:02:28 +02:00
private final Player player;
private final EquipmentSlot hand;
2021-06-11 14:02:28 +02:00
+ // Paper start - drop leash variable
+ @Deprecated
public PlayerUnleashEntityEvent(@NotNull Entity entity, @NotNull Player player, @NotNull EquipmentSlot hand) {
2021-06-11 14:02:28 +02:00
- super(entity, UnleashReason.PLAYER_UNLEASH);
+ this(entity, player, hand, false);
2021-06-11 14:02:28 +02:00
+ }
+
+ public PlayerUnleashEntityEvent(@NotNull Entity entity, @NotNull Player player, @NotNull EquipmentSlot hand, boolean dropLeash) {
2021-06-11 14:02:28 +02:00
+ super(entity, UnleashReason.PLAYER_UNLEASH, dropLeash);
+ // Paper end
this.player = player;
this.hand = hand;
2021-06-11 14:02:28 +02:00
}