From 3274723cede8767d412338a0ec1fd995a8a3809f Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sat, 12 Feb 2011 00:03:41 +0000 Subject: [PATCH] Allows calling of functions in the main thread By: Raphfrk --- .../org/bukkit/scheduler/BukkitScheduler.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 *