Add method for checking the global thread

This commit is contained in:
Josh Roy 2023-03-30 13:31:16 -04:00
parent 4ff9286a79
commit 2d8cc827b9
No known key found for this signature in database
GPG Key ID: 64C8142336ED1F69
5 changed files with 20 additions and 0 deletions

View File

@ -1239,6 +1239,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
return schedulingProvider.isRegionThread(location);
}
@Override
public boolean isGlobalThread() {
return schedulingProvider.isGlobalThread();
}
@Override
public PermissionsHandler getPermissionsHandler() {
return permissionsHandler;

View File

@ -129,6 +129,8 @@ public interface IEssentials extends Plugin {
boolean isRegionThread(Location location);
boolean isGlobalThread();
PermissionsHandler getPermissionsHandler();
AlternativeCommandsHandler getAlternativeCommandsHandler();

View File

@ -10,6 +10,8 @@ public interface SchedulingProvider extends Provider {
boolean isRegionThread(Location location);
boolean isGlobalThread();
void runEntityTask(Entity entity, Runnable runnable);
EssentialsTask runEntityTask(Entity entity, Runnable runnable, long delay);

View File

@ -1,6 +1,7 @@
package net.ess3.provider.providers;
import net.ess3.provider.SchedulingProvider;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.Plugin;
@ -28,6 +29,11 @@ public class BukkitSchedulingProvider implements SchedulingProvider {
return plugin.getServer().isPrimaryThread();
}
@Override
public boolean isGlobalThread() {
return Bukkit.isPrimaryThread();
}
@Override
public void runEntityTask(Entity entity, Runnable runnable) {
runEntityTask(entity, runnable, 1);

View File

@ -48,6 +48,11 @@ public class FoliaSchedulingProvider implements SchedulingProvider, Listener {
return plugin.getServer().isOwnedByCurrentRegion(location);
}
@Override
public boolean isGlobalThread() {
return plugin.getServer().isGlobalTickThread();
}
@Override
public void runEntityTask(Entity entity, Runnable runnable) {
runEntityTask(entity, runnable, 1);