Open MrZomka opened 1 year ago
as im surprised this hasnt been added, i will add code for the developer to easy go off of to hopefully get this feature faster
// this is assuming the method is run in your app class, add reference to the class if used externally
JavaPlugin plugin; // as a placeholder, replace with reference to your plugin class
// create an async thread
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new TimerTask() {
@Override
public void run() {
while (plugin.getServer().getOnlinePlayers().size() > 0) { // Wait for the player count to reach 0
try {
Thread.sleep(5000); // 5 second delay between online checks to not overwhelm the server
}
catch (InterruptedException e) {
e.printStackTrace(); // Error occurred with Thread.sleep
}
}
plugin.getServer().shutdown(); // or replace with custom restart method
}
});
@Konicai
Might have to add configuration to handle auto restart on no player online variable
Auto restart is really handy, but it would've been better if it was possible for it to occur only when there are no players online to not cause any inconveniences :)