aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0181-PlayerDeathEvent-shouldDropExperience.patch
blob: fafa02c7320132958b6df3c1de6072996596e06e (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Tue, 24 Dec 2019 00:35:31 +0000
Subject: [PATCH] PlayerDeathEvent#shouldDropExperience


diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
index 9719e183036c361b909b203593c067a551b82264..66e9d65a8dd05bed05d0ab46ec64206a6dae0507 100644
--- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
+++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
@@ -16,6 +16,7 @@ public class PlayerDeathEvent extends EntityDeathEvent {
     private int newTotalExp = 0;
     private boolean keepLevel = false;
     private boolean keepInventory = false;
+    private boolean doExpDrop; // Paper - shouldDropExperience API
     // Paper start - adventure
     @org.jetbrains.annotations.ApiStatus.Internal
     public PlayerDeathEvent(final @NotNull Player player, final @NotNull List<ItemStack> drops, final int droppedExp, final @Nullable net.kyori.adventure.text.Component deathMessage) {
@@ -29,11 +30,18 @@ public class PlayerDeathEvent extends EntityDeathEvent {
 
     @org.jetbrains.annotations.ApiStatus.Internal
     public PlayerDeathEvent(final @NotNull Player player, final @NotNull List<ItemStack> drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, final @Nullable net.kyori.adventure.text.Component deathMessage) {
+        // Paper start - shouldDropExperience API
+        this(player, drops, droppedExp, newExp, newTotalExp, newLevel, deathMessage, true);
+    }
+    @org.jetbrains.annotations.ApiStatus.Internal
+    public PlayerDeathEvent(final @NotNull Player player, final @NotNull List<ItemStack> drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, final @Nullable net.kyori.adventure.text.Component deathMessage, final boolean doExpDrop) {
+        // Paper end - shouldDropExperience API
         super(player, drops, droppedExp);
         this.newExp = newExp;
         this.newTotalExp = newTotalExp;
         this.newLevel = newLevel;
         this.deathMessage = deathMessage;
+        this.doExpDrop = doExpDrop; // Paper - shouldDropExperience API
     }
     // Paper end - adventure
 
@@ -48,11 +56,19 @@ public class PlayerDeathEvent extends EntityDeathEvent {
 
     @Deprecated // Paper
     public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage) {
+        // Paper start - shouldDropExperience API
+        this(player, drops, droppedExp, newExp, newTotalExp, newLevel, deathMessage, true);
+    }
+
+    @Deprecated // Paper
+    public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage, boolean doExpDrop) {
+        // Paper end - shouldDropExperience API
         super(player, drops, droppedExp);
         this.newExp = newExp;
         this.newTotalExp = newTotalExp;
         this.newLevel = newLevel;
         this.deathMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserializeOrNull(deathMessage); // Paper
+        this.doExpDrop = doExpDrop; // Paper - shouldDropExperience API
     }
 
     @Deprecated // Paper
@@ -90,6 +106,22 @@ public class PlayerDeathEvent extends EntityDeathEvent {
     }
     // Paper end
 
+    // Paper start - shouldDropExperience API
+    /**
+     * @return should experience be dropped from this death
+     */
+    public boolean shouldDropExperience() {
+        return doExpDrop;
+    }
+
+    /**
+     * @param doExpDrop sets if experience should be dropped from this death
+     */
+    public void setShouldDropExperience(boolean doExpDrop) {
+        this.doExpDrop = doExpDrop;
+    }
+    // Paper end - shouldDropExperience API
+
     @NotNull
     @Override
     public Player getEntity() {