diff options
author | Aikar <[email protected]> | 2019-03-28 00:58:05 -0400 |
---|---|---|
committer | Aikar <[email protected]> | 2019-03-28 01:12:38 -0400 |
commit | be067fea110f374ebf3b9c1a565615ce5ca42378 (patch) | |
tree | f30a8d816ad139368010f7f4d65fdbbb0fad01b1 /Spigot-API-Patches | |
parent | 8f25112b9334ac8a40f8aad2aa403c160b4a4409 (diff) | |
download | Paper-be067fea110f374ebf3b9c1a565615ce5ca42378.tar.gz Paper-be067fea110f374ebf3b9c1a565615ce5ca42378.zip |
PlayerDeathEvent#getItemsToKeep
Exposes a mutable array on items a player should keep on death.
This allows a cleaner method to implement "Keep certain items on death"
than how plugins currently do it in that it never removes them in first
place, so its safe if the player logs out/server is shutdown before respawn.
Example Usage: https://gist.github.com/aikar/5bb202de6057a051a950ce1f29feb0b4
Diffstat (limited to 'Spigot-API-Patches')
-rw-r--r-- | Spigot-API-Patches/0181-PlayerDeathEvent-getItemsToKeep.patch | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Spigot-API-Patches/0181-PlayerDeathEvent-getItemsToKeep.patch b/Spigot-API-Patches/0181-PlayerDeathEvent-getItemsToKeep.patch new file mode 100644 index 0000000000..e6ccbb43e4 --- /dev/null +++ b/Spigot-API-Patches/0181-PlayerDeathEvent-getItemsToKeep.patch @@ -0,0 +1,39 @@ +From 9552cb45732ed2d11f179cdf766996d3c0843001 Mon Sep 17 00:00:00 2001 +From: Aikar <[email protected]> +Date: Mon, 11 Mar 2013 20:04:34 -0400 +Subject: [PATCH] PlayerDeathEvent#getItemsToKeep + +Exposes a mutable array on items a player should keep on death + +Example Usage: https://gist.github.com/aikar/5bb202de6057a051a950ce1f29feb0b4 + +diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +index 5b0ef1eb1..b30818177 100644 +--- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java ++++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +@@ -18,6 +18,22 @@ public class PlayerDeathEvent extends EntityDeathEvent { + private boolean keepLevel = false; + private boolean keepInventory = false; + ++ // Paper start ++ private List<ItemStack> itemsToKeep = new java.util.ArrayList<>(); ++ ++ /** ++ * A mutable collection to add items that the player should keep on death (Similar to KeepInventory game rule) ++ * ++ * You <b>MUST</b> remove the item from the .getDrops() collection too or it will duplicate! ++ * ++ * @return The list to hold items to keep ++ */ ++ @NotNull ++ public List<ItemStack> getItemsToKeep() { ++ return itemsToKeep; ++ } ++ // Paper end ++ + public PlayerDeathEvent(@NotNull final Player player, @NotNull final List<ItemStack> drops, final int droppedExp, @Nullable final String deathMessage) { + this(player, drops, droppedExp, 0, deathMessage); + } +-- +2.21.0 + |