Solved Kicking players 1 by 1?

Discussion in 'Spigot Plugin Development' started by Xuho, Jun 28, 2018.

  1. What is the best way to kick players 1 by 1 with a delay of X ticks on server stop/restart?
     
  2. Create a bukkit runnable timer, kick a user each time it runs.
     
    • Agree Agree x 1
  3. Create a BukkitRunnable in onDisable and kick a random user every X amount of time?
     
  4. And if the server turns off before I kick all the players?
     
  5. Create a async scheduler or create a new Thread and forEach all players, then kick them and sleep the Thread for a second.
     
    • Optimistic Optimistic x 1
  6. 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:
    Code (Java):
    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.
     
    #6 darklazerog, Jun 28, 2018
    Last edited: Jun 28, 2018
    • Agree Agree x 3
    • Winner Winner x 3
  7. 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
     
    • Optimistic Optimistic x 1
  8. This aint bungee related as it is not in the bungee section.
     
    • Agree Agree x 1
  9. okay, just give another solution if must doing that :p