public static void PerformShutDown() { Console.Clear(); log.Info("Server shutting down..."); Console.Title = "PLUS EMULATOR: SHUTTING DOWN!"; PlusEnvironment.GetGame().GetClientManager().SendMessage(new BroadcastMessageAlertComposer(PlusEnvironment.GetGame().GetLanguageLocale().TryGetValue("shutdown_alert"))); GetGame().StopGameLoop(); Thread.Sleep(2500); GetConnectionManager().Destroy(); //Stop listening. GetGame().GetPacketManager().UnregisterAll(); //Unregister the packets. GetGame().GetPacketManager().WaitForAllToComplete(); GetGame().GetClientManager().CloseAll(); //Close all connections GetGame().GetRoomManager().Dispose(); //Stop the game loop. using (IQueryAdapter dbClient = _manager.GetQueryReactor()) { dbClient.RunQuery("TRUNCATE `catalog_marketplace_data`"); dbClient.RunQuery("UPDATE `users` SET `online` = '0', `auth_ticket` = NULL"); dbClient.RunQuery("UPDATE `rooms` SET `users_now` = '0' WHERE `users_now` > '0'"); dbClient.RunQuery("UPDATE `server_status` SET `users_online` = '0', `loaded_rooms` = '0'"); } log.Info("Plus Emulator has successfully shutdown."); Thread.Sleep(1000); Environment.Exit(0); }