Skip to content

Instantly share code, notes, and snippets.

@aikar
Created March 28, 2019 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aikar/5bb202de6057a051a950ce1f29feb0b4 to your computer and use it in GitHub Desktop.
Save aikar/5bb202de6057a051a950ce1f29feb0b4 to your computer and use it in GitHub Desktop.
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