mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 06:57:39 +01:00
Add method for checking the global thread
This commit is contained in:
parent
4ff9286a79
commit
2d8cc827b9
@ -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;
|
||||
|
@ -129,6 +129,8 @@ public interface IEssentials extends Plugin {
|
||||
|
||||
boolean isRegionThread(Location location);
|
||||
|
||||
boolean isGlobalThread();
|
||||
|
||||
PermissionsHandler getPermissionsHandler();
|
||||
|
||||
AlternativeCommandsHandler getAlternativeCommandsHandler();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user