Folia Support(dev)

This commit is contained in:
HaHaWTH
2024-01-14 11:03:12 +08:00
parent 68ab92dd7a
commit 885db23fc6
4 changed files with 63 additions and 28 deletions
@@ -1,5 +1,6 @@
package fr.xephi.authme.service;
import com.github.Anon8281.universalScheduler.scheduling.tasks.MyScheduledTask;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.settings.Settings;
@@ -48,10 +49,10 @@ public class BukkitService implements SettingsDependent {
* This task will be executed by the main server thread.
*
* @param task Task to be executed
* @return Task id number (-1 if scheduling failed)
* Task id number (-1 if scheduling failed)
*/
public int scheduleSyncDelayedTask(Runnable task) {
return Bukkit.getScheduler().scheduleSyncDelayedTask(authMe, task);
public void scheduleSyncDelayedTask(Runnable task) {
MyScheduledTask tsk = AuthMe.getScheduler().runTask(task);
}
/**
@@ -59,12 +60,12 @@ public class BukkitService implements SettingsDependent {
* <p>
* This task will be executed by the main server thread.
*
* @param task Task to be executed
* @param task Task to be executed
* @param delay Delay in server ticks before executing task
* @return Task id number (-1 if scheduling failed)
* Task id number (-1 if scheduling failed)
*/
public int scheduleSyncDelayedTask(Runnable task, long delay) {
return Bukkit.getScheduler().scheduleSyncDelayedTask(authMe, task, delay);
public void scheduleSyncDelayedTask(Runnable task, long delay) {
MyScheduledTask tsk = AuthMe.getScheduler().runTaskLater(task, delay);
}
/**
@@ -76,7 +77,7 @@ public class BukkitService implements SettingsDependent {
*/
public void scheduleSyncTaskFromOptionallyAsyncTask(Runnable task) {
if (Bukkit.isPrimaryThread()) {
task.run();
AuthMe.getScheduler().runTask(task);
} else {
scheduleSyncDelayedTask(task);
}
@@ -86,12 +87,12 @@ public class BukkitService implements SettingsDependent {
* Returns a task that will run on the next server tick.
*
* @param task the task to be run
* @return a BukkitTask that contains the id number
* a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null
*/
public BukkitTask runTask(Runnable task) {
return Bukkit.getScheduler().runTask(authMe, task);
public void runTask(Runnable task) {
AuthMe.getScheduler().runTask(task);
}
/**
@@ -105,7 +106,7 @@ public class BukkitService implements SettingsDependent {
* @throws IllegalArgumentException if task is null
*/
public BukkitTask runTaskLater(Runnable task, long delay) {
return Bukkit.getScheduler().runTaskLater(authMe, task, delay);
return (BukkitTask) AuthMe.getScheduler().runTaskLater(task, delay);
}
/**
@@ -116,9 +117,9 @@ public class BukkitService implements SettingsDependent {
*/
public void runTaskOptionallyAsync(Runnable task) {
if (useAsyncTasks) {
runTaskAsynchronously(task);
AuthMe.getScheduler().runTaskAsynchronously(task);
} else {
task.run();
AuthMe.getScheduler().runTask(task);
}
}
@@ -129,12 +130,12 @@ public class BukkitService implements SettingsDependent {
* Returns a task that will run asynchronously.
*
* @param task the task to be run
* @return a BukkitTask that contains the id number
* a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null
*/
public BukkitTask runTaskAsynchronously(Runnable task) {
return Bukkit.getScheduler().runTaskAsynchronously(authMe, task);
public void runTaskAsynchronously(Runnable task) {
AuthMe.getScheduler().runTaskAsynchronously(task);
}
/**
@@ -148,27 +149,27 @@ public class BukkitService implements SettingsDependent {
* @param delay the ticks to wait before running the task for the first
* time
* @param period the ticks to wait between runs
* @return a BukkitTask that contains the id number
* a BukkitTask that contains the id number
* @throws IllegalArgumentException if task is null
* @throws IllegalStateException if this was already scheduled
*/
public BukkitTask runTaskTimerAsynchronously(BukkitRunnable task, long delay, long period) {
return task.runTaskTimerAsynchronously(authMe, delay, period);
public void runTaskTimerAsynchronously(BukkitRunnable task, long delay, long period) {
AuthMe.getScheduler().runTaskTimerAsynchronously(task, delay, period);
}
/**
* Schedules the given task to repeatedly run until cancelled, starting after the
* specified number of server ticks.
*
* @param task the task to schedule
* @param delay the ticks to wait before running the task
* @param task the task to schedule
* @param delay the ticks to wait before running the task
* @param period the ticks to wait between runs
* @return a BukkitTask that contains the id number
* a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null
* @throws IllegalStateException if this was already scheduled
* @throws IllegalStateException if this was already scheduled
*/
public BukkitTask runTaskTimer(BukkitRunnable task, long delay, long period) {
return task.runTaskTimer(authMe, delay, period);
public void runTaskTimer(BukkitRunnable task, long delay, long period) {
AuthMe.getScheduler().runTaskTimer(task, delay, period);
}
/**