Skip to content

Instantly share code, notes, and snippets.

@WesJD
Created December 30, 2015 23:25
Show Gist options
  • Save WesJD/d3dc7dcd1770e302fe7f to your computer and use it in GitHub Desktop.
Save WesJD/d3dc7dcd1770e302fe7f to your computer and use it in GitHub Desktop.
Execute things on the main thread easily.
public abstract class MainThreadExecutor {
public MainThreadExecutor() {
MinecraftServer.getServer().processQueue.add(new Runnable() {
@Override
public void run() {
call();
}
});
}
public abstract void call();
}
@airidas338
Copy link

Can be simply replaced by BukkitRunnable.runTask()

@WesJD
Copy link
Author

WesJD commented Mar 29, 2016

@airidas338 I actually never thought of that, but this is a little more informative in a multi-threaded environment. Also, it might possibly be faster since it wouldn't go though the Bukkit scheduler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment