diff --git a/paper-api/src/main/java/org/bukkit/scheduler/BukkitScheduler.java b/paper-api/src/main/java/org/bukkit/scheduler/BukkitScheduler.java index e1b64246f7..08062f34d6 100644 --- a/paper-api/src/main/java/org/bukkit/scheduler/BukkitScheduler.java +++ b/paper-api/src/main/java/org/bukkit/scheduler/BukkitScheduler.java @@ -1,6 +1,8 @@ package org.bukkit.scheduler; import org.bukkit.plugin.Plugin; +import java.util.concurrent.Callable; +import java.util.concurrent.Future; public interface BukkitScheduler { @@ -70,6 +72,19 @@ public interface BukkitScheduler { */ public int scheduleAsyncRepeatingTask(Plugin plugin, Runnable task, long delay, long period); + /** + * Calls a method on the main thread and returns a Future object + * This task will be executed by the main server thread + * + * Note: The Future.get() methods must NOT be called from the main thread + * Note2: There is at least an average of 10ms latency until the isDone() method returns true + * + * @param Plugin Plugin that owns the task + * @param Callable Task to be executed + * @return Future Future object related to the task + */ + public Future callSyncMethod(Plugin plugin, Callable task); + /** * Removes task from scheduler *