diff --git a/core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java b/core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java index c27378bc..712a2a5e 100644 --- a/core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java +++ b/core/src/main/java/com/boydti/fawe/logging/rollback/RollbackOptimizedHistory.java @@ -85,7 +85,9 @@ public class RollbackOptimizedHistory extends DiskStorageHistory { if (super.close()) { // Save to DB RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld()); - db.logEdit(this); + if (db != null) { + db.logEdit(this); + } return true; } return false; diff --git a/forge111/src/main/java/com/boydti/fawe/forge/v111/ForgeChunk_All.java b/forge111/src/main/java/com/boydti/fawe/forge/v111/ForgeChunk_All.java index 3049425c..4c2e7a35 100644 --- a/forge111/src/main/java/com/boydti/fawe/forge/v111/ForgeChunk_All.java +++ b/forge111/src/main/java/com/boydti/fawe/forge/v111/ForgeChunk_All.java @@ -256,23 +256,27 @@ public class ForgeChunk_All extends CharFaweChunk { getParent().getChangeTask().run(previous, this); } // Trim tiles - Set> entryset = tiles.entrySet(); - Iterator> iterator = entryset.iterator(); - while (iterator.hasNext()) { - Map.Entry tile = iterator.next(); - BlockPos pos = tile.getKey(); - int lx = pos.getX() & 15; - int ly = pos.getY(); - int lz = pos.getZ() & 15; - int j = FaweCache.CACHE_I[ly][lz][lx]; - char[] array = this.getIdArray(j); - if (array == null) { - continue; - } - int k = FaweCache.CACHE_J[ly][lz][lx]; - if (array[k] != 0) { - tile.getValue().invalidate();; - iterator.remove(); + if (!tiles.isEmpty()) { + Set> entryset = tiles.entrySet(); + Iterator> iterator = entryset.iterator(); + while (iterator.hasNext()) { + Map.Entry tile = iterator.next(); + BlockPos pos = tile.getKey(); + int lx = pos.getX() & 15; + int ly = pos.getY(); + int lz = pos.getZ() & 15; + int j = FaweCache.CACHE_I[ly][lz][lx]; + char[] array = this.getIdArray(j); + if (array == null) { + continue; + } + int k = FaweCache.CACHE_J[ly][lz][lx]; + if (array[k] != 0) { + synchronized (ForgeChunk_All.class) { + tile.getValue().invalidate(); + iterator.remove(); + } + } } } // Efficiently merge sections diff --git a/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java b/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java index 97fbf74f..2537860c 100644 --- a/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java +++ b/sponge/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeChunk_1_11.java @@ -256,23 +256,27 @@ public class SpongeChunk_1_11 extends CharFaweChunk { getParent().getChangeTask().run(previous, this); } // Trim tiles - Set> entryset = tiles.entrySet(); - Iterator> iterator = entryset.iterator(); - while (iterator.hasNext()) { - Map.Entry tile = iterator.next(); - BlockPos pos = tile.getKey(); - int lx = pos.getX() & 15; - int ly = pos.getY(); - int lz = pos.getZ() & 15; - int j = FaweCache.CACHE_I[ly][lz][lx]; - char[] array = this.getIdArray(j); - if (array == null) { - continue; - } - int k = FaweCache.CACHE_J[ly][lz][lx]; - if (array[k] != 0) { - tile.getValue().invalidate();; - iterator.remove(); + if (!tiles.isEmpty()) { + Set> entryset = tiles.entrySet(); + Iterator> iterator = entryset.iterator(); + while (iterator.hasNext()) { + Map.Entry tile = iterator.next(); + BlockPos pos = tile.getKey(); + int lx = pos.getX() & 15; + int ly = pos.getY(); + int lz = pos.getZ() & 15; + int j = FaweCache.CACHE_I[ly][lz][lx]; + char[] array = this.getIdArray(j); + if (array == null) { + continue; + } + int k = FaweCache.CACHE_J[ly][lz][lx]; + if (array[k] != 0) { + synchronized (SpongeChunk_1_11.class) { + tile.getValue().invalidate(); + iterator.remove(); + } + } } } HashSet entsToRemove = this.getEntityRemoves();