From a4ccadacdc20878a3c804c9e6ee3faab3cd3e4ed Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2011 07:59:14 +0100 Subject: [PATCH] Added ServerInterface.schedule(delay, period, task). --- .../java/com/sk89q/worldedit/ServerInterface.java | 13 +++++++++++++ .../worldedit/bukkit/BukkitServerInterface.java | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/src/main/java/com/sk89q/worldedit/ServerInterface.java b/src/main/java/com/sk89q/worldedit/ServerInterface.java index fc845bc32..a497f676c 100644 --- a/src/main/java/com/sk89q/worldedit/ServerInterface.java +++ b/src/main/java/com/sk89q/worldedit/ServerInterface.java @@ -44,4 +44,17 @@ public abstract class ServerInterface { * Reload WorldEdit configuration. */ public abstract void reload(); + + /** + * Schedules the given task to be invoked once every period ticks + * after an initial delay of delay ticks. + * + * @param delay Delay in server ticks before executing first repeat + * @param period Period in server ticks of the task + * @param task Task to be executed + * @return Task id number (-1 if scheduling failed) + */ + public int schedule(long delay, long period, Runnable task) { + return -1; + } } diff --git a/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java b/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java index e5301fb02..78664c682 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java @@ -48,4 +48,8 @@ public class BukkitServerInterface extends ServerInterface { plugin.loadConfiguration(); } + @Override + public int schedule(long delay, long period, Runnable task) { + return Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, task, delay, period); + } }