diff --git a/bukkit0/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java b/bukkit0/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java index 2494dc47..d92064da 100644 --- a/bukkit0/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java +++ b/bukkit0/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java @@ -72,35 +72,33 @@ public abstract class BukkitQueue_0 extends NMSMa } public void setupAdapter(BukkitImplAdapter adapter) { - if (adapter == null) { - try { - WorldEditPlugin instance = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"); - Field fieldAdapter = WorldEditPlugin.class.getDeclaredField("bukkitAdapter"); - fieldAdapter.setAccessible(true); - if ((this.adapter = adapter) != null) { - fieldAdapter.set(instance, adapter); - } else { - this.adapter = fieldAdapter.get(instance); - } - for (Method method : this.adapter.getClass().getDeclaredMethods()) { - switch (method.getName()) { - case "toNative": - methodToNative = method; - methodToNative.setAccessible(true); - break; - case "fromNative": - methodFromNative = method; - methodFromNative.setAccessible(true); - break; - } - } - } catch (Throwable e) { - Fawe.debug("====== NO NATIVE WORLDEDIT ADAPTER ======"); - Fawe.debug("Try updating WorldEdit: "); - Fawe.debug(" - http://builds.enginehub.org/job/worldedit?branch=master"); - Fawe.debug("See also: http://wiki.sk89q.com/wiki/WorldEdit/Bukkit_adapters"); - Fawe.debug("========================================="); + try { + WorldEditPlugin instance = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"); + Field fieldAdapter = WorldEditPlugin.class.getDeclaredField("bukkitAdapter"); + fieldAdapter.setAccessible(true); + if ((this.adapter = adapter) != null) { + fieldAdapter.set(instance, adapter); + } else { + this.adapter = fieldAdapter.get(instance); } + for (Method method : this.adapter.getClass().getDeclaredMethods()) { + switch (method.getName()) { + case "toNative": + methodToNative = method; + methodToNative.setAccessible(true); + break; + case "fromNative": + methodFromNative = method; + methodFromNative.setAccessible(true); + break; + } + } + } catch (Throwable e) { + Fawe.debug("====== NO NATIVE WORLDEDIT ADAPTER ======"); + Fawe.debug("Try updating WorldEdit: "); + Fawe.debug(" - http://builds.enginehub.org/job/worldedit?branch=master"); + Fawe.debug("See also: http://wiki.sk89q.com/wiki/WorldEdit/Bukkit_adapters"); + Fawe.debug("========================================="); } } diff --git a/bukkit110/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java b/bukkit110/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java index 091a0b6e..4c8b6514 100644 --- a/bukkit110/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java +++ b/bukkit110/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java @@ -22,6 +22,7 @@ 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; import java.util.Iterator; import java.util.List; @@ -595,8 +596,8 @@ public class BukkitQueue_1_10 extends BukkitQueue_0> entryset = tiles.entrySet(); - Iterator> iterator = entryset.iterator(); + Iterator> iterator = tiles.entrySet().iterator(); + HashMap toRemove = null; while (iterator.hasNext()) { Map.Entry tile = iterator.next(); BlockPosition pos = tile.getKey(); @@ -610,10 +611,23 @@ public class BukkitQueue_1_10 extends BukkitQueue_0(); + } + toRemove.put(tile.getKey(), tile.getValue()); } } + if (toRemove != null) { + for (Entry entry : toRemove.entrySet()) { + BlockPosition bp = entry.getKey(); + TileEntity tile = entry.getValue(); + tiles.remove(bp); + tile.y(); + nmsWorld.s(bp); + tile.invalidateBlockCache(); + } + + } // Set blocks for (int j = 0; j < sections.length; j++) { int count = fs.getCount(j); diff --git a/bukkit18/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java b/bukkit18/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java index 52100f68..f90cd007 100644 --- a/bukkit18/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java +++ b/bukkit18/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java @@ -20,6 +20,7 @@ import com.sk89q.worldedit.internal.Constants; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -271,8 +272,8 @@ public class BukkitQueue18R3 extends BukkitQueue_0> entryset = tiles.entrySet(); - Iterator> iterator = entryset.iterator(); + Iterator> iterator = tiles.entrySet().iterator(); + HashMap toRemove = null; while (iterator.hasNext()) { Map.Entry tile = iterator.next(); BlockPosition pos = tile.getKey(); @@ -286,10 +287,23 @@ public class BukkitQueue18R3 extends BukkitQueue_0(); + } + toRemove.put(tile.getKey(), tile.getValue()); } } + if (toRemove != null) { + for (Map.Entry entry : toRemove.entrySet()) { + BlockPosition bp = entry.getKey(); + TileEntity tile = entry.getValue(); + tiles.remove(bp); + tile.y(); + nmsWorld.t(bp); + tile.E(); + } + + } HashSet entsToRemove = fs.getEntityRemoves(); if (entsToRemove.size() > 0) { for (int i = 0; i < entities.length; i++) { diff --git a/bukkit19/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java b/bukkit19/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java index aca17906..48586504 100644 --- a/bukkit19/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java +++ b/bukkit19/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java @@ -22,6 +22,7 @@ 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; import java.util.Iterator; import java.util.List; @@ -593,8 +594,8 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0> entryset = tiles.entrySet(); - Iterator> iterator = entryset.iterator(); + Iterator> iterator = tiles.entrySet().iterator(); + HashMap toRemove = null; while (iterator.hasNext()) { Map.Entry tile = iterator.next(); BlockPosition pos = tile.getKey(); @@ -608,10 +609,23 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0(); + } + toRemove.put(tile.getKey(), tile.getValue()); } } + if (toRemove != null) { + for (Entry entry : toRemove.entrySet()) { + BlockPosition bp = entry.getKey(); + TileEntity tile = entry.getValue(); + tiles.remove(bp); + tile.y(); + nmsWorld.s(bp); + tile.invalidateBlockCache(); + } + + } // Set blocks for (int j = 0; j < sections.length; j++) { int count = fs.getCount(j);