Created
March 28, 2019 05:11
-
-
Save aikar/5bb202de6057a051a950ce1f29feb0b4 to your computer and use it in GitHub Desktop.
Example of using PlayerDeathEvent#getItemsToKeep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@EventHandler(ignoreCancelled = true) | |
public void onPlayerDeath(PlayerDeathEvent event) { | |
for (Iterator<ItemStack> iterator = event.getDrops().iterator(); iterator.hasNext(); ) { | |
ItemStack drop = iterator.next(); | |
List<String> lore = drop.getLore(); | |
if (lore != null && !lore.isEmpty()) { | |
if (lore.get(0).contains("(SOULBOUND)")) { | |
iterator.remove(); | |
event.getItemsToKeep().add(drop); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment