Folia Support(dev)
This commit is contained in:
parent
68ab92dd7a
commit
885db23fc6
19
pom.xml
19
pom.xml
@ -324,8 +324,18 @@
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- <artifactSet>-->
|
||||
<!-- <includes>-->
|
||||
<!-- <include>com.github.Anon8281:UniversalScheduler</include>-->
|
||||
<!-- </includes>-->
|
||||
<!-- </artifactSet>-->
|
||||
<finalName>${project.finalNameBase}-Spigot-Universal</finalName>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.github.Anon8281.universalScheduler</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.com.github.Anon8281.universalScheduler
|
||||
</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.common</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.com.google.common</shadedPattern>
|
||||
@ -1049,6 +1059,15 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Universal Scheduler used by Folia -->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.Anon8281</groupId>
|
||||
<artifactId>UniversalScheduler</artifactId>
|
||||
<version>0.1.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- XAuth, another authentication plugin, required by the database converter -->
|
||||
<dependency>
|
||||
<groupId>de.luricos.bukkit</groupId>
|
||||
|
||||
@ -2,6 +2,8 @@ package fr.xephi.authme;
|
||||
|
||||
import ch.jalu.injector.Injector;
|
||||
import ch.jalu.injector.InjectorBuilder;
|
||||
import com.github.Anon8281.universalScheduler.UniversalScheduler;
|
||||
import com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler;
|
||||
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||
import fr.xephi.authme.command.CommandHandler;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
@ -77,6 +79,7 @@ public class AuthMe extends JavaPlugin {
|
||||
private static final String pluginBuild = "b";
|
||||
private static String pluginBuildNumber = "40";
|
||||
// Private instances
|
||||
private static TaskScheduler scheduler;
|
||||
private EmailService emailService;
|
||||
private CommandHandler commandHandler;
|
||||
@Inject
|
||||
@ -102,6 +105,14 @@ public class AuthMe extends JavaPlugin {
|
||||
return pluginBuild;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Universal Scheduler
|
||||
*
|
||||
* @return TaskScheduler
|
||||
*/
|
||||
public static TaskScheduler getScheduler() {
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin's name.
|
||||
@ -139,7 +150,7 @@ public class AuthMe extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
// Load the plugin version data from the plugin description file
|
||||
loadPluginInfo(getDescription().getVersion());
|
||||
|
||||
scheduler = UniversalScheduler.getScheduler(this);
|
||||
// Set the Logger instance and log file path
|
||||
ConsoleLogger.initialize(getLogger(), new File(getDataFolder(), LOG_FILENAME));
|
||||
logger = ConsoleLoggerFactory.get(AuthMe.class);
|
||||
@ -189,6 +200,7 @@ public class AuthMe extends JavaPlugin {
|
||||
backupService.doBackup(BackupService.BackupCause.START);
|
||||
// Set up Metrics
|
||||
OnStartupTasks.sendMetrics(this, settings);
|
||||
|
||||
if (settings.getProperty(SecuritySettings.SHOW_STARTUP_BANNER)) {
|
||||
logger.info("\n" + " ___ __ __ __ ___ \n" +
|
||||
" / | __ __/ /_/ /_ / |/ /__ \n" +
|
||||
@ -453,7 +465,9 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
|
||||
private void checkServerType() {
|
||||
if (isClassLoaded("com.destroystokyo.paper.PaperConfig")) {
|
||||
if (isClassLoaded("io.papermc.paper.threadedregions.RegionizedServerInitEvent")) {
|
||||
logger.info("AuthMeReReloaded is running on Folia");
|
||||
} else if (isClassLoaded("com.destroystokyo.paper.PaperConfig")) {
|
||||
logger.info("AuthMeReReloaded is running on Paper");
|
||||
} else if (isClassLoaded("catserver.server.CatServerConfig")) {
|
||||
logger.info("AuthMeReReloaded is running on CatServer");
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -16,6 +16,7 @@ softdepend:
|
||||
- EssentialsSpawn
|
||||
- ProtocolLib
|
||||
- floodgate
|
||||
folia-supported: true
|
||||
commands:
|
||||
authme:
|
||||
description: AuthMe op commands
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user