Paper/patches/api/0058-PlayerPickupItemEvent-setFlyAtPlayer.patch
2024-12-03 17:58:41 +01:00

56 lines
1.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sun, 7 May 2017 06:26:01 -0500
Subject: [PATCH] PlayerPickupItemEvent#setFlyAtPlayer
diff --git a/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java b/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java
index a73d1b9717bb6d745f909317474cf3b4380d5cb3..f5166bbf94d5fc24c10888a384003a5f8181ac69 100644
--- a/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java
@@ -17,6 +17,7 @@ import org.jetbrains.annotations.NotNull;
public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Item item;
+ private boolean flyAtPlayer = true; // Paper
private boolean cancel = false;
private final int remaining;
@@ -45,6 +46,28 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
return remaining;
}
+ // Paper start
+ /**
+ * Set if the item will fly at the player
+ * <p>
+ * Cancelling the event will set this value to false.
+ *
+ * @param flyAtPlayer true for item to fly at player
+ */
+ public void setFlyAtPlayer(boolean flyAtPlayer) {
+ this.flyAtPlayer = flyAtPlayer;
+ }
+
+ /**
+ * Gets if the item will fly at the player
+ *
+ * @return true if the item will fly at the player
+ */
+ public boolean getFlyAtPlayer() {
+ return flyAtPlayer;
+ }
+ // Paper end
+
@Override
public boolean isCancelled() {
return cancel;
@@ -53,6 +76,7 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
+ this.flyAtPlayer = !cancel; // Paper
}
@NotNull