Added folia support
This commit is contained in:
@@ -27,7 +27,7 @@ public class Prerequisite {
|
||||
*/
|
||||
public static final Prerequisite HAS_PAPER = new Prerequisite(
|
||||
() -> ClassUtils.exists("com.destroystokyo.paper.event.block.BeaconEffectEvent"),
|
||||
"Requires server to be running paper (or a fork)"
|
||||
"Requires server to be running paper"
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ public class Prerequisite {
|
||||
@Deprecated(since = "6.49.0", forRemoval = true)
|
||||
public static final Prerequisite HAS_BUNGEECORD = new Prerequisite(
|
||||
() -> ClassUtils.exists("net.md_5.bungee.api.event.ServerConnectedEvent"),
|
||||
"Requires server to be running BungeeCord (or a fork)"
|
||||
"Requires server to be running BungeeCord"
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -95,7 +95,15 @@ public class Prerequisite {
|
||||
@Deprecated(since = "6.49.0", forRemoval = true)
|
||||
public static final Prerequisite HAS_VELOCITY = new Prerequisite(
|
||||
() -> ClassUtils.exists("com.velocitypowered.api.event.player.ServerConnectedEvent"),
|
||||
"Requires server to be running Velocity (or a fork)"
|
||||
"Requires server to be running Velocity"
|
||||
);
|
||||
|
||||
/**
|
||||
* Requires the server to be running an implementation of Folia.
|
||||
*/
|
||||
public static final Prerequisite HAS_FOLIA = new Prerequisite(
|
||||
() -> ClassUtils.exists("io.papermc.paper.threadedregions.scheduler.RegionisedScheduler"),
|
||||
"Requires server to be running Folia!"
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.willfp.eco.core.scheduling;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -14,9 +16,13 @@ public interface Scheduler {
|
||||
* @param runnable The lambda to run.
|
||||
* @param ticksLater The amount of ticks to wait before execution.
|
||||
* @return The created {@link BukkitTask}.
|
||||
* @deprecated Does not work with Folia.
|
||||
*/
|
||||
BukkitTask runLater(@NotNull Runnable runnable,
|
||||
long ticksLater);
|
||||
@Deprecated(since = "6.53.0", forRemoval = true)
|
||||
default BukkitTask runLater(@NotNull Runnable runnable,
|
||||
long ticksLater) {
|
||||
return runLater(new Location(Bukkit.getWorlds().get(0), 0, 0, 0), (int) ticksLater, runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task after a specified tick delay.
|
||||
@@ -26,10 +32,12 @@ public interface Scheduler {
|
||||
* @param runnable The lambda to run.
|
||||
* @param ticksLater The amount of ticks to wait before execution.
|
||||
* @return The created {@link BukkitTask}.
|
||||
* @deprecated Does not work with Folia.
|
||||
*/
|
||||
@Deprecated(since = "6.53.0", forRemoval = true)
|
||||
default BukkitTask runLater(long ticksLater,
|
||||
@NotNull Runnable runnable) {
|
||||
return runLater(runnable, ticksLater);
|
||||
return runLater(new Location(Bukkit.getWorlds().get(0), 0, 0, 0), (int) ticksLater, runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,10 +47,14 @@ public interface Scheduler {
|
||||
* @param delay The amount of ticks to wait before the first execution.
|
||||
* @param repeat The amount of ticks to wait between executions.
|
||||
* @return The created {@link BukkitTask}.
|
||||
* @deprecated Does not work with Folia.
|
||||
*/
|
||||
BukkitTask runTimer(@NotNull Runnable runnable,
|
||||
long delay,
|
||||
long repeat);
|
||||
@Deprecated(since = "6.53.0", forRemoval = true)
|
||||
default BukkitTask runTimer(@NotNull Runnable runnable,
|
||||
long delay,
|
||||
long repeat) {
|
||||
return runTimer(new Location(Bukkit.getWorlds().get(0), 0, 0, 0), (int) delay, (int) repeat, runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task repeatedly on a timer.
|
||||
@@ -53,11 +65,13 @@ public interface Scheduler {
|
||||
* @param delay The amount of ticks to wait before the first execution.
|
||||
* @param repeat The amount of ticks to wait between executions.
|
||||
* @return The created {@link BukkitTask}.
|
||||
* @deprecated Does not work with Folia.
|
||||
*/
|
||||
@Deprecated(since = "6.53.0", forRemoval = true)
|
||||
default BukkitTask runTimer(long delay,
|
||||
long repeat,
|
||||
@NotNull Runnable runnable) {
|
||||
return runTimer(runnable, delay, repeat);
|
||||
return runTimer(new Location(Bukkit.getWorlds().get(0), 0, 0, 0), (int) delay, (int) repeat, runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,10 +81,14 @@ public interface Scheduler {
|
||||
* @param delay The amount of ticks to wait before the first execution.
|
||||
* @param repeat The amount of ticks to wait between executions.
|
||||
* @return The created {@link BukkitTask}.
|
||||
* @deprecated Does not work with Folia.
|
||||
*/
|
||||
BukkitTask runAsyncTimer(@NotNull Runnable runnable,
|
||||
long delay,
|
||||
long repeat);
|
||||
@Deprecated(since = "6.53.0", forRemoval = true)
|
||||
default BukkitTask runAsyncTimer(@NotNull Runnable runnable,
|
||||
long delay,
|
||||
long repeat) {
|
||||
return runTimerAsync((int) delay, (int) repeat, runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task repeatedly and asynchronously on a timer.
|
||||
@@ -81,11 +99,13 @@ public interface Scheduler {
|
||||
* @param delay The amount of ticks to wait before the first execution.
|
||||
* @param repeat The amount of ticks to wait between executions.
|
||||
* @return The created {@link BukkitTask}.
|
||||
* @deprecated Does not work with Folia.
|
||||
*/
|
||||
@Deprecated(since = "6.53.0", forRemoval = true)
|
||||
default BukkitTask runAsyncTimer(long delay,
|
||||
long repeat,
|
||||
@NotNull Runnable runnable) {
|
||||
return runAsyncTimer(runnable, delay, repeat);
|
||||
return runTimerAsync((int) delay, (int) repeat, runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,28 +113,28 @@ public interface Scheduler {
|
||||
*
|
||||
* @param runnable The lambda to run.
|
||||
* @return The created {@link BukkitTask}.
|
||||
* @deprecated Does not work with Folia.
|
||||
*/
|
||||
BukkitTask run(@NotNull Runnable runnable);
|
||||
@Deprecated(since = "6.53.0", forRemoval = true)
|
||||
default BukkitTask run(@NotNull Runnable runnable) {
|
||||
return run(new Location(Bukkit.getWorlds().get(0), 0, 0, 0), runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the task asynchronously.
|
||||
*
|
||||
* @param runnable The lambda to run.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
BukkitTask runAsync(@NotNull Runnable runnable);
|
||||
|
||||
/**
|
||||
* Schedule the task to be ran repeatedly on a timer.
|
||||
* Schedule the task to be run repeatedly on a timer.
|
||||
*
|
||||
* @param runnable The lambda to run.
|
||||
* @param delay The amount of ticks to wait before the first execution.
|
||||
* @param repeat The amount of ticks to wait between executions.
|
||||
* @return The id of the task.
|
||||
* @deprecated Not needed.
|
||||
*/
|
||||
int syncRepeating(@NotNull Runnable runnable,
|
||||
long delay,
|
||||
long repeat);
|
||||
@Deprecated(since = "6.53.0", forRemoval = true)
|
||||
default int syncRepeating(@NotNull Runnable runnable,
|
||||
long delay,
|
||||
long repeat) {
|
||||
return runTimer(runnable, delay, repeat).getTaskId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule the task to be ran repeatedly on a timer.
|
||||
@@ -125,15 +145,73 @@ public interface Scheduler {
|
||||
* @param delay The amount of ticks to wait before the first execution.
|
||||
* @param repeat The amount of ticks to wait between executions.
|
||||
* @return The id of the task.
|
||||
* @deprecated Not needed.
|
||||
*/
|
||||
@Deprecated(since = "6.53.0", forRemoval = true)
|
||||
default int syncRepeating(long delay,
|
||||
long repeat,
|
||||
@NotNull Runnable runnable) {
|
||||
return syncRepeating(runnable, delay, repeat);
|
||||
return runTimer(runnable, delay, repeat).getTaskId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel all running tasks from the linked {@link EcoPlugin}.
|
||||
*/
|
||||
void cancelAll();
|
||||
|
||||
/**
|
||||
* Run a task asynchronously.
|
||||
*
|
||||
* @param task The lambda to run.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
BukkitTask runAsync(@NotNull Runnable task);
|
||||
|
||||
/**
|
||||
* Run a task.
|
||||
*
|
||||
* @param location The location.
|
||||
* @param task The task.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
BukkitTask run(@NotNull Location location,
|
||||
@NotNull Runnable task);
|
||||
|
||||
/**
|
||||
* Run a task after a delay.
|
||||
*
|
||||
* @param location The location.
|
||||
* @param ticksLater The delay.
|
||||
* @param task The task.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
BukkitTask runLater(@NotNull Location location,
|
||||
int ticksLater,
|
||||
@NotNull Runnable task);
|
||||
|
||||
/**
|
||||
* Run a task on a timer.
|
||||
*
|
||||
* @param location The location.
|
||||
* @param delay The delay.
|
||||
* @param repeat The repeat delay.
|
||||
* @param task The task.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
BukkitTask runTimer(@NotNull Location location,
|
||||
int delay,
|
||||
int repeat,
|
||||
@NotNull Runnable task);
|
||||
|
||||
/**
|
||||
* Run a task asynchronously on a timer.
|
||||
*
|
||||
* @param delay The delay.
|
||||
* @param repeat The repeat delay.
|
||||
* @param task The task.
|
||||
* @return The created {@link BukkitTask}.
|
||||
*/
|
||||
BukkitTask runTimerAsync(int delay,
|
||||
int repeat,
|
||||
@NotNull Runnable task);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user