Paper/patches/api/0184-PlayerDeathEvent-shouldDropExperience.patch
Nassim Jahnke 928bcc8d3a
Updated Upstream (Bukkit/CraftBukkit) (#8430)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
09943450 Update SnakeYAML version
5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc
6f82b381 PR-788: Add getHand() to all relevant events

CraftBukkit Changes:
aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe
5329dd6fd PR-1107: Add getHand() to all relevant events
93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
2022-10-02 09:56:36 +02:00

80 lines
3.7 KiB
Diff

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 5f7d0d08be8bca06c9aa89659b7865a7b5a547f8..9d95218b49895ab76b00fe9524d9b25ea9f9b8c2 100644
--- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
+++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
@@ -1,6 +1,8 @@
package org.bukkit.event.entity;
import java.util.List;
+
+import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
@@ -18,6 +20,8 @@ public class PlayerDeathEvent extends EntityDeathEvent {
private boolean keepLevel = false;
private boolean keepInventory = false;
// Paper start
+ private boolean doExpDrop;
+
public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> drops, final int droppedExp, @Nullable final net.kyori.adventure.text.Component adventure$deathMessage) {
this(player, drops, droppedExp, 0, adventure$deathMessage, null);
}
@@ -27,12 +31,17 @@ public class PlayerDeathEvent extends EntityDeathEvent {
}
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 net.kyori.adventure.text.Component adventure$deathMessage, @Nullable String deathMessage) {
+ this(player, drops, droppedExp, newExp, newTotalExp, newLevel, adventure$deathMessage, deathMessage, true);
+ }
+
+ 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 net.kyori.adventure.text.Component adventure$deathMessage, @Nullable String deathMessage, boolean doExpDrop) {
super(player, drops, droppedExp);
this.newExp = newExp;
this.newTotalExp = newTotalExp;
this.newLevel = newLevel;
this.deathMessage = deathMessage;
this.adventure$deathMessage = adventure$deathMessage;
+ this.doExpDrop = doExpDrop;
}
// Paper end
@@ -47,6 +56,11 @@ 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) {
+ 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) {
super(player, drops, droppedExp);
this.newExp = newExp;
this.newTotalExp = newTotalExp;
@@ -88,6 +102,20 @@ public class PlayerDeathEvent extends EntityDeathEvent {
public List<ItemStack> getItemsToKeep() {
return itemsToKeep;
}
+
+ /**
+ * @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
@NotNull