From 0a3574eb20eedfe1504d79ed46baae09a9270349 Mon Sep 17 00:00:00 2001 From: Major- Date: Thu, 27 Aug 2015 23:29:27 +0100 Subject: [PATCH] Fix ScheduledTask timer. --- .../apollo/game/scheduling/ScheduledTask.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/game/src/main/org/apollo/game/scheduling/ScheduledTask.java b/game/src/main/org/apollo/game/scheduling/ScheduledTask.java index 8f80129d..3b360673 100644 --- a/game/src/main/org/apollo/game/scheduling/ScheduledTask.java +++ b/game/src/main/org/apollo/game/scheduling/ScheduledTask.java @@ -28,8 +28,7 @@ public abstract class ScheduledTask { * Creates a new scheduled task. * * @param delay The delay between executions of the task, in pulses. - * @param immediate A flag indicating if this task should (for the first execution) be ran immediately, or after the - * {@code delay}. + * @param immediate Indicates whether or not this task should be executed immediately, or after the {@code delay}. * @throws IllegalArgumentException If the delay is less than or equal to zero. */ public ScheduledTask(int delay, boolean immediate) { @@ -37,11 +36,6 @@ public abstract class ScheduledTask { pulses = immediate ? 0 : delay; } - /** - * Executes this task. - */ - public abstract void execute(); - /** * Checks if this task is running. * @@ -51,16 +45,6 @@ public abstract class ScheduledTask { return running; } - /** - * Pulses this task: updates the delay and calls {@link #execute()} if necessary. - */ - final void pulse() { - if (running && pulses-- == 0) { - execute(); - pulses = delay; - } - } - /** * Sets the delay. * @@ -79,4 +63,19 @@ public abstract class ScheduledTask { running = false; } + /** + * Executes this task. + */ + public abstract void execute(); + + /** + * Pulses this task: updates the delay and calls {@link #execute()} if necessary. + */ + final void pulse() { + if (running && --pulses <= 0) { + execute(); + pulses = delay; + } + } + } \ No newline at end of file