diff --git a/proxy/src/main/java/net/md_5/bungee/scheduler/BungeeScheduler.java b/proxy/src/main/java/net/md_5/bungee/scheduler/BungeeScheduler.java index 418e9210..e3085db2 100644 --- a/proxy/src/main/java/net/md_5/bungee/scheduler/BungeeScheduler.java +++ b/proxy/src/main/java/net/md_5/bungee/scheduler/BungeeScheduler.java @@ -44,7 +44,7 @@ public class BungeeScheduler implements TaskScheduler @Override public void cancel(ScheduledTask task) { - cancel( task.getId() ); + task.cancel(); } @Override diff --git a/proxy/src/main/java/net/md_5/bungee/scheduler/BungeeTask.java b/proxy/src/main/java/net/md_5/bungee/scheduler/BungeeTask.java index 7e87ec13..195b50d4 100644 --- a/proxy/src/main/java/net/md_5/bungee/scheduler/BungeeTask.java +++ b/proxy/src/main/java/net/md_5/bungee/scheduler/BungeeTask.java @@ -34,7 +34,12 @@ public class BungeeTask implements Runnable, ScheduledTask @Override public void cancel() { - running.set( false ); + boolean wasRunning = running.getAndSet( false ); + + if ( wasRunning ) + { + sched.cancel( this.getId() ); + } } @Override @@ -76,11 +81,6 @@ public class BungeeTask implements Runnable, ScheduledTask } } - // We might have been previously running before, but now we aren't. - // If we weren't already cancelled, then cancel ourselves. - if ( running.get() ) - { - sched.cancel( this ); - } + cancel(); } }