Skip to content

Instantly share code, notes, and snippets.

@aikar aikar/Listener.java
Created Mar 28, 2019

Embed
What would you like to do?
Example of using PlayerDeathEvent#getItemsToKeep
@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
You can’t perform that action at this time.