From 7c2def651d9d90520acd6343e043e979c72f773c Mon Sep 17 00:00:00 2001 From: Phillipp Glanz Date: Tue, 19 Sep 2023 17:31:32 +0200 Subject: [PATCH 1/3] Update documentation --- .../bukkit/util/FoliaTaskManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/FoliaTaskManager.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/FoliaTaskManager.java index 4edcbaa699..357ec4aa75 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/FoliaTaskManager.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/FoliaTaskManager.java @@ -200,21 +200,21 @@ private static class SchedulerAdapter { "execute", ENTITY_EXECUTE_TYPE ); - // (ES, P, R, R, L)Z (ES, R, R, L)Z + // (Entity, Plugin, Runnable, Runnable, Long)Z (Entity, Runnable, Runnable, Long)Z executeForPlayer = insertArguments(executeForPlayer, 1, pluginInstance); - // (ES, R1, R2, L)Z -> (ES, R1)Z + // (Entity, Runnable, Runnable, Long)Boolean -> (Entity, Runnable1)Boolean executeForPlayer = insertArguments(executeForPlayer, 2, THROW_IF_RETIRED, 0); - // (ES, R1)Z -> (ES, R1)V + // (Entity, Runnable1)Boolean -> (Entity, Runnable1)boolean executeForPlayer = dropReturn(executeForPlayer); MethodHandle getScheduler = lookup.findVirtual( org.bukkit.entity.Entity.class, "getScheduler", methodType(entitySchedulerClass) ); - // (ES, R1)V -> (E, R1)V + // (Entity, Runnable1)V -> (Entity, Runnable1)V executeForPlayer = filterArguments(executeForPlayer, 0, getScheduler); MethodType finalType = methodType(void.class, org.bukkit.entity.Player.class, Runnable.class); - // (ES, R1)V -> (P, R1)V + // (Entity, Runnable1)V -> (Player, Runnable1)V executeForPlayer = explicitCastArguments(executeForPlayer, finalType); } catch (Throwable throwable) { throw new AssertionError(throwable); From 7f1765e85e4a6a9ed78da8fe4263a10afbee551f Mon Sep 17 00:00:00 2001 From: Phillipp Glanz Date: Tue, 19 Sep 2023 17:32:03 +0200 Subject: [PATCH 2/3] Use ticking thread method instead main thread method --- .../impl/fawe/v1_20_R1/PaperweightFaweWorldNativeAccess.java | 4 ++-- .../impl/fawe/v1_20_R1/PaperweightPlatformAdapter.java | 4 ++-- .../java/com/fastasyncworldedit/core/util/TaskManager.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightFaweWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightFaweWorldNativeAccess.java index 8cd120531b..6b41acb4de 100644 --- a/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightFaweWorldNativeAccess.java +++ b/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightFaweWorldNativeAccess.java @@ -138,7 +138,7 @@ public synchronized net.minecraft.world.level.block.state.BlockState setBlockSta } else { currentTick = MinecraftServer.currentTick; } - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { return levelChunk.setBlockState(blockPos, blockState, this.sideEffectSet != null && this.sideEffectSet.shouldApply(SideEffect.UPDATE) ); @@ -309,7 +309,7 @@ public void run(Object value) { } } }; - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { runnableVal.run(); } else { TaskManager.taskManager().sync(runnableVal); diff --git a/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightPlatformAdapter.java b/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightPlatformAdapter.java index 714efe35c2..1696134d1c 100644 --- a/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightPlatformAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightPlatformAdapter.java @@ -286,7 +286,7 @@ public static LevelChunk ensureLoaded(ServerLevel serverLevel, int chunkX, int c if (nmsChunk != null) { return nmsChunk; } - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { return serverLevel.getChunk(chunkX, chunkZ); } } else { @@ -301,7 +301,7 @@ public static LevelChunk ensureLoaded(ServerLevel serverLevel, int chunkX, int c return nmsChunk; } // Avoid "async" methods from the main thread. - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { return serverLevel.getChunk(chunkX, chunkZ); } if (FOLIA_SUPPORT) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TaskManager.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TaskManager.java index 25923b2071..4b8b170f5a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TaskManager.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/TaskManager.java @@ -173,13 +173,13 @@ public void parallel(Collection runnables, @Nullable Integer numThread @Deprecated public void runUnsafe(Runnable run) { QueueHandler queue = Fawe.instance().getQueueHandler(); - queue.startUnsafe(Fawe.isMainThread()); + queue.startUnsafe(Fawe.isTickThread()); try { run.run(); } catch (Throwable e) { e.printStackTrace(); } - queue.endUnsafe(Fawe.isMainThread()); + queue.endUnsafe(Fawe.isTickThread()); } /** From a7d2112eeedcb9563bdcad7f942b31fa4f6ea0de Mon Sep 17 00:00:00 2001 From: Phillipp Glanz Date: Tue, 19 Sep 2023 17:32:07 +0200 Subject: [PATCH 3/3] Use ticking thread method instead main thread method --- .../worldedit/extension/platform/PlatformCommandManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 7b493cf985..9dcce4b13b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -687,7 +687,7 @@ public void handleCommand(CommandEvent event) { Command cmd = optional.get(); PermissionCondition queued = cmd.getCondition().as(PermissionCondition.class).orElse(null); if (queued != null && !queued.isQueued()) { - TaskManager.taskManager().taskNow(() -> handleCommandOnCurrentThread(event), Fawe.isMainThread()); + TaskManager.taskManager().taskNow(() -> handleCommandOnCurrentThread(event), Fawe.isTickThread()); return; } else { actor.decline();