1
0
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:
Mykyta Komarnytskyy 2020-12-11 11:20:45 -08:00
parent 308d890c00
commit 925d1ab391

View File

@ -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();
}
}
}