Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by Xuho, Jun 28, 2018.
What is the best way to kick players 1 by 1 with a delay of X ticks on server stop/restart?
Create a bukkit runnable timer, kick a user each time it runs.
Create a BukkitRunnable in onDisable and kick a random user every X amount of time?
And if the server turns off before I kick all the players?
Create a async scheduler or create a new Thread and forEach all players, then kick them and sleep the Thread for a second.
If the server crashes then it is impossible to kick them before it happens, as far as I'm aware of. You can create an async repeating task that will run X seconds onDisable. You can then kick the player like so and sleep the thread for X seconds:
Bukkit.getOnlinePlayers().stream().findAny().ifPresent(player->player.kickPlayer("You have been kicked"));
However, knowing what you want to achieve would make us better understand your situation and help you accordingly.
nope, not completely agree, if the bukkit server crash and u doing it with bungee, it is possible to get the player from bungee side, and force them to other server, same as kick :L
This aint bungee related as it is not in the bungee section.
okay, just give another solution if must doing that