diff --git a/providers/BaseProviders/src/main/java/net/ess3/provider/SchedulingProvider.java b/providers/BaseProviders/src/main/java/net/ess3/provider/SchedulingProvider.java index 83a5a62cc..0b4ca9c63 100644 --- a/providers/BaseProviders/src/main/java/net/ess3/provider/SchedulingProvider.java +++ b/providers/BaseProviders/src/main/java/net/ess3/provider/SchedulingProvider.java @@ -6,6 +6,10 @@ import org.bukkit.entity.Entity; public interface SchedulingProvider extends Provider { void registerInitTask(Runnable runnable); + boolean isEntityThread(Entity entity); + + boolean isRegionThread(Location location); + void runEntityTask(Entity entity, Runnable runnable); EssentialsTask runEntityTask(Entity entity, Runnable runnable, long delay); diff --git a/providers/BaseProviders/src/main/java/net/ess3/provider/providers/BukkitSchedulingProvider.java b/providers/BaseProviders/src/main/java/net/ess3/provider/providers/BukkitSchedulingProvider.java index 887999fea..94433986d 100644 --- a/providers/BaseProviders/src/main/java/net/ess3/provider/providers/BukkitSchedulingProvider.java +++ b/providers/BaseProviders/src/main/java/net/ess3/provider/providers/BukkitSchedulingProvider.java @@ -18,6 +18,16 @@ public class BukkitSchedulingProvider implements SchedulingProvider { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, runnable); } + @Override + public boolean isEntityThread(Entity entity) { + return plugin.getServer().isPrimaryThread(); + } + + @Override + public boolean isRegionThread(Location location) { + return plugin.getServer().isPrimaryThread(); + } + @Override public void runEntityTask(Entity entity, Runnable runnable) { runEntityTask(entity, runnable, 1); diff --git a/providers/FoliaProvider/src/main/java/net/ess3/provider/providers/FoliaSchedulingProvider.java b/providers/FoliaProvider/src/main/java/net/ess3/provider/providers/FoliaSchedulingProvider.java index 9ec92f933..4ffdf8e93 100644 --- a/providers/FoliaProvider/src/main/java/net/ess3/provider/providers/FoliaSchedulingProvider.java +++ b/providers/FoliaProvider/src/main/java/net/ess3/provider/providers/FoliaSchedulingProvider.java @@ -38,6 +38,16 @@ public class FoliaSchedulingProvider implements SchedulingProvider, Listener { initTasks.add(runnable); } + @Override + public boolean isEntityThread(Entity entity) { + return plugin.getServer().isOwnedByCurrentRegion(entity); + } + + @Override + public boolean isRegionThread(Location location) { + return plugin.getServer().isOwnedByCurrentRegion(location); + } + @Override public void runEntityTask(Entity entity, Runnable runnable) { runEntityTask(entity, runnable, 1);