From efcca5b66f77fbb2ac91f6f6e42768f98d782e96 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 1 Jan 2021 19:49:11 +0000 Subject: [PATCH] it's better not to bother with tickets to avoid tickets not being removed all the time --- .../adapter/mc1_15_2/BukkitAdapter_1_15_2.java | 17 ++++------------- .../mc1_15_2/BukkitGetBlocks_1_15_2.java | 1 - .../adapter/mc1_16_1/BukkitAdapter_1_16_1.java | 17 ++++------------- .../mc1_16_1/BukkitGetBlocks_1_16_1.java | 1 - .../adapter/mc1_16_2/BukkitAdapter_1_16_2.java | 17 ++++------------- .../mc1_16_2/BukkitGetBlocks_1_16_2.java | 1 - .../adapter/mc1_16_4/BukkitAdapter_1_16_4.java | 18 ++++-------------- .../mc1_16_4/BukkitGetBlocks_1_16_4.java | 1 - 8 files changed, 16 insertions(+), 57 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitAdapter_1_15_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitAdapter_1_15_2.java index 12a25e0fc..ea5fea77b 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitAdapter_1_15_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitAdapter_1_15_2.java @@ -9,7 +9,6 @@ import com.boydti.fawe.object.collection.BitArray; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.TaskManager; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypesCache; @@ -155,33 +154,25 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter { } public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) { - final Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false); + Chunk nmsChunk = nmsWorld.getChunkIfLoaded(chunkX, chunkZ); if (nmsChunk != null) { - TaskManager.IMP.task(() -> nmsChunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance())); return nmsChunk; } if (Fawe.isMainThread()) { - final Chunk nmsChunkMain = nmsWorld.getChunkAt(chunkX, chunkZ); - TaskManager.IMP.task(() -> nmsChunkMain.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance())); - return nmsChunkMain; + return nmsWorld.getChunkAt(chunkX, chunkZ); } if (PaperLib.isPaper()) { CraftWorld craftWorld = nmsWorld.getWorld(); CompletableFuture future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true); try { - final CraftChunk chunk = (CraftChunk) future.get(); - TaskManager.IMP.task(() -> chunk.addPluginChunkTicket(WorldEditPlugin.getInstance())); + CraftChunk chunk = (CraftChunk) future.get(); return chunk.getHandle(); } catch (Throwable e) { e.printStackTrace(); } } // TODO optimize - return TaskManager.IMP.sync(() -> { - Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ); - chunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()); - return chunk; - }); + return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ)); } public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java index daae13a16..b6b2380a2 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java @@ -607,7 +607,6 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { task.run(); } } - nmsChunk.bukkitChunk.removePluginChunkTicket(WorldEditPlugin.getInstance()); if (callback == null) { if (finalizer != null) { finalizer.run(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitAdapter_1_16_1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitAdapter_1_16_1.java index 559d1a6b1..d00432cb7 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitAdapter_1_16_1.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitAdapter_1_16_1.java @@ -9,7 +9,6 @@ import com.boydti.fawe.object.collection.BitArrayUnstretched; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.TaskManager; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypesCache; @@ -152,33 +151,25 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter { } public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) { - final Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false); + Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false); if (nmsChunk != null) { - TaskManager.IMP.task(() -> nmsChunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance())); return nmsChunk; } if (Fawe.isMainThread()) { - final Chunk nmsChunkMain = nmsWorld.getChunkAt(chunkX, chunkZ); - TaskManager.IMP.task(() -> nmsChunkMain.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance())); - return nmsChunkMain; + return nmsWorld.getChunkAt(chunkX, chunkZ); } if (PaperLib.isPaper()) { CraftWorld craftWorld = nmsWorld.getWorld(); CompletableFuture future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true); try { - final CraftChunk chunk = (CraftChunk) future.get(); - TaskManager.IMP.task(() -> chunk.addPluginChunkTicket(WorldEditPlugin.getInstance())); + CraftChunk chunk = (CraftChunk) future.get(); return chunk.getHandle(); } catch (Throwable e) { e.printStackTrace(); } } // TODO optimize - return TaskManager.IMP.sync(() -> { - Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ); - chunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()); - return chunk; - }); + return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ)); } public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java index 39f1e9681..3a5a68338 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java @@ -609,7 +609,6 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { task.run(); } } - nmsChunk.bukkitChunk.removePluginChunkTicket(WorldEditPlugin.getInstance()); if (callback == null) { if (finalizer != null) { finalizer.run(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitAdapter_1_16_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitAdapter_1_16_2.java index 76fdbdece..9ac20c248 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitAdapter_1_16_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitAdapter_1_16_2.java @@ -11,7 +11,6 @@ import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.TaskManager; import com.destroystokyo.paper.util.misc.PooledLinkedHashSets; import com.mojang.datafixers.util.Either; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypesCache; @@ -164,33 +163,25 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter { } public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) { - final Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false); + Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false); if (nmsChunk != null) { - TaskManager.IMP.task(() -> nmsChunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance())); return nmsChunk; } if (Fawe.isMainThread()) { - final Chunk nmsChunkMain = nmsWorld.getChunkAt(chunkX, chunkZ); - TaskManager.IMP.task(() -> nmsChunkMain.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance())); - return nmsChunkMain; + return nmsWorld.getChunkAt(chunkX, chunkZ); } if (PaperLib.isPaper()) { CraftWorld craftWorld = nmsWorld.getWorld(); CompletableFuture future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true); try { - final CraftChunk chunk = (CraftChunk) future.get(); - TaskManager.IMP.task(() -> chunk.addPluginChunkTicket(WorldEditPlugin.getInstance())); + CraftChunk chunk = (CraftChunk) future.get(); return chunk.getHandle(); } catch (Throwable e) { e.printStackTrace(); } } // TODO optimize - return TaskManager.IMP.sync(() -> { - Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ); - chunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()); - return chunk; - }); + return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ)); } public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int chunkX, final int chunkZ) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java index cb5b84019..5a8873114 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java @@ -612,7 +612,6 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks { task.run(); } } - nmsChunk.bukkitChunk.removePluginChunkTicket(WorldEditPlugin.getInstance()); if (callback == null) { if (finalizer != null) { finalizer.run(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitAdapter_1_16_4.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitAdapter_1_16_4.java index 28293c93a..e4101a22f 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitAdapter_1_16_4.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitAdapter_1_16_4.java @@ -5,14 +5,12 @@ import com.boydti.fawe.FaweCache; import com.boydti.fawe.bukkit.adapter.DelegateLock; import com.boydti.fawe.bukkit.adapter.NMSAdapter; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.collection.BitArrayUnstretched; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.TaskManager; import com.destroystokyo.paper.util.misc.PooledLinkedHashSets; import com.mojang.datafixers.util.Either; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypesCache; @@ -165,33 +163,25 @@ public final class BukkitAdapter_1_16_4 extends NMSAdapter { } public static Chunk ensureLoaded(World nmsWorld, int chunkX, int chunkZ) { - final Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false); + Chunk nmsChunk = nmsWorld.getChunkProvider().getChunkAt(chunkX, chunkZ, false); if (nmsChunk != null) { - TaskManager.IMP.task(() -> nmsChunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance())); return nmsChunk; } if (Fawe.isMainThread()) { - final Chunk nmsChunkMain = nmsWorld.getChunkAt(chunkX, chunkZ); - TaskManager.IMP.task(() -> nmsChunkMain.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance())); - return nmsChunkMain; + return nmsWorld.getChunkAt(chunkX, chunkZ); } if (PaperLib.isPaper()) { CraftWorld craftWorld = nmsWorld.getWorld(); CompletableFuture future = craftWorld.getChunkAtAsync(chunkX, chunkZ, true); try { - final CraftChunk chunk = (CraftChunk) future.get(); - TaskManager.IMP.task(() -> chunk.addPluginChunkTicket(WorldEditPlugin.getInstance())); + CraftChunk chunk = (CraftChunk) future.get(); return chunk.getHandle(); } catch (Throwable e) { e.printStackTrace(); } } // TODO optimize - return TaskManager.IMP.sync(() -> { - Chunk chunk = nmsWorld.getChunkAt(chunkX, chunkZ); - chunk.bukkitChunk.addPluginChunkTicket(WorldEditPlugin.getInstance()); - return chunk; - }); + return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(chunkX, chunkZ)); } public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int chunkX, final int chunkZ) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitGetBlocks_1_16_4.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitGetBlocks_1_16_4.java index 90807bca5..8fb195641 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitGetBlocks_1_16_4.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_4/BukkitGetBlocks_1_16_4.java @@ -612,7 +612,6 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks { task.run(); } } - nmsChunk.bukkitChunk.removePluginChunkTicket(WorldEditPlugin.getInstance()); if (callback == null) { if (finalizer != null) { finalizer.run();