diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java index a33986a0c4..e0e068799a 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java +++ b/paper-api/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/paper-api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java index e6b4ffea88..ade7b26893 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java @@ -17,8 +17,15 @@ public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Canc private final Player player; private final EquipmentSlot hand; + // Paper start - drop leash variable + @Deprecated public PlayerUnleashEntityEvent(@NotNull Entity entity, @NotNull Player player, @NotNull EquipmentSlot hand) { - super(entity, UnleashReason.PLAYER_UNLEASH); + this(entity, player, hand, false); + } + + public PlayerUnleashEntityEvent(@NotNull Entity entity, @NotNull Player player, @NotNull EquipmentSlot hand, boolean dropLeash) { + super(entity, UnleashReason.PLAYER_UNLEASH, dropLeash); + // Paper end this.player = player; this.hand = hand; }