SteamWar/FightSystem
Archiviert
13
1

Staggered kick to prevent a lobby crash

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-06-22 08:58:37 +02:00
Ursprung 51fe8cfbe5
Commit 08c19e6a85

Datei anzeigen

@ -46,7 +46,17 @@ public class IFightSystem {
public static void shutdown(String reason){ public static void shutdown(String reason){
if(reason != null) if(reason != null)
Bukkit.broadcastMessage(reason); Bukkit.broadcastMessage(reason);
Bukkit.getOnlinePlayers().forEach(player -> player.kickPlayer(null)); //Staggered kick to prevent lobby overloading
Bukkit.shutdown(); kickNext();
}
private static void kickNext(){
if(Bukkit.getOnlinePlayers().isEmpty()){
Bukkit.shutdown();
return;
}
Bukkit.getOnlinePlayers().iterator().next().kickPlayer(null);
Bukkit.getScheduler().runTaskLater(plugin, IFightSystem::kickNext, 10);
} }
} }