mirror of
https://github.com/nkomarn/harbor.git
synced 2025-01-20 06:21:26 +01:00
Server thread helper
This commit is contained in:
parent
308d890c00
commit
925d1ab391
@ -268,4 +268,17 @@ public class Checker extends BukkitRunnable {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures the provided task is ran on the server thread.
|
||||
*
|
||||
* @param runnable The task to run on the server thread.
|
||||
*/
|
||||
public void ensureMain(@NotNull Runnable runnable) {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
Bukkit.getScheduler().runTask(harbor, runnable);
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user