From b4c8581812dd3b53233e5792ae14422b502d47db Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 7 Mar 2018 21:03:01 -0500 Subject: [PATCH] Fix ProfilePropertyIterator#remove() recursion bug --- .../Basic-PlayerProfile-API.patch | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/Spigot-Server-Patches/Basic-PlayerProfile-API.patch b/Spigot-Server-Patches/Basic-PlayerProfile-API.patch index 94960d09f3..f8afd82959 100644 --- a/Spigot-Server-Patches/Basic-PlayerProfile-API.patch +++ b/Spigot-Server-Patches/Basic-PlayerProfile-API.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Basic PlayerProfile API diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java new file mode 100644 -index 000000000..98fca26e9 +index 000000000..e673726c5 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java @@ -0,0 +0,0 @@ @@ -149,24 +149,9 @@ index 000000000..98fca26e9 + private class PropertySet extends AbstractSet { + + @Override ++ @Nonnull + public Iterator iterator() { -+ Iterator iterator = profile.getProperties().values().iterator(); -+ return new Iterator() { -+ @Override -+ public boolean hasNext() { -+ return iterator.hasNext(); -+ } -+ -+ @Override -+ public ProfileProperty next() { -+ return toBukkit(iterator.next()); -+ } -+ -+ @Override -+ public void remove() { -+ iterator().remove(); -+ } -+ }; ++ return new ProfilePropertyIterator(profile.getProperties().values().iterator()); + } + + @Override @@ -191,6 +176,29 @@ index 000000000..98fca26e9 + public boolean contains(Object o) { + return o instanceof ProfileProperty && profile.getProperties().containsKey(((ProfileProperty) o).getName()); + } ++ ++ private class ProfilePropertyIterator implements Iterator { ++ private final Iterator iterator; ++ ++ ProfilePropertyIterator(Iterator iterator) { ++ this.iterator = iterator; ++ } ++ ++ @Override ++ public boolean hasNext() { ++ return iterator.hasNext(); ++ } ++ ++ @Override ++ public ProfileProperty next() { ++ return toBukkit(iterator.next()); ++ } ++ ++ @Override ++ public void remove() { ++ iterator.remove(); ++ } ++ } + } +} diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java @@ -219,7 +227,7 @@ index 02940d697..4539b5601 100644 * Calculates distance between 2 entities * @param e1 diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 8d0a9e8ca..f0ae65f08 100644 +index 77c16fe2c..aca5ea7c0 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;