Java / Minecraft] How do I rewrite this code so that the server does not shut down immediately after starting?

Ba
- in Plugins
6

Private void AFKStop () {
new BukkitRunnable () {

@Override
public void run () {
if (Bukkit.getOnlinePlayers (). Size () == 0) {
Bukkit.shutdown ();
}
}
} .runTaskTimer ((plugin) this, 0, 6000);
}

What is the code doing? The server should be shut down if there's no player on it for 5 minutes.

In onEnable () {} is AFKStop (); registered. Relatively far down, but that doesn't matter. I've tried it.

An

You have to set the 0 to the number of ticks that should be waited for before the first check.

Ba

That's going to be done anyway. Even if I set the ticks higher, the server will shut down again after starting LOL

Ba

Ah wait a minute… May make sense xD

Ba

But then it is so that if the player after e.g. Leaves 4 minutes, the server is shut down after 1 minute, because then 5 minutes are up…

An

Yes, I would have solved it differently. Can I write to you afterwards during the lunch break?

Ba

All right, I already got a very helpful answer. See above