Skip to content

Commit

Permalink
Merge pull request #395 from Pieter12345/scheduler_fix
Browse files Browse the repository at this point in the history
Don't schedule tasks when the plugin is disabled.
  • Loading branch information
LadyCailin committed Feb 11, 2016
2 parents 18d89f8 + 1d75113 commit 50398b7
Showing 1 changed file with 9 additions and 0 deletions.
Expand Up @@ -65,6 +65,7 @@
import com.laytonsmith.core.environments.CommandHelperEnvironment;
import com.laytonsmith.core.environments.Environment;
import com.laytonsmith.core.exceptions.CRE.CREFormatException;
import com.laytonsmith.core.exceptions.CancelCommandException;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location;
Expand Down Expand Up @@ -476,6 +477,10 @@ public MCInventory GetLocationInventory(MCLocation location) {

@Override
public void runOnMainThreadLater(DaemonManager dm, final Runnable r) {
if(!CommandHelperPlugin.self.isEnabled()) {
throw new CancelCommandException(Implementation.GetServerType().getBranding()
+ " tried to schedule a task while the plugin was disabled (is the server shutting down?).", Target.UNKNOWN);
}
Bukkit.getServer().getScheduler().callSyncMethod(CommandHelperPlugin.self, new Callable<Object>() {

@Override
Expand All @@ -488,6 +493,10 @@ public Object call() throws Exception {

@Override
public <T> T runOnMainThreadAndWait(Callable<T> callable) throws InterruptedException, ExecutionException {
if(!CommandHelperPlugin.self.isEnabled()) {
throw new CancelCommandException(Implementation.GetServerType().getBranding()
+ " tried to schedule a task while the plugin was disabled (is the server shutting down?).", Target.UNKNOWN);
}
return Bukkit.getServer().getScheduler().callSyncMethod(CommandHelperPlugin.self, callable).get();
}

Expand Down

0 comments on commit 50398b7

Please sign in to comment.