Fix folia compatibility
This commit is contained in:
parent
4f88d15f8e
commit
3bf95f6eba
@ -191,9 +191,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
int blindTimeOut = (registrationTimeout <= 0) ? 99999 : registrationTimeout;
|
||||
|
||||
// AuthMeReReloaded start - Fix async potion apply on Folia
|
||||
bukkitService.runTask(() -> {
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2));
|
||||
});
|
||||
bukkitService.runTaskSyncIfFolia(() -> player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2)));
|
||||
// AuthMeReReloaded end
|
||||
|
||||
}
|
||||
|
||||
@ -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;
|
||||
@ -34,6 +35,7 @@ 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;
|
||||
private static final boolean IS_FOLIA = Utils.isClassLoaded("io.papermc.paper.threadedregions.RegionizedServer");
|
||||
|
||||
private final AuthMe authMe;
|
||||
private boolean useAsyncTasks;
|
||||
@ -139,6 +141,18 @@ public class BukkitService implements SettingsDependent {
|
||||
getScheduler().runTaskAsynchronously(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the task synchronously if we are on a Folia server, else runs normally.
|
||||
* @param task the task to run
|
||||
*/
|
||||
public void runTaskSyncIfFolia(Runnable task) {
|
||||
if (IS_FOLIA) {
|
||||
runTask(task);
|
||||
} else {
|
||||
task.run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>Asynchronous tasks should never access any API in Bukkit. Great care
|
||||
* should be taken to assure the thread-safety of asynchronous tasks.</b>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user