mirror of
https://github.com/kaboomserver/extras.git
synced 2024-05-20 20:11:21 +00:00
Run un-forceload task on global region scheduler
This commit is contained in:
parent
20eb65c607
commit
c4237df1ff
|
@ -13,4 +13,5 @@ public interface IScheduler {
|
|||
void runSync(final Plugin plugin, final Runnable runnable);
|
||||
void runAsync(final Plugin plugin, final Runnable runnable);
|
||||
void executeOnChunk(final Plugin plugin, final Chunk chunk, final Runnable runnable);
|
||||
void executeOnGlobalRegion(final Plugin plugin, final Runnable runnable);
|
||||
}
|
||||
|
|
|
@ -39,4 +39,8 @@ public final class PlatformScheduler {
|
|||
final Runnable runnable) {
|
||||
currentScheduler.executeOnChunk(plugin, chunk, runnable);
|
||||
}
|
||||
|
||||
public static void executeOnGlobalRegion(final Plugin plugin, final Runnable runnable) {
|
||||
currentScheduler.executeOnGlobalRegion(plugin, runnable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package pw.kaboom.extras.platform.folia;
|
||||
|
||||
import io.papermc.paper.threadedregions.scheduler.AsyncScheduler;
|
||||
import io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler;
|
||||
import io.papermc.paper.threadedregions.scheduler.RegionScheduler;
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -15,6 +16,8 @@ import java.util.function.Consumer;
|
|||
public final class FoliaScheduler implements IScheduler {
|
||||
private static final AsyncScheduler ASYNC_SCHEDULER = Bukkit.getAsyncScheduler();
|
||||
private static final RegionScheduler REGION_SCHEDULER = Bukkit.getRegionScheduler();
|
||||
private static final GlobalRegionScheduler GLOBAL_REGION_SCHEDULER =
|
||||
Bukkit.getGlobalRegionScheduler();
|
||||
|
||||
@Override
|
||||
public void runRepeating(final Plugin plugin, final Runnable runnable,
|
||||
|
@ -48,6 +51,11 @@ public final class FoliaScheduler implements IScheduler {
|
|||
REGION_SCHEDULER.execute(plugin, world, chunkX, chunkZ, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOnGlobalRegion(final Plugin plugin, final Runnable runnable) {
|
||||
GLOBAL_REGION_SCHEDULER.execute(plugin, runnable);
|
||||
}
|
||||
|
||||
private static final class FoliaTask implements Consumer<ScheduledTask> {
|
||||
private final Runnable runnable;
|
||||
|
||||
|
|
|
@ -45,4 +45,9 @@ public final class PaperScheduler implements IScheduler {
|
|||
public void executeOnChunk(final Plugin plugin, final Chunk chunk, final Runnable runnable) {
|
||||
BUKKIT_SCHEDULER.runTask(plugin, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOnGlobalRegion(final Plugin plugin, final Runnable runnable) {
|
||||
BUKKIT_SCHEDULER.runTask(plugin, runnable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public final class BlockCheck implements Listener {
|
|||
final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
for (Chunk chunk : event.getChunk().getWorld().getForceLoadedChunks()) {
|
||||
PlatformScheduler.executeOnChunk(plugin, chunk, () -> chunk.setForceLoaded(false));
|
||||
PlatformScheduler.executeOnGlobalRegion(plugin, () -> chunk.setForceLoaded(false));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue