Fix entity iteration/removal

This commit is contained in:
Jesse Boyd 2017-02-01 08:35:29 +11:00
parent 479d92b573
commit a9cafb13a2
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
5 changed files with 40 additions and 31 deletions

View File

@ -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<Chunk, BukkitQueue_1_10> {
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<Chunk, BukkitQueue_1_10> {
if (!entsToRemove.isEmpty()) {
synchronized (BukkitQueue_0.adapter) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity);
Collection<Entity> 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);
}
}
}
}

View File

@ -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<Chunk, com.boydti.fawe.bukki
if (!entsToRemove.isEmpty()) {
synchronized (BukkitQueue_0.adapter) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
if (copy != null) {
copy.storeEntity(entity);
Collection<Entity> 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<Chunk, com.boydti.fawe.bukki
if (!ents.isEmpty()) {
char[] array = this.getIdArray(i);
if (array == null || ents == null || ents.isEmpty()) continue;
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;
}

View File

@ -171,9 +171,9 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk, BukkitQueue17> {
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;
}

View File

@ -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<Chunk, BukkitQueue18R3> {
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<Chunk, BukkitQueue18R3> {
if (!entsToRemove.isEmpty()) {
synchronized (BukkitQueue_0.adapter) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity);
Collection<Entity> 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);
}
}
}
}

View File

@ -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<Chunk, BukkitQueue_1_9_R1> {
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<Chunk, BukkitQueue_1_9_R1> {
if (!entsToRemove.isEmpty()) {
synchronized (BukkitQueue_0.adapter) {
for (int i = 0; i < entities.length; i++) {
Collection<Entity> ents = new ArrayList<>(entities[i]);
for (Entity entity : ents) {
if (entsToRemove.contains(entity.getUniqueID())) {
nmsWorld.removeEntity(entity);
Collection<Entity> 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);
}
}
}
}