void WriteLineConsoleDispose() { if (logWrite != null) { logWrite.Flush(); logWrite.Close(); logWrite.Dispose(); } if (logWatch != null) { logWatch.EnableRaisingEvents = false; logWatch.Changed -= new FileSystemEventHandler(OnLogChanged); logWatch.Dispose(); } }
public static void Recv(string command, string data, BoltConnection source) { if (CoopPeerStarter.DedicatedHost && source.IsDedicatedServerAdmin() && command != null) { if (CoopAdminCommand.< > f__switch$map2 == null) { CoopAdminCommand.< > f__switch$map2 = new Dictionary <string, int>(12) { { "save", 0 }, { "restart", 1 }, { "shutdown", 2 }, { "openlogs", 3 }, { "closelogs", 4 }, { "kick", 5 }, { "ban", 6 }, { "unban", 7 }, { "treeregrowmode", 8 }, { "allowbuildingdestruction", 9 }, { "allowenemiescreative", 10 }, { "allowcheats", 11 } }; } int num; if (CoopAdminCommand.< > f__switch$map2.TryGetValue(command, out num)) { switch (num) { case 0: { int slot; if (!string.IsNullOrEmpty(data) && int.TryParse(data, out slot)) { GameSetup.SetSlot((Slots)slot); } LevelSerializer.Checkpoint(); SaveSlotUtils.SaveHostGameGUID(); CoopAdminCommand.SendNetworkMessage("Game saved to slot " + (int)GameSetup.Slot, source); break; } case 1: CoopAdminCommand.SendNetworkMessageAll("Server shuting down for restart, please reconnect."); TheForest.Utils.Scene.ActiveMB.StartCoroutine(CoopAdminCommand.ShutDownRoutine(true)); break; case 2: CoopAdminCommand.SendNetworkMessageAll("Server is shuting down (no restart)"); TheForest.Utils.Scene.ActiveMB.StartCoroutine(CoopAdminCommand.ShutDownRoutine(false)); break; case 3: if (!SteamDSConfig.ShowLogs) { ConsoleWriter.Open(); if (CoopAdminCommand.< > f__mg$cache0 == null) { CoopAdminCommand.< > f__mg$cache0 = new Application.LogCallback(CoopAdminCommand.Application_logMessageReceived); } Application.logMessageReceived += CoopAdminCommand.< > f__mg$cache0; SteamDSConfig.ShowLogs = true; CoopAdminCommand.SendNetworkMessage("Opened logs console", source); } else { CoopAdminCommand.SendNetworkMessage("Error: console already opened", source); } break; case 4: ConsoleWriter.Close(); if (CoopAdminCommand.< > f__mg$cache1 == null) { CoopAdminCommand.< > f__mg$cache1 = new Application.LogCallback(CoopAdminCommand.Application_logMessageReceived); } Application.logMessageReceived -= CoopAdminCommand.< > f__mg$cache1; SteamDSConfig.ShowLogs = false; CoopAdminCommand.SendNetworkMessage("Closed logs console", source); break; case 5: { ulong num2; if (ulong.TryParse(data, out num2)) { BoltEntity entityFromSteamID = MpPlayerList.GetEntityFromSteamID(num2); if (entityFromSteamID) { CoopKick.KickPlayer(entityFromSteamID, 1, "ADMIN_KICKED_YOU"); CoopAdminCommand.SendNetworkMessage("Kicked " + data, source); } else { CoopAdminCommand.SendNetworkMessage("Failed to kick " + data, source); } } else { BoltEntity entityFromName = MpPlayerList.GetEntityFromName(data, source); if (entityFromName) { CoopKick.KickPlayer(entityFromName, 1, "ADMIN_KICKED_YOU"); CoopAdminCommand.SendNetworkMessage("Kicked " + data, source); } else { CoopAdminCommand.SendNetworkMessage("Invalid SteamId or Name, kick failed (data=" + data + ")", source); } } break; } case 6: { ulong num2; if (ulong.TryParse(data, out num2)) { BoltEntity entityFromSteamID2 = MpPlayerList.GetEntityFromSteamID(num2); if (entityFromSteamID2) { CoopKick.BanPlayer(entityFromSteamID2); CoopAdminCommand.SendNetworkMessage("Banned " + data, source); } else { CoopAdminCommand.SendNetworkMessage("Failed to ban " + data, source); } } else { BoltEntity entityFromName2 = MpPlayerList.GetEntityFromName(data, source); if (entityFromName2) { CoopKick.BanPlayer(entityFromName2); CoopAdminCommand.SendNetworkMessage("Banned " + data, source); } else { CoopAdminCommand.SendNetworkMessage("Invalid SteamId or Name, ban failed (data=" + data + ")", source); } } break; } case 7: { ulong num2; if (ulong.TryParse(data, out num2)) { CoopKick.UnBanPlayer(num2); CoopAdminCommand.SendNetworkMessage("Unbanned " + data, source); } else if (CoopKick.UnBanPlayer(data)) { CoopAdminCommand.SendNetworkMessage("Unbanned " + data, source); } else { CoopAdminCommand.SendNetworkMessage("Invalid SteamId or Name, unban failed (data=" + data + ")", source); } break; } case 8: if (data == "on") { SteamDSConfig.TreeRegrowMode = true; PlayerPreferences.SetLocalTreeRegrowth(SteamDSConfig.TreeRegrowMode); CoopAdminCommand.SendNetworkMessage("TreeRegrowMode set to on", source); } else if (data == "off") { SteamDSConfig.TreeRegrowMode = false; PlayerPreferences.SetLocalTreeRegrowth(SteamDSConfig.TreeRegrowMode); CoopAdminCommand.SendNetworkMessage("TreeRegrowMode set to off", source); } else { CoopAdminCommand.SendNetworkMessage("Invalid parameter (data=" + data + ")", source); } break; case 9: if (data == "on") { SteamDSConfig.AllowBuildingDestruction = true; PlayerPreferences.SetLocalNoDestructionMode(!SteamDSConfig.AllowBuildingDestruction); CoopAdminCommand.SendNetworkMessage("allowbuildingdestruction set to on", source); } else if (data == "off") { SteamDSConfig.AllowBuildingDestruction = false; PlayerPreferences.SetLocalNoDestructionMode(!SteamDSConfig.AllowBuildingDestruction); CoopAdminCommand.SendNetworkMessage("allowbuildingdestruction set to off", source); } else { CoopAdminCommand.SendNetworkMessage("Invalid parameter (data=" + data + ")", source); } break; case 10: if (data == "on") { SteamDSConfig.AllowEnemiesCreative = true; PlayerPreferences.SetLocalAllowEnemiesCreativeMode(SteamDSConfig.AllowEnemiesCreative); CoopAdminCommand.SendNetworkMessage("AllowEnemiesCreative set to on", source); } else if (data == "off") { SteamDSConfig.AllowEnemiesCreative = false; PlayerPreferences.SetLocalAllowEnemiesCreativeMode(SteamDSConfig.AllowEnemiesCreative); CoopAdminCommand.SendNetworkMessage("AllowEnemiesCreative set to off", source); } else { CoopAdminCommand.SendNetworkMessage("Invalid parameter (data=" + data + ")", source); } break; case 11: if (data == "on") { SteamDSConfig.AllowCheats = true; PlayerPreferences.SetAllowCheatsMode(SteamDSConfig.AllowCheats); CoopAdminCommand.SendNetworkMessage("allowcheats set to on", source); } else if (data == "off") { SteamDSConfig.AllowCheats = false; PlayerPreferences.SetAllowCheatsMode(SteamDSConfig.AllowCheats); CoopAdminCommand.SendNetworkMessage("allowcheats set to off", source); } else { CoopAdminCommand.SendNetworkMessage("Invalid parameter (data=" + data + ")", source); } break; } } } }
protected override void OnClosing(CancelEventArgs e) { cwOut.Close( ); cwError.Close( ); base.OnClosing(e); }
private void Window_Closed(object sender, EventArgs e) { Console.WriteLine("Closing Console..."); ConsoleWriter.Close(); }