diff --git a/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightPlatformAdapter.java b/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightPlatformAdapter.java index e086c686b..40d15dd03 100644 --- a/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightPlatformAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightPlatformAdapter.java @@ -58,8 +58,8 @@ import net.minecraft.world.level.chunk.PalettedContainer; import net.minecraft.world.level.chunk.SingleValuePalette; import net.minecraft.world.level.entity.PersistentEntitySectionManager; import org.apache.logging.log4j.Logger; +import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_19_R3.CraftChunk; -import sun.misc.Unsafe; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -283,7 +283,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { } catch (TimeoutException e) { String world = serverLevel.getWorld().getName(); // We've already taken 10 seconds we can afford to wait a little here. - boolean loaded = false; // TODO TaskManager.taskManager().sync(() -> Bukkit.getWorld(world) != null); + boolean loaded = TaskManager.taskManager().syncGlobal(() -> Bukkit.getWorld(world) != null); if (loaded) { LOGGER.warn("Chunk {},{} failed to load in 10 seconds in world {}. Retrying...", chunkX, chunkZ, world); // Retry chunk load 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 12cbb04a3..de8f294db 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 @@ -63,6 +63,7 @@ import net.minecraft.world.level.chunk.PalettedContainer; import net.minecraft.world.level.chunk.SingleValuePalette; import net.minecraft.world.level.entity.PersistentEntitySectionManager; import org.apache.logging.log4j.Logger; +import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R1.CraftChunk; import javax.annotation.Nonnull; @@ -309,7 +310,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { } catch (TimeoutException e) { String world = serverLevel.getWorld().getName(); // We've already taken 10 seconds we can afford to wait a little here. - boolean loaded = false; // TODO TaskManager.taskManager().sync(() -> Bukkit.getWorld(world) != null); + boolean loaded = TaskManager.taskManager().syncGlobal(() -> Bukkit.getWorld(world) != null); if (loaded) { LOGGER.warn("Chunk {},{} failed to load in 10 seconds in world {}. Retrying...", chunkX, chunkZ, world); // Retry chunk load diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/BukkitTaskManager.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/BukkitTaskManager.java index 7c25e996d..ce273febf 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/BukkitTaskManager.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/util/BukkitTaskManager.java @@ -48,6 +48,11 @@ public class BukkitTaskManager extends TaskManager { @Override public void later(@NotNull final Runnable runnable, final Location location, final int delay) { + laterGlobal(runnable, delay); + } + + @Override + public void laterGlobal(@NotNull final Runnable runnable, final int delay) { this.plugin.getServer().getScheduler().runTaskLater(this.plugin, runnable, delay); } 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 c67720bb7..f53656d0a 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 @@ -79,6 +79,15 @@ public class FoliaTaskManager extends TaskManager { ); } + @Override + public void laterGlobal(@NotNull final Runnable runnable, final int delay) { + Bukkit.getGlobalRegionScheduler().runDelayed( + WorldEditPlugin.getInstance(), + asConsumer(runnable), + delay + ); + } + @Override public void laterAsync(@NotNull final Runnable runnable, final int delay) { Bukkit.getAsyncScheduler().runDelayed( diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/Fawe.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/Fawe.java index fda51af9b..430c06ec7 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/Fawe.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/Fawe.java @@ -130,13 +130,12 @@ public class Fawe { this.timer = new FaweTimer(); // Delayed worldedit setup - // TODO support again - /*TaskManager.taskManager().later(() -> { + TaskManager.taskManager().laterGlobal(() -> { try { WEManager.weManager().addManagers(Fawe.this.implementation.getMaskManagers()); } catch (Throwable ignored) { } - }, 0);*/ + }, 0); if (!FoliaSupport.isFolia()) { // TODO TaskManager.taskManager().repeat(timer, 1); 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 56ab75381..40e7085b2 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 @@ -170,7 +170,7 @@ public abstract class TaskManager { } /** - * Run a task later on the main thread. + * Run a task later on the ticking thread at the given location. * * @param runnable the task to run * @param location the location context to run at @@ -178,6 +178,14 @@ public abstract class TaskManager { */ public abstract void later(@Nonnull final Runnable runnable, Location location, final int delay); + /** + * Run a task later on the global tick thread. + * + * @param runnable the task to run + * @param delay in ticks + */ + public abstract void laterGlobal(@Nonnull final Runnable runnable, final int delay); + /** * Run a task later asynchronously. *