From c32f8e132c843b92c3d287f24f68af78dc6ed4e8 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Tue, 24 Dec 2019 00:36:24 +0000 Subject: [PATCH] PlayerDeathEvent#shouldDropExperience --- ...layerDeathEvent-shouldDropExperience.patch | 64 +++++++++++++++++++ ...layerDeathEvent-shouldDropExperience.patch | 21 ++++++ 2 files changed, 85 insertions(+) create mode 100644 Spigot-API-Patches/0188-PlayerDeathEvent-shouldDropExperience.patch create mode 100644 Spigot-Server-Patches/0419-PlayerDeathEvent-shouldDropExperience.patch diff --git a/Spigot-API-Patches/0188-PlayerDeathEvent-shouldDropExperience.patch b/Spigot-API-Patches/0188-PlayerDeathEvent-shouldDropExperience.patch new file mode 100644 index 0000000000..60a2666719 --- /dev/null +++ b/Spigot-API-Patches/0188-PlayerDeathEvent-shouldDropExperience.patch @@ -0,0 +1,64 @@ +From 26f8dfff57e31852d46c49274e1a45d9d66c6523 Mon Sep 17 00:00:00 2001 +From: Shane Freeder +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 1e97d04b..3a743430 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; +@@ -49,6 +51,23 @@ public class PlayerDeathEvent extends EntityDeathEvent { + public List getItemsToKeep() { + return itemsToKeep; + } ++ ++ private boolean doExpDrop; ++ ++ /** ++ * @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 + + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, @Nullable final String deathMessage) { +@@ -60,11 +79,17 @@ public class PlayerDeathEvent extends EntityDeathEvent { + } + + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage) { ++ // Paper start ++ this(player, drops, droppedExp, newExp, newTotalExp, newLevel, deathMessage, player.getGameMode() != GameMode.SPECTATOR); ++ } ++ public PlayerDeathEvent(@NotNull final Player player, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage, boolean doExpDrop) { ++ // Paper end + super(player, drops, droppedExp); + this.newExp = newExp; + this.newTotalExp = newTotalExp; + this.newLevel = newLevel; + this.deathMessage = deathMessage; ++ this.doExpDrop = doExpDrop; // Paper + } + + @NotNull +-- +2.24.1 + diff --git a/Spigot-Server-Patches/0419-PlayerDeathEvent-shouldDropExperience.patch b/Spigot-Server-Patches/0419-PlayerDeathEvent-shouldDropExperience.patch new file mode 100644 index 0000000000..56b0d7d991 --- /dev/null +++ b/Spigot-Server-Patches/0419-PlayerDeathEvent-shouldDropExperience.patch @@ -0,0 +1,21 @@ +From 01886a4ffa8057b331659dd2a18eb57faa05aa98 Mon Sep 17 00:00:00 2001 +From: Shane Freeder +Date: Tue, 24 Dec 2019 00:35:42 +0000 +Subject: [PATCH] PlayerDeathEvent#shouldDropExperience + + +diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java +index ed6f1b1a3..5cd709991 100644 +--- a/src/main/java/net/minecraft/server/EntityPlayer.java ++++ b/src/main/java/net/minecraft/server/EntityPlayer.java +@@ -649,6 +649,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + } + + this.setSpectatorTarget(this); // Remove spectated target ++ if (event.shouldDropExperience()) this.dropExperience(); // Paper - drop experience + // CraftBukkit end + + // CraftBukkit - Get our scores instead +-- +2.24.1 +