diff --git a/scheduler/scheduler-async/src/main/java/io/github/projectunified/minelib/scheduler/async/AsyncScheduler.java b/scheduler/scheduler-async/src/main/java/io/github/projectunified/minelib/scheduler/async/AsyncScheduler.java index 606137b..1430ce6 100644 --- a/scheduler/scheduler-async/src/main/java/io/github/projectunified/minelib/scheduler/async/AsyncScheduler.java +++ b/scheduler/scheduler-async/src/main/java/io/github/projectunified/minelib/scheduler/async/AsyncScheduler.java @@ -1,12 +1,10 @@ package io.github.projectunified.minelib.scheduler.async; -import com.google.common.cache.LoadingCache; import io.github.projectunified.minelib.scheduler.common.scheduler.Scheduler; import io.github.projectunified.minelib.scheduler.common.task.Task; import io.github.projectunified.minelib.scheduler.common.util.Platform; import org.bukkit.plugin.Plugin; -import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.function.BooleanSupplier; @@ -14,10 +12,6 @@ * A {@link Scheduler} that can run tasks asynchronously */ public interface AsyncScheduler extends Scheduler { - LoadingCache PROVIDER = Scheduler.createProvider( - Platform.FOLIA.isPlatform() ? FoliaAsyncScheduler::new : BukkitAsyncScheduler::new - ); - /** * Get the {@link AsyncScheduler} for the given plugin * @@ -25,11 +19,7 @@ public interface AsyncScheduler extends Scheduler { * @return the scheduler */ static AsyncScheduler get(Plugin plugin) { - try { - return PROVIDER.get(plugin); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } + return Platform.FOLIA.isPlatform() ? new FoliaAsyncScheduler(plugin) : new BukkitAsyncScheduler(plugin); } /** diff --git a/scheduler/scheduler-canceller/src/main/java/io/github/projectunified/minelib/scheduler/canceller/TaskCanceller.java b/scheduler/scheduler-canceller/src/main/java/io/github/projectunified/minelib/scheduler/canceller/TaskCanceller.java index f0bcc80..43e8bda 100644 --- a/scheduler/scheduler-canceller/src/main/java/io/github/projectunified/minelib/scheduler/canceller/TaskCanceller.java +++ b/scheduler/scheduler-canceller/src/main/java/io/github/projectunified/minelib/scheduler/canceller/TaskCanceller.java @@ -1,20 +1,12 @@ package io.github.projectunified.minelib.scheduler.canceller; -import com.google.common.cache.LoadingCache; -import io.github.projectunified.minelib.scheduler.common.scheduler.Scheduler; import io.github.projectunified.minelib.scheduler.common.util.Platform; import org.bukkit.plugin.Plugin; -import java.util.concurrent.ExecutionException; - /** * An interface for cancelling tasks */ public interface TaskCanceller { - LoadingCache PROVIDER = Scheduler.createProvider( - Platform.FOLIA.isPlatform() ? FoliaTaskCanceller::new : BukkitTaskCanceller::new - ); - /** * Get the {@link TaskCanceller} for the given plugin * @@ -22,11 +14,7 @@ public interface TaskCanceller { * @return the {@link TaskCanceller} */ static TaskCanceller get(Plugin plugin) { - try { - return PROVIDER.get(plugin); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } + return Platform.FOLIA.isPlatform() ? new FoliaTaskCanceller(plugin) : new BukkitTaskCanceller(plugin); } /** diff --git a/scheduler/scheduler-common/src/main/java/io/github/projectunified/minelib/scheduler/common/scheduler/Scheduler.java b/scheduler/scheduler-common/src/main/java/io/github/projectunified/minelib/scheduler/common/scheduler/Scheduler.java index 1b6765f..74d6046 100644 --- a/scheduler/scheduler-common/src/main/java/io/github/projectunified/minelib/scheduler/common/scheduler/Scheduler.java +++ b/scheduler/scheduler-common/src/main/java/io/github/projectunified/minelib/scheduler/common/scheduler/Scheduler.java @@ -1,29 +1,13 @@ package io.github.projectunified.minelib.scheduler.common.scheduler; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; import io.github.projectunified.minelib.scheduler.common.task.Task; import java.util.function.BooleanSupplier; -import java.util.function.Function; /** * A scheduler that provides a way to run tasks */ public interface Scheduler { - /** - * Create a provider - * - * @param function the function - * @param the key type - * @param the scheduler type - * @return the provider - */ - static LoadingCache createProvider(Function function) { - return CacheBuilder.newBuilder().weakKeys().build(CacheLoader.from(function::apply)); - } - /** * Run a task * diff --git a/scheduler/scheduler-entity/src/main/java/io/github/projectunified/minelib/scheduler/entity/BukkitEntityScheduler.java b/scheduler/scheduler-entity/src/main/java/io/github/projectunified/minelib/scheduler/entity/BukkitEntityScheduler.java index 017e7fe..c7cd657 100644 --- a/scheduler/scheduler-entity/src/main/java/io/github/projectunified/minelib/scheduler/entity/BukkitEntityScheduler.java +++ b/scheduler/scheduler-entity/src/main/java/io/github/projectunified/minelib/scheduler/entity/BukkitEntityScheduler.java @@ -2,22 +2,26 @@ import io.github.projectunified.minelib.scheduler.common.task.Task; import io.github.projectunified.minelib.scheduler.common.util.task.BukkitTask; +import org.bukkit.entity.Entity; +import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; import java.util.function.BooleanSupplier; class BukkitEntityScheduler implements EntityScheduler { - private final Key key; + private final Plugin plugin; + private final Entity entity; - BukkitEntityScheduler(Key key) { - this.key = key; + BukkitEntityScheduler(Plugin plugin, Entity entity) { + this.plugin = plugin; + this.entity = entity; } private BukkitRunnable wrapRunnable(BooleanSupplier runnable, Runnable retired) { return new BukkitRunnable() { @Override public void run() { - if (key.isEntityValid()) { + if (EntityScheduler.isEntityValid(entity)) { if (!runnable.getAsBoolean()) { cancel(); } @@ -39,21 +43,21 @@ private BukkitRunnable wrapRunnable(Runnable runnable, Runnable retired) { @Override public Task run(Runnable runnable, Runnable retired) { return new BukkitTask( - wrapRunnable(runnable, retired).runTask(key.plugin) + wrapRunnable(runnable, retired).runTask(plugin) ); } @Override public Task runLater(Runnable runnable, Runnable retired, long delay) { return new BukkitTask( - wrapRunnable(runnable, retired).runTaskLater(key.plugin, delay) + wrapRunnable(runnable, retired).runTaskLater(plugin, delay) ); } @Override public Task runTimer(BooleanSupplier runnable, Runnable retired, long delay, long period) { return new BukkitTask( - wrapRunnable(runnable, retired).runTaskTimer(key.plugin, delay, period) + wrapRunnable(runnable, retired).runTaskTimer(plugin, delay, period) ); } } diff --git a/scheduler/scheduler-entity/src/main/java/io/github/projectunified/minelib/scheduler/entity/EntityScheduler.java b/scheduler/scheduler-entity/src/main/java/io/github/projectunified/minelib/scheduler/entity/EntityScheduler.java index e776683..defbe78 100644 --- a/scheduler/scheduler-entity/src/main/java/io/github/projectunified/minelib/scheduler/entity/EntityScheduler.java +++ b/scheduler/scheduler-entity/src/main/java/io/github/projectunified/minelib/scheduler/entity/EntityScheduler.java @@ -1,6 +1,5 @@ package io.github.projectunified.minelib.scheduler.entity; -import com.google.common.cache.LoadingCache; import io.github.projectunified.minelib.scheduler.common.scheduler.Scheduler; import io.github.projectunified.minelib.scheduler.common.task.Task; import io.github.projectunified.minelib.scheduler.common.util.Platform; @@ -8,17 +7,31 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import java.util.Objects; -import java.util.concurrent.ExecutionException; import java.util.function.BooleanSupplier; /** * A {@link Scheduler} that schedules tasks for an {@link Entity} */ public interface EntityScheduler extends Scheduler { - LoadingCache PROVIDER = Scheduler.createProvider( - Platform.FOLIA.isPlatform() ? FoliaEntityScheduler::new : BukkitEntityScheduler::new - ); + /** + * Check if the {@link Entity} is valid. + * This checks if the entity is not null and is still valid. + * For {@link Player} entities, this also checks if the player is online. + * + * @param entity the entity + * @return {@code true} if the entity is valid + */ + static boolean isEntityValid(Entity entity) { + if (entity == null) { + return false; + } + + if (entity instanceof Player) { + return ((Player) entity).isOnline(); + } + + return entity.isValid(); + } /** * Get the {@link EntityScheduler} for the given {@link Plugin} and {@link Entity} @@ -28,11 +41,9 @@ public interface EntityScheduler extends Scheduler { * @return the scheduler */ static EntityScheduler get(Plugin plugin, Entity entity) { - try { - return PROVIDER.get(new Key(plugin, entity)); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } + return Platform.FOLIA.isPlatform() + ? new FoliaEntityScheduler(plugin, entity) + : new BukkitEntityScheduler(plugin, entity); } /** @@ -98,47 +109,4 @@ default Task runTimer(BooleanSupplier runnable, long delay, long period) { return runTimer(runnable, () -> { }, delay, period); } - - /** - * A key for the {@link EntityScheduler} - */ - class Key { - public final Plugin plugin; - public final Entity entity; - - public Key(Plugin plugin, Entity entity) { - this.plugin = plugin; - this.entity = entity; - } - - /** - * Check if the entity is valid - * - * @return true if the entity is valid - */ - public boolean isEntityValid() { - if (entity == null) { - return false; - } - - if (entity instanceof Player) { - return ((Player) entity).isOnline(); - } - - return entity.isValid(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Key key = (Key) o; - return Objects.equals(plugin, key.plugin) && Objects.equals(entity, key.entity); - } - - @Override - public int hashCode() { - return Objects.hash(plugin, entity); - } - } } diff --git a/scheduler/scheduler-entity/src/main/java/io/github/projectunified/minelib/scheduler/entity/FoliaEntityScheduler.java b/scheduler/scheduler-entity/src/main/java/io/github/projectunified/minelib/scheduler/entity/FoliaEntityScheduler.java index 369493a..180a418 100644 --- a/scheduler/scheduler-entity/src/main/java/io/github/projectunified/minelib/scheduler/entity/FoliaEntityScheduler.java +++ b/scheduler/scheduler-entity/src/main/java/io/github/projectunified/minelib/scheduler/entity/FoliaEntityScheduler.java @@ -4,6 +4,8 @@ import io.github.projectunified.minelib.scheduler.common.util.task.FoliaTask; import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.Bukkit; +import org.bukkit.entity.Entity; +import org.bukkit.plugin.Plugin; import java.util.function.BooleanSupplier; @@ -11,19 +13,21 @@ import static io.github.projectunified.minelib.scheduler.common.util.task.FoliaTask.wrapRunnable; class FoliaEntityScheduler implements EntityScheduler { - private final Key key; + private final Plugin plugin; + private final Entity entity; - FoliaEntityScheduler(Key key) { - this.key = key; + FoliaEntityScheduler(Plugin plugin, Entity entity) { + this.plugin = plugin; + this.entity = entity; } @Override public Task run(Runnable runnable, Runnable retired) { ScheduledTask scheduledTask; - if (key.isEntityValid()) { - scheduledTask = key.entity.getScheduler().run(key.plugin, wrapRunnable(runnable), retired); + if (EntityScheduler.isEntityValid(entity)) { + scheduledTask = entity.getScheduler().run(plugin, wrapRunnable(runnable), retired); } else { - scheduledTask = Bukkit.getGlobalRegionScheduler().run(key.plugin, wrapRunnable(retired)); + scheduledTask = Bukkit.getGlobalRegionScheduler().run(plugin, wrapRunnable(retired)); } return new FoliaTask(scheduledTask); } @@ -31,10 +35,10 @@ public Task run(Runnable runnable, Runnable retired) { @Override public Task runLater(Runnable runnable, Runnable retired, long delay) { ScheduledTask scheduledTask; - if (key.isEntityValid()) { - scheduledTask = key.entity.getScheduler().runDelayed(key.plugin, wrapRunnable(runnable), retired, normalizedTicks(delay)); + if (EntityScheduler.isEntityValid(entity)) { + scheduledTask = entity.getScheduler().runDelayed(plugin, wrapRunnable(runnable), retired, normalizedTicks(delay)); } else { - scheduledTask = Bukkit.getGlobalRegionScheduler().runDelayed(key.plugin, wrapRunnable(retired), normalizedTicks(delay)); + scheduledTask = Bukkit.getGlobalRegionScheduler().runDelayed(plugin, wrapRunnable(retired), normalizedTicks(delay)); } return new FoliaTask(scheduledTask); } @@ -42,10 +46,10 @@ public Task runLater(Runnable runnable, Runnable retired, long delay) { @Override public Task runTimer(BooleanSupplier runnable, Runnable retired, long delay, long period) { ScheduledTask scheduledTask; - if (key.isEntityValid()) { - scheduledTask = key.entity.getScheduler().runAtFixedRate(key.plugin, wrapRunnable(runnable), retired, normalizedTicks(delay), normalizedTicks(period)); + if (EntityScheduler.isEntityValid(entity)) { + scheduledTask = entity.getScheduler().runAtFixedRate(plugin, wrapRunnable(runnable), retired, normalizedTicks(delay), normalizedTicks(period)); } else { - scheduledTask = Bukkit.getGlobalRegionScheduler().runDelayed(key.plugin, wrapRunnable(retired), normalizedTicks(delay)); + scheduledTask = Bukkit.getGlobalRegionScheduler().runDelayed(plugin, wrapRunnable(retired), normalizedTicks(delay)); } return new FoliaTask(scheduledTask); } diff --git a/scheduler/scheduler-global/src/main/java/io/github/projectunified/minelib/scheduler/global/GlobalScheduler.java b/scheduler/scheduler-global/src/main/java/io/github/projectunified/minelib/scheduler/global/GlobalScheduler.java index 187544c..31bcf5d 100644 --- a/scheduler/scheduler-global/src/main/java/io/github/projectunified/minelib/scheduler/global/GlobalScheduler.java +++ b/scheduler/scheduler-global/src/main/java/io/github/projectunified/minelib/scheduler/global/GlobalScheduler.java @@ -1,20 +1,13 @@ package io.github.projectunified.minelib.scheduler.global; -import com.google.common.cache.LoadingCache; import io.github.projectunified.minelib.scheduler.common.scheduler.Scheduler; import io.github.projectunified.minelib.scheduler.common.util.Platform; import org.bukkit.plugin.Plugin; -import java.util.concurrent.ExecutionException; - /** * A {@link Scheduler} that can run tasks globally */ public interface GlobalScheduler extends Scheduler { - LoadingCache PROVIDER = Scheduler.createProvider( - Platform.FOLIA.isPlatform() ? FoliaGlobalScheduler::new : BukkitGlobalScheduler::new - ); - /** * Get the {@link GlobalScheduler} for the given plugin * @@ -22,10 +15,6 @@ public interface GlobalScheduler extends Scheduler { * @return the scheduler */ static GlobalScheduler get(Plugin plugin) { - try { - return PROVIDER.get(plugin); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } + return Platform.FOLIA.isPlatform() ? new FoliaGlobalScheduler(plugin) : new BukkitGlobalScheduler(plugin); } } diff --git a/scheduler/scheduler-location/src/main/java/io/github/projectunified/minelib/scheduler/location/FoliaLocationScheduler.java b/scheduler/scheduler-location/src/main/java/io/github/projectunified/minelib/scheduler/location/FoliaLocationScheduler.java index 05312ce..9d3846f 100644 --- a/scheduler/scheduler-location/src/main/java/io/github/projectunified/minelib/scheduler/location/FoliaLocationScheduler.java +++ b/scheduler/scheduler-location/src/main/java/io/github/projectunified/minelib/scheduler/location/FoliaLocationScheduler.java @@ -3,6 +3,8 @@ import io.github.projectunified.minelib.scheduler.common.task.Task; import io.github.projectunified.minelib.scheduler.common.util.task.FoliaTask; import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.plugin.Plugin; import java.util.function.BooleanSupplier; @@ -10,30 +12,32 @@ import static io.github.projectunified.minelib.scheduler.common.util.task.FoliaTask.wrapRunnable; class FoliaLocationScheduler implements LocationScheduler { - private final Key key; + private final Plugin plugin; + private final Location location; - FoliaLocationScheduler(Key key) { - this.key = key; + FoliaLocationScheduler(Plugin plugin, Location location) { + this.plugin = plugin; + this.location = location; } @Override public Task run(Runnable runnable) { return new FoliaTask( - Bukkit.getRegionScheduler().run(key.plugin, key.location, wrapRunnable(runnable)) + Bukkit.getRegionScheduler().run(plugin, location, wrapRunnable(runnable)) ); } @Override public Task runLater(Runnable runnable, long delay) { return new FoliaTask( - Bukkit.getRegionScheduler().runDelayed(key.plugin, key.location, wrapRunnable(runnable), normalizedTicks(delay)) + Bukkit.getRegionScheduler().runDelayed(plugin, location, wrapRunnable(runnable), normalizedTicks(delay)) ); } @Override public Task runTimer(BooleanSupplier runnable, long delay, long period) { return new FoliaTask( - Bukkit.getRegionScheduler().runAtFixedRate(key.plugin, key.location, wrapRunnable(runnable), normalizedTicks(delay), normalizedTicks(period)) + Bukkit.getRegionScheduler().runAtFixedRate(plugin, location, wrapRunnable(runnable), normalizedTicks(delay), normalizedTicks(period)) ); } } diff --git a/scheduler/scheduler-location/src/main/java/io/github/projectunified/minelib/scheduler/location/LocationScheduler.java b/scheduler/scheduler-location/src/main/java/io/github/projectunified/minelib/scheduler/location/LocationScheduler.java index 89183bc..84b8ff0 100644 --- a/scheduler/scheduler-location/src/main/java/io/github/projectunified/minelib/scheduler/location/LocationScheduler.java +++ b/scheduler/scheduler-location/src/main/java/io/github/projectunified/minelib/scheduler/location/LocationScheduler.java @@ -1,22 +1,14 @@ package io.github.projectunified.minelib.scheduler.location; -import com.google.common.cache.LoadingCache; import io.github.projectunified.minelib.scheduler.common.scheduler.Scheduler; import io.github.projectunified.minelib.scheduler.common.util.Platform; import org.bukkit.Location; import org.bukkit.plugin.Plugin; -import java.util.Objects; -import java.util.concurrent.ExecutionException; - /** * A {@link Scheduler} that schedules tasks for a {@link Location} */ public interface LocationScheduler extends Scheduler { - LoadingCache PROVIDER = Scheduler.createProvider( - Platform.FOLIA.isPlatform() ? FoliaLocationScheduler::new : k -> new BukkitLocationScheduler(k.plugin) - ); - /** * Get the {@link LocationScheduler} for the given {@link Plugin} and {@link Location} * @@ -25,36 +17,8 @@ public interface LocationScheduler extends Scheduler { * @return the scheduler */ static LocationScheduler get(Plugin plugin, Location location) { - try { - return PROVIDER.get(new Key(plugin, location)); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } - } - - /** - * A key for a {@link LocationScheduler} - */ - class Key { - public final Plugin plugin; - public final Location location; - - public Key(Plugin plugin, Location location) { - this.plugin = plugin; - this.location = location; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Key key = (Key) o; - return Objects.equals(plugin, key.plugin) && Objects.equals(location, key.location); - } - - @Override - public int hashCode() { - return Objects.hash(plugin, location); - } + return Platform.FOLIA.isPlatform() + ? new FoliaLocationScheduler(plugin, location) + : new BukkitLocationScheduler(plugin); } } diff --git a/scheduler/scheduler-region/src/main/java/io/github/projectunified/minelib/scheduler/region/FoliaRegionScheduler.java b/scheduler/scheduler-region/src/main/java/io/github/projectunified/minelib/scheduler/region/FoliaRegionScheduler.java index bed5cc0..8b1c1bb 100644 --- a/scheduler/scheduler-region/src/main/java/io/github/projectunified/minelib/scheduler/region/FoliaRegionScheduler.java +++ b/scheduler/scheduler-region/src/main/java/io/github/projectunified/minelib/scheduler/region/FoliaRegionScheduler.java @@ -3,6 +3,8 @@ import io.github.projectunified.minelib.scheduler.common.task.Task; import io.github.projectunified.minelib.scheduler.common.util.task.FoliaTask; import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.plugin.Plugin; import java.util.function.BooleanSupplier; @@ -10,30 +12,36 @@ import static io.github.projectunified.minelib.scheduler.common.util.task.FoliaTask.wrapRunnable; class FoliaRegionScheduler implements RegionScheduler { - private final Key key; - - FoliaRegionScheduler(Key key) { - this.key = key; + private final Plugin plugin; + private final World world; + private final int chunkX; + private final int chunkZ; + + FoliaRegionScheduler(Plugin plugin, World world, int chunkX, int chunkZ) { + this.plugin = plugin; + this.world = world; + this.chunkX = chunkX; + this.chunkZ = chunkZ; } @Override public Task run(Runnable runnable) { return new FoliaTask( - Bukkit.getRegionScheduler().run(key.plugin, key.world, key.chunkX, key.chunkZ, wrapRunnable(runnable)) + Bukkit.getRegionScheduler().run(plugin, world, chunkX, chunkZ, wrapRunnable(runnable)) ); } @Override public Task runLater(Runnable runnable, long delay) { return new FoliaTask( - Bukkit.getRegionScheduler().runDelayed(key.plugin, key.world, key.chunkX, key.chunkZ, wrapRunnable(runnable), normalizedTicks(delay)) + Bukkit.getRegionScheduler().runDelayed(plugin, world, chunkX, chunkZ, wrapRunnable(runnable), normalizedTicks(delay)) ); } @Override public Task runTimer(BooleanSupplier runnable, long delay, long period) { return new FoliaTask( - Bukkit.getRegionScheduler().runAtFixedRate(key.plugin, key.world, key.chunkX, key.chunkZ, wrapRunnable(runnable), normalizedTicks(delay), normalizedTicks(period)) + Bukkit.getRegionScheduler().runAtFixedRate(plugin, world, chunkX, chunkZ, wrapRunnable(runnable), normalizedTicks(delay), normalizedTicks(period)) ); } } diff --git a/scheduler/scheduler-region/src/main/java/io/github/projectunified/minelib/scheduler/region/RegionScheduler.java b/scheduler/scheduler-region/src/main/java/io/github/projectunified/minelib/scheduler/region/RegionScheduler.java index 4bcff72..102560e 100644 --- a/scheduler/scheduler-region/src/main/java/io/github/projectunified/minelib/scheduler/region/RegionScheduler.java +++ b/scheduler/scheduler-region/src/main/java/io/github/projectunified/minelib/scheduler/region/RegionScheduler.java @@ -1,22 +1,16 @@ package io.github.projectunified.minelib.scheduler.region; -import com.google.common.cache.LoadingCache; import io.github.projectunified.minelib.scheduler.common.scheduler.Scheduler; import io.github.projectunified.minelib.scheduler.common.util.Platform; import org.bukkit.World; import org.bukkit.plugin.Plugin; import java.util.Objects; -import java.util.concurrent.ExecutionException; /** * A {@link Scheduler} that schedules tasks for a region */ public interface RegionScheduler extends Scheduler { - LoadingCache PROVIDER = Scheduler.createProvider( - Platform.FOLIA.isPlatform() ? FoliaRegionScheduler::new : k -> new BukkitRegionScheduler(k.plugin) - ); - /** * Get the {@link RegionScheduler} for the given {@link Plugin}, {@link World}, and chunk coordinates * @@ -27,11 +21,9 @@ public interface RegionScheduler extends Scheduler { * @return the scheduler */ static RegionScheduler get(Plugin plugin, World world, int chunkX, int chunkZ) { - try { - return PROVIDER.get(new Key(plugin, world, chunkX, chunkZ)); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } + return Platform.FOLIA.isPlatform() + ? new FoliaRegionScheduler(plugin, world, chunkX, chunkZ) + : new BukkitRegionScheduler(plugin); } /**