Fix ProfilePropertyIterator#remove() recursion bug

This commit is contained in:
Aikar 2018-03-07 21:03:01 -05:00
parent cb8f0e5674
commit b4c8581812

View file

@ -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 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 new file mode 100644
index 000000000..98fca26e9 index 000000000..e673726c5
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java +++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
@ -149,24 +149,9 @@ index 000000000..98fca26e9
+ private class PropertySet extends AbstractSet<ProfileProperty> { + private class PropertySet extends AbstractSet<ProfileProperty> {
+ +
+ @Override + @Override
+ @Nonnull
+ public Iterator<ProfileProperty> iterator() { + public Iterator<ProfileProperty> iterator() {
+ Iterator<Property> iterator = profile.getProperties().values().iterator(); + return new ProfilePropertyIterator(profile.getProperties().values().iterator());
+ return new Iterator<ProfileProperty>() {
+ @Override
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ @Override
+ public ProfileProperty next() {
+ return toBukkit(iterator.next());
+ }
+
+ @Override
+ public void remove() {
+ iterator().remove();
+ }
+ };
+ } + }
+ +
+ @Override + @Override
@ -191,6 +176,29 @@ index 000000000..98fca26e9
+ public boolean contains(Object o) { + public boolean contains(Object o) {
+ return o instanceof ProfileProperty && profile.getProperties().containsKey(((ProfileProperty) o).getName()); + return o instanceof ProfileProperty && profile.getProperties().containsKey(((ProfileProperty) o).getName());
+ } + }
+
+ private class ProfilePropertyIterator implements Iterator<ProfileProperty> {
+ private final Iterator<Property> iterator;
+
+ ProfilePropertyIterator(Iterator<Property> 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 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 * Calculates distance between 2 entities
* @param e1 * @param e1
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java 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 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/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; @@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;