diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java index 1694279a..ccfe2135 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java @@ -16,7 +16,6 @@ import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.internal.Constants; import java.lang.reflect.Constructor; import java.lang.reflect.Field; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -209,9 +208,9 @@ public class BukkitChunk_1_10 extends CharFaweChunk { if (!ents.isEmpty()) { char[] array = this.getIdArray(i); if (array == null || entities[i] == null || entities[i].isEmpty()) continue; - ents = new ArrayList<>(entities[i]); + Entity[] entsArr = ents.toArray(new Entity[ents.size()]); synchronized (BukkitQueue_0.adapter) { - for (Entity entity : ents) { + for (Entity entity : entsArr) { if (entity instanceof EntityPlayer) { continue; } @@ -231,10 +230,13 @@ public class BukkitChunk_1_10 extends CharFaweChunk { if (!entsToRemove.isEmpty()) { synchronized (BukkitQueue_0.adapter) { for (int i = 0; i < entities.length; i++) { - Collection ents = new ArrayList<>(entities[i]); - for (Entity entity : ents) { - if (entsToRemove.contains(entity.getUniqueID())) { - nmsWorld.removeEntity(entity); + Collection ents = entities[i]; + if (ents.isEmpty()) { + Entity[] entsArr = ents.toArray(new Entity[ents.size()]); + for (Entity entity : entsArr) { + if (entsToRemove.contains(entity.getUniqueID())) { + nmsWorld.removeEntity(entity); + } } } } diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java index 57b1887e..18a383fd 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitChunk_1_11.java @@ -17,7 +17,6 @@ import com.sk89q.worldedit.internal.Constants; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; @@ -230,13 +229,16 @@ public class BukkitChunk_1_11 extends CharFaweChunk ents = new ArrayList<>(entities[i]); - for (Entity entity : ents) { - if (entsToRemove.contains(entity.getUniqueID())) { - if (copy != null) { - copy.storeEntity(entity); + Collection ents = entities[i]; + if (ents.isEmpty()) { + Entity[] entsArr = ents.toArray(new Entity[ents.size()]); + for (Entity entity : entsArr) { + if (entsToRemove.contains(entity.getUniqueID())) { + if (copy != null) { + copy.storeEntity(entity); + } + nmsWorld.removeEntity(entity); } - nmsWorld.removeEntity(entity); } } } @@ -263,8 +265,9 @@ public class BukkitChunk_1_11 extends CharFaweChunk { if (!ents.isEmpty()) { char[] array = this.getIdArray(i); if (array == null || entities[i] == null || entities[i].isEmpty()) continue; - ents = new ArrayList<>(entities[i]); + Entity[] entsArr = ents.toArray(new Entity[ents.size()]); synchronized (BukkitQueue_0.adapter) { - for (Entity entity : ents) { + for (Entity entity : entsArr) { if (entity instanceof EntityPlayer) { continue; } diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java index 7e365a8b..bc0a245b 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitChunk_1_8.java @@ -12,7 +12,6 @@ import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.internal.Constants; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -110,9 +109,9 @@ public class BukkitChunk_1_8 extends CharFaweChunk { if (!ents.isEmpty()) { char[] array = this.getIdArray(i); if (array == null || entities[i] == null || entities[i].isEmpty()) continue; - ents = new ArrayList<>(entities[i]); + Entity[] entsArr = ents.toArray(new Entity[ents.size()]); synchronized (BukkitQueue_0.adapter) { - for (Entity entity : ents) { + for (Entity entity : entsArr) { if (entity instanceof EntityPlayer) { continue; } @@ -132,10 +131,13 @@ public class BukkitChunk_1_8 extends CharFaweChunk { if (!entsToRemove.isEmpty()) { synchronized (BukkitQueue_0.adapter) { for (int i = 0; i < entities.length; i++) { - Collection ents = new ArrayList<>(entities[i]); - for (Entity entity : ents) { - if (entsToRemove.contains(entity.getUniqueID())) { - nmsWorld.removeEntity(entity); + Collection ents = entities[i]; + if (ents.isEmpty()) { + Entity[] entsArr = ents.toArray(new Entity[ents.size()]); + for (Entity entity : entsArr) { + if (entsToRemove.contains(entity.getUniqueID())) { + nmsWorld.removeEntity(entity); + } } } } diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java index dc099d55..dfdfc9c5 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitChunk_1_9.java @@ -16,7 +16,6 @@ import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.internal.Constants; import java.lang.reflect.Constructor; import java.lang.reflect.Field; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -210,9 +209,9 @@ public class BukkitChunk_1_9 extends CharFaweChunk { if (!ents.isEmpty()) { char[] array = this.getIdArray(i); if (array == null || entities[i] == null || entities[i].isEmpty()) continue; - ents = new ArrayList<>(entities[i]); + Entity[] entsArr = ents.toArray(new Entity[ents.size()]); synchronized (BukkitQueue_0.adapter) { - for (Entity entity : ents) { + for (Entity entity : entsArr) { if (entity instanceof EntityPlayer) { continue; } @@ -232,10 +231,13 @@ public class BukkitChunk_1_9 extends CharFaweChunk { if (!entsToRemove.isEmpty()) { synchronized (BukkitQueue_0.adapter) { for (int i = 0; i < entities.length; i++) { - Collection ents = new ArrayList<>(entities[i]); - for (Entity entity : ents) { - if (entsToRemove.contains(entity.getUniqueID())) { - nmsWorld.removeEntity(entity); + Collection ents = entities[i]; + if (ents.isEmpty()) { + Entity[] entsArr = ents.toArray(new Entity[ents.size()]); + for (Entity entity : entsArr) { + if (entsToRemove.contains(entity.getUniqueID())) { + nmsWorld.removeEntity(entity); + } } } }