From 9d093228377b43543e4946f3602592213c394839 Mon Sep 17 00:00:00 2001 From: Phillipp Glanz Date: Mon, 3 Apr 2023 12:21:14 +0200 Subject: [PATCH] Use new method to check of is running on "main thread" --- .../PaperweightFaweWorldNativeAccess.java | 4 ++-- .../v1_17_R1_2/PaperweightPlatformAdapter.java | 4 ++-- .../v1_18_R2/PaperweightFaweWorldNativeAccess.java | 4 ++-- .../fawe/v1_18_R2/PaperweightPlatformAdapter.java | 4 ++-- .../v1_19_R3/PaperweightFaweWorldNativeAccess.java | 4 ++-- .../fawe/v1_19_R3/PaperweightPlatformAdapter.java | 4 ++-- .../v1_19_R3/PaperweightFaweWorldNativeAccess.java | 4 ++-- .../fawe/v1_19_R3/PaperweightPlatformAdapter.java | 4 ++-- .../plotsquared/FaweDelegateSchematicHandler.java | 2 +- .../com/sk89q/worldedit/bukkit/BukkitWorld.java | 2 +- .../com/fastasyncworldedit/core/FaweCache.java | 2 +- .../core/entity/LazyBaseEntity.java | 2 +- .../fastasyncworldedit/core/extent/SlowExtent.java | 2 +- .../core/history/changeset/AbstractChangeSet.java | 2 +- .../core/queue/implementation/QueueHandler.java | 8 ++++---- .../implementation/SingleThreadQueueExtent.java | 2 +- .../fastasyncworldedit/core/util/TaskManager.java | 14 +++++++------- .../com/sk89q/worldedit/EditSessionBuilder.java | 2 +- 18 files changed, 35 insertions(+), 35 deletions(-) diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java index 282a6b505..9bb5249ff 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java @@ -95,7 +95,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess future = serverLevel.getWorld().getChunkAtAsync(chunkX, chunkZ, true, true); diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightFaweWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightFaweWorldNativeAccess.java index ef7fc98ac..f15f48d70 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightFaweWorldNativeAccess.java +++ b/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightFaweWorldNativeAccess.java @@ -95,7 +95,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess future = serverLevel.getWorld().getChunkAtAsync(chunkX, chunkZ, true, true); diff --git a/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightFaweWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightFaweWorldNativeAccess.java index dbe0150a9..866c6b559 100644 --- a/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightFaweWorldNativeAccess.java +++ b/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightFaweWorldNativeAccess.java @@ -95,7 +95,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess future = serverLevel.getWorld().getChunkAtAsync(chunkX, chunkZ, true, true); diff --git a/worldedit-bukkit/folia-adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/folia/adapter/impl/fawe/v1_19_R3/PaperweightFaweWorldNativeAccess.java b/worldedit-bukkit/folia-adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/folia/adapter/impl/fawe/v1_19_R3/PaperweightFaweWorldNativeAccess.java index b1aceaf73..83ecec303 100644 --- a/worldedit-bukkit/folia-adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/folia/adapter/impl/fawe/v1_19_R3/PaperweightFaweWorldNativeAccess.java +++ b/worldedit-bukkit/folia-adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/folia/adapter/impl/fawe/v1_19_R3/PaperweightFaweWorldNativeAccess.java @@ -95,7 +95,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess future = serverLevel.getWorld().getChunkAtAsync(chunkX, chunkZ, true, true); diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java index 6cf09da28..8a65bfd68 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java @@ -160,7 +160,7 @@ public class FaweDelegateSchematicHandler { } } }; - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { com.fastasyncworldedit.core.util.TaskManager.taskManager().async(r); } else { r.run(); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index a9ba45afe..710b32d5b 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -365,7 +365,7 @@ public class BukkitWorld extends AbstractWorld { //FAWE start int X = pt.getBlockX() >> 4; int Z = pt.getBlockZ() >> 4; - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { world.getChunkAt(X, Z); } else if (PaperLib.isPaper()) { PaperLib.getChunkAtAsync(world, X, Z, true); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java index 0655e4214..6cf1b19a0 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/FaweCache.java @@ -156,7 +156,7 @@ public enum FaweCache implements Trimable { */ public LongFunction createMainThreadSafeCache(Supplier withInitial) { return new LongFunction<>() { - private final LoadingCache loadingCache = Fawe.isMainThread() ? null : FaweCache.INSTANCE.createCache( + private final LoadingCache loadingCache = Fawe.isTickThread() ? null : FaweCache.INSTANCE.createCache( withInitial); @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/LazyBaseEntity.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/LazyBaseEntity.java index f591cf826..cd8325cd2 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/LazyBaseEntity.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/entity/LazyBaseEntity.java @@ -24,7 +24,7 @@ public class LazyBaseEntity extends BaseEntity { Supplier tmp = saveTag; if (tmp != null) { saveTag = null; - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { setNbt(tmp.get()); } else { setNbt(TaskManager.taskManager().sync(tmp)); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/SlowExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/SlowExtent.java index 6aa07b116..78f299f07 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/SlowExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/SlowExtent.java @@ -27,7 +27,7 @@ public class SlowExtent extends AbstractDelegateExtent { increment += nanos; if (increment >= THRESHOLD) { long wait = increment / 1000000; - if (!Fawe.isMainThread()) { + if (!Fawe.isTickThread()) { try { Thread.sleep(wait); } catch (InterruptedException e) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java index 4bbe1a109..018a95dd4 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java @@ -353,7 +353,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { } public Future addWriteTask(Runnable writeTask) { - return addWriteTask(writeTask, Fawe.isMainThread()); + return addWriteTask(writeTask, Fawe.isTickThread()); } public Future addWriteTask(final Runnable writeTask, final boolean completeNow) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/QueueHandler.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/QueueHandler.java index 992c11716..cef80cbb6 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/QueueHandler.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/QueueHandler.java @@ -317,7 +317,7 @@ public abstract class QueueHandler implements Trimable, Runnable { } private Future sync(Runnable run, T value, Queue queue) { - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { run.run(); return Futures.immediateFuture(value); } @@ -328,7 +328,7 @@ public abstract class QueueHandler implements Trimable, Runnable { } private Future sync(Runnable run, Queue queue) { - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { run.run(); return Futures.immediateCancelledFuture(); } @@ -339,7 +339,7 @@ public abstract class QueueHandler implements Trimable, Runnable { } private Future sync(Callable call, Queue queue) throws Exception { - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { return Futures.immediateFuture(call.call()); } final FutureTask result = new FutureTask<>(call); @@ -349,7 +349,7 @@ public abstract class QueueHandler implements Trimable, Runnable { } private Future sync(Supplier call, Queue queue) { - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { return Futures.immediateFuture(call.get()); } final FutureTask result = new FutureTask<>(call::get); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java index 34dd5191e..e2e34c4f0 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/SingleThreadQueueExtent.java @@ -239,7 +239,7 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen } } - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { V result = (V) chunk.call(); if (result == null) { return (V) (Future) Futures.immediateFuture(null); 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 69a16b437..25923b207 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 @@ -205,7 +205,7 @@ public abstract class TaskManager { */ @Deprecated public void taskNowMain(@Nonnull final Runnable runnable) { - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { runnable.run(); } else { task(runnable); @@ -216,10 +216,10 @@ public abstract class TaskManager { * Run a task as soon as possible not on the main thread. * * @param runnable the task to run - * @see Fawe#isMainThread() + * @see Fawe#isTickThread() */ public void taskNowAsync(@Nonnull final Runnable runnable) { - taskNow(runnable, Fawe.isMainThread()); + taskNow(runnable, Fawe.isTickThread()); } /** @@ -326,7 +326,7 @@ public abstract class TaskManager { @Deprecated public void taskWhenFree(@Nonnull Runnable run) { - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { run.run(); } else { Fawe.instance().getQueueHandler().sync(run); @@ -340,7 +340,7 @@ public abstract class TaskManager { */ @Deprecated public T syncWhenFree(@Nonnull final RunnableVal function) { - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { function.run(); return function.value; } @@ -358,7 +358,7 @@ public abstract class TaskManager { */ @Deprecated public T syncWhenFree(@Nonnull final Supplier supplier) { - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { return supplier.get(); } try { @@ -385,7 +385,7 @@ public abstract class TaskManager { */ @Deprecated public T sync(final Supplier function) { - if (Fawe.isMainThread()) { + if (Fawe.isTickThread()) { return function.get(); } try { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java index ca6f3b6a5..4dfd17638 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSessionBuilder.java @@ -469,7 +469,7 @@ public final class EditSessionBuilder { wnaMode = false; if (unwrapped instanceof IQueueExtent) { extent = queue = (IQueueExtent) unwrapped; - } else if (Settings.settings().QUEUE.PARALLEL_THREADS > 1 && !Fawe.isMainThread()) { + } else if (Settings.settings().QUEUE.PARALLEL_THREADS > 1 && !Fawe.isTickThread()) { ParallelQueueExtent parallel = new ParallelQueueExtent(Fawe.instance().getQueueHandler(), world, fastMode); queue = parallel.getExtent(); extent = parallel;