This commit is contained in:
HaHaWTH 2024-03-25 21:37:25 +08:00
parent 1f734f4b95
commit 8932c71173
2 changed files with 35 additions and 1 deletions

View File

@ -189,7 +189,9 @@ public class AsynchronousJoin implements AsynchronousProcess {
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
// Allow infinite blindness effect
int blindTimeOut = (registrationTimeout <= 0) ? 99999 : registrationTimeout;
bukkitService.runTask(player,() -> player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2)));
// AuthMeReReloaded - Fix potion apply on Folia
bukkitService.runTaskIfFolia(player,() -> player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2)));
}
commandManager.runCommandsOnJoin(player);
});

View File

@ -6,6 +6,7 @@ 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;
@ -36,6 +37,8 @@ public class BukkitService implements SettingsDependent {
public static final int TICKS_PER_SECOND = 20;
/** 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 final AuthMe authMe;
private boolean useAsyncTasks;
@ -102,6 +105,35 @@ public class BukkitService implements SettingsDependent {
getScheduler().runTask(location, task);
}
/**
* Runs the task synchronously if we are running Folia, else do nothing but run it.
* @param task the task to be run
*/
public void runTaskIfFolia(Runnable task) {
if (IS_FOLIA) {
runTask(task);
} else {
task.run();
}
}
public void runTaskIfFolia(Entity entity, Runnable task) {
if (IS_FOLIA) {
runTask(entity, task);
} else {
task.run();
}
}
public void runTaskIfFolia(Location location, Runnable task) {
if (IS_FOLIA) {
runTask(location, task);
} else {
task.run();
}
}
/**
* Returns a task that will run after the specified number of server