Copy thrown pearls list for removal (#12840)

This commit is contained in:
Shane Freeder 2025-07-14 22:04:02 +01:00 committed by GitHub
parent bda84069b4
commit 94d60e15b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -420,8 +420,9 @@
player.unRide();
for (ThrownEnderpearl thrownEnderpearl : player.getEnderPearls()) {
- for (ThrownEnderpearl thrownEnderpearl : player.getEnderPearls()) {
- thrownEnderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER);
+ for (ThrownEnderpearl thrownEnderpearl : new java.util.ArrayList<>(player.getEnderPearls())) { // Paper - copy, setOwner will remove from list;
+ // Paper start - Allow using old ender pearl behavior
+ if (!thrownEnderpearl.level().paperConfig().misc.legacyEnderPearlBehavior) {
+ thrownEnderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, org.bukkit.event.entity.EntityRemoveEvent.Cause.PLAYER_QUIT); // CraftBukkit - add Bukkit remove cause