From 3f3671c95cf59a1f8d9a464ad75e393936352fb6 Mon Sep 17 00:00:00 2001 From: HaHaWTH Date: Fri, 24 May 2024 00:42:47 +0800 Subject: [PATCH] Fix #146 and cleanup --- .../process/quit/ProcessSyncPlayerQuit.java | 5 ++++- .../fr/xephi/authme/service/BukkitService.java | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/fr/xephi/authme/process/quit/ProcessSyncPlayerQuit.java b/src/main/java/fr/xephi/authme/process/quit/ProcessSyncPlayerQuit.java index fad8b747..42048ef1 100644 --- a/src/main/java/fr/xephi/authme/process/quit/ProcessSyncPlayerQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/ProcessSyncPlayerQuit.java @@ -1,5 +1,6 @@ package fr.xephi.authme.process.quit; +import com.github.Anon8281.universalScheduler.UniversalScheduler; import fr.xephi.authme.data.limbo.LimboService; import fr.xephi.authme.process.SynchronousProcess; import fr.xephi.authme.settings.commandconfig.CommandManager; @@ -27,7 +28,9 @@ public class ProcessSyncPlayerQuit implements SynchronousProcess { commandManager.runCommandsOnLogout(player); } else { limboService.restoreData(player); - player.saveData(); // #1238: Speed is sometimes not restored properly + if (!UniversalScheduler.isFolia) { // AuthMeReReloaded - Fix #146 (Very stupid solution, but works) + player.saveData(); // #1238: Speed is sometimes not restored properly + } } player.leaveVehicle(); } diff --git a/src/main/java/fr/xephi/authme/service/BukkitService.java b/src/main/java/fr/xephi/authme/service/BukkitService.java index 002ca9fa..45008a38 100644 --- a/src/main/java/fr/xephi/authme/service/BukkitService.java +++ b/src/main/java/fr/xephi/authme/service/BukkitService.java @@ -1,12 +1,12 @@ package fr.xephi.authme.service; import com.github.Anon8281.universalScheduler.UniversalRunnable; +import com.github.Anon8281.universalScheduler.UniversalScheduler; 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; import fr.xephi.authme.settings.properties.PluginSettings; -import fr.xephi.authme.util.Utils; import org.bukkit.BanEntry; import org.bukkit.BanList; import org.bukkit.Bukkit; @@ -38,7 +38,7 @@ public class BukkitService implements SettingsDependent { /** Number of ticks per minute. */ public static final int TICKS_PER_MINUTE = 60 * TICKS_PER_SECOND; /** Whether the server is running Folia. */ - private static final boolean IS_FOLIA = Utils.isClassLoaded("io.papermc.paper.threadedregions.RegionizedServer"); + private static final boolean isFolia = UniversalScheduler.isFolia; private final AuthMe authMe; private boolean useAsyncTasks; @@ -68,7 +68,7 @@ public class BukkitService implements SettingsDependent { * @param delay Delay in server ticks before executing task */ public void scheduleSyncDelayedTask(Runnable task, long delay) { - if (IS_FOLIA) { + if (isFolia) { runTaskLater(task, delay); } else { Bukkit.getScheduler().runTaskLater(authMe, task, delay); // We must do this to keep compatibility @@ -98,7 +98,7 @@ public class BukkitService implements SettingsDependent { * @throws IllegalArgumentException if task is null */ public void runTask(Runnable task) { - if (IS_FOLIA) { + if (isFolia) { getScheduler().runTask(task); } else { Bukkit.getScheduler().runTask(authMe, task); @@ -106,7 +106,7 @@ public class BukkitService implements SettingsDependent { } public void runTask(Entity entity, Runnable task) { - if (IS_FOLIA) { + if (isFolia) { getScheduler().runTask(entity, task); } else { Bukkit.getScheduler().runTask(authMe, task); @@ -122,7 +122,7 @@ public class BukkitService implements SettingsDependent { * @param task the task to be run */ public void runTaskIfFolia(Runnable task) { - if (IS_FOLIA) { + if (isFolia) { runTask(task); } else { task.run(); @@ -134,7 +134,7 @@ public class BukkitService implements SettingsDependent { * @param task the task to be run */ public void runTaskIfFolia(Entity entity, Runnable task) { - if (IS_FOLIA) { + if (isFolia) { runTask(entity, task); } else { task.run(); @@ -146,7 +146,7 @@ public class BukkitService implements SettingsDependent { * @param task the task to be run */ public void runTaskIfFolia(Location location, Runnable task) { - if (IS_FOLIA) { + if (isFolia) { runTask(location, task); } else { task.run(); @@ -196,7 +196,7 @@ public class BukkitService implements SettingsDependent { * @throws IllegalArgumentException if task is null */ public void runTaskAsynchronously(Runnable task) { - if (IS_FOLIA) { + if (isFolia) { getScheduler().runTaskAsynchronously(task); } else { Bukkit.getScheduler().runTaskAsynchronously(authMe, task);