aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0061-PlayerPickupItemEvent-setFlyAtPlayer.patch
blob: 353d3959119144f158c9c42a2326e6dbdee3c5a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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 951ea2cc763973655beedcba3c75332d3f297313..18d82c111f30e0279c10a174a51bac018185cd38 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,27 @@ 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.</p>
+     *
+     * @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 +75,7 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
     @Override
     public void setCancelled(boolean cancel) {
         this.cancel = cancel;
+        this.flyAtPlayer = !cancel; // Paper
     }
 
     @NotNull