[ci skip] Don't promote checking enchantment by legacy lore (#12421)

This commit is contained in:
masmc05 2025-04-13 12:28:03 +03:00 committed by GitHub
parent f517267c0c
commit 4511edb849
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -264,19 +264,18 @@ public class PlayerDeathEvent extends EntityDeathEvent {
* <br> * <br>
* You <b>MUST</b> remove the item from the .getDrops() collection too or it will duplicate! * You <b>MUST</b> remove the item from the .getDrops() collection too or it will duplicate!
* <pre>{@code * <pre>{@code
* {@literal @EventHandler(ignoreCancelled = true)} * private static final NamespacedKey SOULBOUND_KEY = new NamespacedKey("testplugin", "soulbound");
* public void onPlayerDeath(PlayerDeathEvent event) { *
* for (Iterator<ItemStack> iterator = event.getDrops().iterator(); iterator.hasNext(); ) { * @EventHandler(ignoreCancelled = true)
* ItemStack drop = iterator.next(); * public void onPlayerDeath(PlayerDeathEvent event) {
* List<String> lore = drop.getLore(); * for (Iterator<ItemStack> iterator = event.getDrops().iterator(); iterator.hasNext(); ) {
* if (lore != null && !lore.isEmpty()) { * ItemStack drop = iterator.next();
* if (lore.get(0).contains("(SOULBOUND)")) { * if (drop.getPersistentDataContainer().getOrDefault(SOULBOUND_KEY, PersistentDataType.BOOLEAN, false)) {
* iterator.remove(); * iterator.remove();
* event.getItemsToKeep().add(drop); * event.getItemsToKeep().add(drop);
* }
* }
* } * }
* } * }
* }
* }</pre> * }</pre>
* <p> * <p>
* Adding an item to this list that the player did not previously have will give them the item on death. * Adding an item to this list that the player did not previously have will give them the item on death.