diff --git a/pom.xml b/pom.xml index 32f00459..050b937e 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ UTF-8 FastAsyncWorldEdit - 1.3.2 + 3.3.1 FastAsyncWorldEdit jar @@ -163,7 +163,7 @@ org.bukkit bukkit - 1.8.3-R0.1-SNAPSHOT + 1.9-R0.1-SNAPSHOT org.PrimeSoft diff --git a/src/main/java/com/boydti/fawe/Fawe.java b/src/main/java/com/boydti/fawe/Fawe.java index 8fd33782..9d66523c 100644 --- a/src/main/java/com/boydti/fawe/Fawe.java +++ b/src/main/java/com/boydti/fawe/Fawe.java @@ -133,10 +133,6 @@ public class Fawe { TaskManager.IMP.repeat(lag, 100); } - public boolean checkVersion(final int[] version, final int major, final int minor, final int minor2) { - return (version[0] > major) || ((version[0] == major) && (version[1] > minor)) || ((version[0] == major) && (version[1] == minor) && (version[2] >= minor2)); - } - private void setupEvents() { WorldEdit.getInstance().getEventBus().register(new WESubscriber()); if (Settings.COMMAND_PROCESSOR) { diff --git a/src/main/java/com/boydti/fawe/FaweAPI.java b/src/main/java/com/boydti/fawe/FaweAPI.java index 0b6014c3..ed11ad88 100644 --- a/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/src/main/java/com/boydti/fawe/FaweAPI.java @@ -34,6 +34,18 @@ import com.sk89q.worldedit.world.biome.BaseBiome; */ public class FaweAPI { + /** + * Compare two versions + * @param version + * @param major + * @param minor + * @param minor2 + * @return true if version is >= major, minor, minor2 + */ + public static boolean checkVersion(final int[] version, final int major, final int minor, final int minor2) { + return (version[0] > major) || ((version[0] == major) && (version[1] > minor)) || ((version[0] == major) && (version[1] == minor) && (version[2] >= minor2)); + } + /** * Set a block at a location asynchronously * @param loc diff --git a/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index faef3937..50cb817b 100644 --- a/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -12,6 +12,7 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import com.boydti.fawe.Fawe; +import com.boydti.fawe.FaweAPI; import com.boydti.fawe.IFawe; import com.boydti.fawe.bukkit.regions.FactionsFeature; import com.boydti.fawe.bukkit.regions.FactionsUUIDFeature; @@ -134,7 +135,7 @@ public class FaweBukkit extends JavaPlugin implements IFawe { @Override public FaweQueue getQueue() { - if (Fawe.get().checkVersion(getServerVersion(), 1, 9, 0)) { + if (FaweAPI.checkVersion(getServerVersion(), 1, 9, 0)) { try { return new BukkitQueue_1_9(); } catch (Throwable e) { diff --git a/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue_1_8.java b/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue_1_8.java index da6a96f2..2abeccc2 100644 --- a/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue_1_8.java +++ b/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue_1_8.java @@ -73,6 +73,8 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 { private RefField fieldSections; private RefField fieldWorld; private RefMethod methodGetIdArray; + private RefMethod methodGetWorld; + private RefField tileEntityUnload; private final HashMap worldMap = new HashMap<>(); @@ -91,6 +93,8 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 { methodGetIdArray = classChunkSection.getMethod("getIdArray"); methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class); classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class); + this.tileEntityUnload = classWorld.getField("c"); + this.methodGetWorld = classChunk.getMethod("getWorld"); } catch (final NoSuchMethodException e) { e.printStackTrace(); } @@ -299,6 +303,7 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 { // Sections final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle"); final Object c = getHandele.invoke(chunk); + Object w = methodGetWorld.of(c).call(); final Class clazz = c.getClass(); final Field sf = clazz.getDeclaredField("sections"); sf.setAccessible(true); @@ -307,6 +312,7 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 { final Object[] sections = (Object[]) sf.get(c); final HashMap tiles = (HashMap) tf.get(c); + List tilesUnload = (List) tileEntityUnload.of(w).get(); final List[] entities = (List[]) ef.get(c); Method xm = null; @@ -335,6 +341,7 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 { continue; } if (array[k] != 0) { + tilesUnload.add(tile.getValue()); iter.remove(); } } diff --git a/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9.java b/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9.java index 86b1eaed..4131e454 100644 --- a/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9.java +++ b/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9.java @@ -75,6 +75,8 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 { private final RefMethod methodGetCombinedId; private final RefMethod methodGetByCombinedId; private final Object air; + private final RefMethod methodGetWorld; + private final RefField tileEntityUnload; private final RefMethod methodGetHandlePlayer; private final RefField connection; @@ -99,6 +101,8 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 { methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class); classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class); air = methodGetByCombinedId.call(0); + this.tileEntityUnload = classWorld.getField("tileEntityListUnload"); + this.methodGetWorld = classChunk.getMethod("getWorld"); } @Override @@ -310,6 +314,7 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 { // Sections final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle"); final Object c = getHandele.invoke(chunk); + Object w = methodGetWorld.of(c).call(); final Class clazz = c.getClass(); final Field sf = clazz.getDeclaredField("sections"); sf.setAccessible(true); @@ -318,6 +323,7 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 { final Object[] sections = (Object[]) sf.get(c); final HashMap tiles = (HashMap) tf.get(c); + List tilesUnload = (List) tileEntityUnload.of(w).get(); final List[] entities = (List[]) ef.get(c); Method xm = null; @@ -346,6 +352,7 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 { continue; } if (array[k] != 0) { + tilesUnload.add(tile.getValue()); iter.remove(); } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 4c5a3b3c..e9528828 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: FastAsyncWorldEdit main: com.boydti.fawe.bukkit.FaweBukkit -version: 1.2.1 +version: 3.3.1 description: Fast Async WorldEdit plugin authors: [Empire92] loadbefore: [WorldEdit]