Change runAsync in MiniPlugin to use our own thread pool
This allows the tasks to run immediately. Using Bukkit's scheduler the async task wont start until the next server tick
This commit is contained in:
parent
da9a642a6d
commit
656780d027
@ -1,11 +1,15 @@
|
||||
package mineplex.core;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.command.ICommand;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -15,6 +19,9 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
|
||||
public abstract class MiniPlugin implements Listener
|
||||
{
|
||||
private static final ExecutorService threadPool = Executors.newCachedThreadPool(
|
||||
new ThreadFactoryBuilder().setNameFormat("MiniPlugin Async %1$d").build());
|
||||
|
||||
protected String _moduleName = "Default";
|
||||
protected JavaPlugin _plugin;
|
||||
protected NautHashMap<String, ICommand> _commands;
|
||||
@ -105,7 +112,8 @@ public abstract class MiniPlugin implements Listener
|
||||
|
||||
public void runAsync(Runnable runnable)
|
||||
{
|
||||
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, runnable);
|
||||
// Instead of using
|
||||
threadPool.execute(runnable);
|
||||
}
|
||||
|
||||
public void runAsync(Runnable runnable, long time)
|
||||
|
Loading…
Reference in New Issue
Block a user