Paper/patches/api/0061-PlayerPickupItemEvent-setFlyAtPlayer.patch

56 lines
1.9 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
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
2024-02-01 10:15:57 +01:00
index 951ea2cc763973655beedcba3c75332d3f297313..e528d811f651696069dbd2fd21c5ffad294b26af 100644
2021-06-11 14:02:28 +02:00
--- 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;
2021-06-12 13:18:01 +02:00
2024-02-01 10:15:57 +01:00
@@ -45,6 +46,28 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
2021-06-11 14:02:28 +02:00
return remaining;
}
2021-06-12 13:18:01 +02:00
+ // Paper start
2021-06-11 14:02:28 +02:00
+ /**
+ * Set if the item will fly at the player
2024-02-01 10:15:57 +01:00
+ * <p>
+ * Cancelling the event will set this value to false.
2021-06-11 14:02:28 +02:00
+ *
2024-02-01 10:15:57 +01:00
+ * @param flyAtPlayer true for item to fly at player
2021-06-11 14:02:28 +02:00
+ */
+ public void setFlyAtPlayer(boolean flyAtPlayer) {
+ this.flyAtPlayer = flyAtPlayer;
+ }
+
+ /**
+ * Gets if the item will fly at the player
+ *
2024-02-01 10:15:57 +01:00
+ * @return true if the item will fly at the player
2021-06-11 14:02:28 +02:00
+ */
+ public boolean getFlyAtPlayer() {
+ return flyAtPlayer;
+ }
+ // Paper end
2021-06-11 14:02:28 +02:00
+
@Override
public boolean isCancelled() {
return cancel;
2024-02-01 10:15:57 +01:00
@@ -53,6 +76,7 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
2021-06-11 14:02:28 +02:00
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
+ this.flyAtPlayer = !cancel; // Paper
}
2021-06-12 13:18:01 +02:00
2021-06-11 14:02:28 +02:00
@NotNull