/// <summary> /// Start a process, start the threads to read the output and send the output to the correct outputhandler /// </summary> /// <param name="executable">The executable to run</param> /// <param name="parameters">The parameters for the executable</param> /// <param name="server">The server that is being ran</param> /// <param name="serverDir">The directory that should be used as root for the minecraft server</param> /// <returns></returns> public static Boolean StartServer(string executable, string parameters, IMinecraftServer server, string serverDir = "") { try { if (string.IsNullOrEmpty(executable)) { return(false); } if (string.IsNullOrEmpty(parameters)) { parameters = ""; } if (string.IsNullOrEmpty(serverDir)) { serverDir = Fl.SafeLocation(RequestFile.Serverdir); } FileInfo exeFileInfo = new FileInfo(executable); Server = server; RaiseServerStarting(); ServerProcess = new Process { StartInfo = new ProcessStartInfo { FileName = exeFileInfo.FullName, Arguments = parameters, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, ErrorDialog = false, UseShellExecute = false, WorkingDirectory = serverDir, StandardErrorEncoding = Encoding.Unicode, StandardOutputEncoding = Encoding.Unicode, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true }, EnableRaisingEvents = true, }; // log from startinfo to ensure correct results (in case .NET would alter something) Logger.Log(LogLevel.Info, "ProcessHandler", "Starting new process: " + ServerProcess.StartInfo.FileName + " " + ServerProcess.StartInfo.Arguments); ServerProcess.Start(); ServerProcess.Exited += HandleStop; StartThreads(); RaiseServerStarted(); return(true); } catch (Exception exception) { Logger.Log(LogLevel.Warning, "ProcessHandler", "Couldn't start server! " + executable + " " + parameters, exception.Message); return(false); } }
/// <summary> /// Get a list of all available server types /// </summary> /// <returns></returns> internal static Dictionary <string, IMinecraftServer> GetAvailableServers() { Dictionary <string, IMinecraftServer> servers = new Dictionary <string, IMinecraftServer>(); foreach (string entry in ListClasses()) { IMinecraftServer server = Activator.CreateInstance(Assembly.GetExecutingAssembly().GetType(entry)) as IMinecraftServer; if (server == null) { continue; //if not loaded, go on } if (!servers.ContainsKey(server.Name)) { servers.Add(server.Name, server); } else { Logger.Log( LogLevel.Severe, "MinecraftServerLoader", "Can't add server to dictionary, duplicate name!", server.Name); } } return(servers); }
/// <summary> /// Handle server output, raise all events that should be raised /// </summary> /// <param name="text">output text to handle</param> /// <param name="server">the server that should handle the output</param> public static void HandleOutput(IMinecraftServer server, string text) { RaiseOutputReceivedEvent(text); OutputParseResult result = server.ParseOutput(text); RaiseOutputParsedEvent(text, result); switch (result.Type) { case MessageType.Info: RaiseInfoMessageReceivedEvent(text, result); break; case MessageType.Warning: RaiseWarningMessageReceivedEvent(text, result); break; case MessageType.Severe: RaiseSevereMessageReceivedEvent(text, result); break; case MessageType.JavaStackTrace: RaiseJavaStackStraceMessageReceivedEvent(text, result); break; case MessageType.JavaStatus: RaiseJavaStatusMessageReceivedEvent(text, result); break; case MessageType.PlayerJoin: RaisePlayerJoinEvent(text, result, result.Action); break; case MessageType.PlayerLeave: RaisePlayerLeaveEvent(text, result, result.Action); break; case MessageType.PlayerKick: RaisePlayerKickEvent(text, result, result.Action); break; case MessageType.PlayerBan: RaisePlayerBanEvent(text, result, result.Action); break; case MessageType.PlayerIpBan: RaisePlayerIpBanEvent(text, result, result.Action); break; case MessageType.PlayerList: PlayerListReceived(text, result, new Dictionary <string, string>()); break; default: RaiseUnknownMessageReceivedEvent(text, result); break; } }
/// <summary> /// Launch a new server /// </summary> /// <param name="server">the server type that will be executed</param> /// <param name="customSettingsControl">The custom settings control that is filled out</param> public void LaunchServer(IMinecraftServer server, UserControl customSettingsControl) { server.PrepareLaunch(); string parameters = server.GetLaunchParameters(); string executable = server.CustomAssembly; ProcessHandler.StartServer(executable, parameters, server); }
/// <summary> /// Launch the server, get all settings from /// </summary> public void DoServerLaunch(Boolean automated = false) { if (InvokeRequired) { Invoke((MethodInvoker)(() => DoServerLaunch(automated))); } else { ConsoleTab.Reference.MCCOut.Clear(); if (!ValidateInput()) { MetroMessageBox.Show(FindForm(), "The server could not be started: one or more settings are incorrect. See the starter tab for more details", "Server could not be started", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } IMinecraftServer server = GetSelectedServer(); Starter starter = ParentAddon as Starter; Logger.Log(LogLevel.Info, "StarterTab", "starting server: " + server.Name); // We need access to a starter object (the parent) if (starter == null) { Logger.Log(LogLevel.Severe, "StarterTab", "Failed to start server", "No starter object found"); return; } // Auto update if (CBUpdateBehaviour.SelectedIndex > 0) { CheckAutoUpdate(); } if (!server.HasCustomAssembly) { starter.LaunchServer( server, GetSelectedJavaVersion(), TxtJarFile.Text, Convert.ToUInt32(NumMinRam.Value), Convert.ToUInt32(NumMaxRam.Value), TxtOptArg.Text, TxtOptFlag.Text, automated); } else { starter.LaunchServer(server, _customControl); } } }
/// <summary> /// Launch a new server /// </summary> /// <param name="server">the server type that will be executed</param> /// <param name="javaVersion">the java version to use</param> /// <param name="jarFile">the jar file to run</param> /// <param name="minMem">the minimum amount of memory to set</param> /// <param name="maxMem">the maximum amount of memory to set</param> /// <param name="defaultParameters">the parameters entered by the user (optional)</param> /// <param name="defaultFlags">the flags entered by the user (optional)</param> public void LaunchServer(IMinecraftServer server, JavaVersion javaVersion, string jarFile, UInt32 minMem, UInt32 maxMem, string defaultParameters = "", string defaultFlags = "") { server.PrepareLaunch(); string parameters = server.GetLaunchParameters(defaultParameters); string flags = server.GetLaunchFlags(defaultFlags); string argument = parameters + " -Xms" + minMem + "M -Xmx" + maxMem + "M -jar \"" + jarFile + "\" " + flags; string executable = JavaApi.GetJavaPath(javaVersion); ProcessHandler.StartServer(executable, argument, server); }
/// <summary> /// Start a process, start the threads to read the output and send the output to the correct outputhandler /// </summary> /// <param name="executable">The executable to run</param> /// <param name="parameters">The parameters for the executable</param> /// <param name="server">The server that is being ran</param> /// <param name="serverDir">The directory that should be used as root for the minecraft server</param> /// <returns></returns> public static Boolean StartServer(string executable, string parameters, IMinecraftServer server, string serverDir = "") { if (string.IsNullOrEmpty(executable)) { return(false); } Server = server; FileInfo exeFileInfo = new FileInfo(executable); RaiseServerStarting(); if (string.IsNullOrEmpty(serverDir)) { serverDir = Environment.CurrentDirectory; FileInfo guiFileInfo = new FileInfo(Share.AssemblyFullName); if (guiFileInfo.Directory != null) { serverDir = guiFileInfo.Directory.FullName; } } ServerProcess = new Process { StartInfo = new ProcessStartInfo { FileName = exeFileInfo.FullName, Arguments = parameters, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, ErrorDialog = false, UseShellExecute = false, WorkingDirectory = serverDir, StandardErrorEncoding = Encoding.Unicode, StandardOutputEncoding = Encoding.Unicode, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true } }; ServerProcess.EnableRaisingEvents = true; ServerProcess.Start(); ServerProcess.Exited += HandleStop; StartThreads(); IsRunning = true; RaiseServerStarted(); return(true); }
/// <summary> /// Load all settings/buttons for a selected server /// </summary> private void LoadServer() { GBServer.UseWaitCursor = true; IMinecraftServer server = GetSelectedServer(); if (server == null) { return; } Logger.Log(LogLevel.Info, "StarterTab", "Loading server: " + server.Name); // If this server doesn't use a custom assembly, use the java settings CBJavaVersion.Enabled = !server.HasCustomAssembly; NumMaxRam.Enabled = !server.HasCustomAssembly; NumMinRam.Enabled = !server.HasCustomAssembly; TBMaxRam.Enabled = !server.HasCustomAssembly; TBMinRam.Enabled = !server.HasCustomAssembly; TxtOptArg.Enabled = !server.HasCustomAssembly; TxtOptFlag.Enabled = !server.HasCustomAssembly; TxtJarFile.Enabled = !server.HasCustomAssembly; // If there is a custom settings control, load it if (server.HasCustomSettingsControl) { _customControl = server.CustomSettingsControl; GBCustomSettings.Controls.Clear(); GBCustomSettings.Controls.Add(_customControl); GBCustomSettings.Controls[0].Dock = DockStyle.Fill; } else { _customControl = null; GBCustomSettings.Controls.Clear(); } GBServer.UseWaitCursor = false; Logger.Log(LogLevel.Info, "StarterTab", "Loaded server: " + server.Name); }
/// <summary> /// Launch the server, get all settings from /// </summary> public void DoServerLaunch() { IMinecraftServer server = this.GetSelectedServer(); Starter starter = this.ParentAddon as Starter; Logger.Log(LogLevel.Info, "StarterTab", "starting server: " + server.Name); // We need access to a starter object (the parent) if (starter == null) { Logger.Log(LogLevel.Severe, "StarterTab", "Failed to start server", "No starter object found"); return; } // If invalid input, stop if (!this.ValidateInput()) { return; } if (!server.HasCustomAssembly) { starter.LaunchServer( server, this.GetSelectedJavaVersion(), this.TxtJarFile.Text, Convert.ToUInt32(this.NumMinRam.Value), Convert.ToUInt32(this.NumMaxRam.Value), this.TxtOptArg.Text, this.TxtOptFlag.Text); } else { starter.LaunchServer(server, server.CustomAssembly, this._customControl); } }
/// <summary> /// Launch a new server /// </summary> /// <param name="server">the server type that will be executed</param> /// <param name="customAssembly">the custom assembly that will be executed, absolute path recommended</param> /// <param name="customSettingsControl">The custom settings control that is filled out</param> public void LaunchServer(IMinecraftServer server, Assembly customAssembly, UserControl customSettingsControl) { }
private void CheckAutoUpdate() { try { if (InvokeRequired) { Invoke((MethodInvoker)(CheckAutoUpdate)); } else { if (CBUpdateBehaviour.SelectedIndex < 1) { return; } if (CBUpdateBranch.SelectedItem == null || string.IsNullOrEmpty(CBUpdateBranch.SelectedItem.ToString())) { return; } ProcessHandler.SetStatusStarting(); // already show that the server is starting ConsoleTab.WriteOut("__________________________________________________________________"); ConsoleTab.WriteOut("Performing version check... Branch: " + CBUpdateBranch.SelectedItem); IMinecraftServer server = GetSelectedServer(); string currentversion = server.GetCurrentVersion(TxtJarFile.Text); ConsoleTab.WriteOut("Performing version check... Current version: " + currentversion); string latestversion = ""; if (CBUpdateBranch.SelectedItem.ToString().ToLower().Contains("recommended")) { latestversion = server.FetchRecommendedVersion; } if (CBUpdateBranch.SelectedItem.ToString().ToLower().Contains("beta")) { latestversion = server.FetchBetaVersion; } if (CBUpdateBranch.SelectedItem.ToString().ToLower().Contains("dev")) { latestversion = server.FetchDevVersion; } ConsoleTab.WriteOut("Performing version check... Latest version: " + latestversion); switch (CBUpdateBehaviour.SelectedIndex) { case 1: // Notify if (int.Parse(latestversion) > int.Parse(currentversion)) { ConsoleTab.WriteOut("A new server version is available for " + server.Name); ConsoleTab.WriteOut( "Download the latest version in the starter tab. The latest version is #" + latestversion); Thread t = new Thread(() => MetroMessageBox.Show(FindForm(), "A new server version is available for " + server.Name + "." + Environment.NewLine + "Download the latest version in the starter tab. The latest version is #" + latestversion, "Server update available", MessageBoxButtons.OK, MessageBoxIcon.Information) ); t.Start(); } break; case 2: // Auto update if (int.Parse(latestversion) > int.Parse(currentversion)) { ConsoleTab.WriteOut("New server version available: #" + latestversion + ". This version will be installed automaticly. You can disable this in the starter tab."); if (CBUpdateBranch.SelectedItem.ToString().ToLower().Contains("recommended")) { server.DownloadRecommendedVersion(TxtJarFile.Text); } if (CBUpdateBranch.SelectedItem.ToString().ToLower().Contains("beta")) { server.DownloadBetaVersion(TxtJarFile.Text); } if (CBUpdateBranch.SelectedItem.ToString().ToLower().Contains("dev")) { server.DownloadDevVersion(TxtJarFile.Text); } ConsoleTab.WriteOut("New server version installed."); } break; } ConsoleTab.WriteOut("Finished update check. Starting server..."); ConsoleTab.WriteOut("__________________________________________________________________"); } } catch (Exception exception) { Logger.Log(LogLevel.Severe, "StarterTab", "Failed to complete auto-update check for " + GetSelectedServer(), exception.Message); } }
/// <summary> /// Start a process, start the threads to read the output and send the output to the correct outputhandler /// </summary> /// <param name="executable">The executable to run</param> /// <param name="parameters">The parameters for the executable</param> /// <param name="server">The server that is being ran</param> /// <param name="serverDir">The directory that should be used as root for the minecraft server</param> /// <returns></returns> public static Boolean StartServer(string executable, string parameters, IMinecraftServer server, string serverDir = "") { try { if (string.IsNullOrEmpty(executable)) return false; if (string.IsNullOrEmpty(parameters)) parameters = ""; if (string.IsNullOrEmpty(serverDir)) { serverDir = Fl.SafeLocation(RequestFile.Serverdir); } FileInfo exeFileInfo = new FileInfo(executable); Server = server; RaiseServerStarting(); ServerProcess = new Process { StartInfo = new ProcessStartInfo { FileName = exeFileInfo.FullName, Arguments = parameters, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, ErrorDialog = false, UseShellExecute = false, WorkingDirectory = serverDir, StandardErrorEncoding = Encoding.Unicode, StandardOutputEncoding = Encoding.Unicode, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true }, EnableRaisingEvents = true }; // log from startinfo to ensure correct results (in case .NET would alter something) Logger.Log(LogLevel.Info, "ProcessHandler", "Starting new process: " + ServerProcess.StartInfo.FileName + " " + ServerProcess.StartInfo.Arguments); ServerProcess.Start(); ServerProcess.Exited += HandleStop; StartThreads(); RaiseServerStarted(); return true; } catch (Exception exception) { Logger.Log(LogLevel.Warning, "ProcessHandler", "Couldn't start server! " + executable + " " + parameters, exception.Message); return false; } }
/// <summary> /// Load all settings/buttons for a selected server /// </summary> private void LoadServer() { GBServer.UseWaitCursor = true; GBMaintainance.UseWaitCursor = true; IMinecraftServer server = GetSelectedServer(); if (server == null) { return; } Logger.Log(LogLevel.Info, "StarterTab", "Loading server: " + server.Name); PBServerLogo.Image = server.Logo; LLblSite.Text = "Site: " + server.Site; // Enable buttons as needed BtnDownloadRec.Enabled = server.CanDownloadRecommendedVersion; BtnDownloadBeta.Enabled = server.CanDownloadBetaVersion; BtnDownloadDev.Enabled = server.CanDownloadDevVersion; btnGetCurrentBuild.Enabled = server.CanGetCurrentVersion; // If this server doesn't use a custom assembly, use the java settings CBJavaVersion.Enabled = !server.HasCustomAssembly; NumMaxRam.Enabled = !server.HasCustomAssembly; NumMinRam.Enabled = !server.HasCustomAssembly; TBMaxRam.Enabled = !server.HasCustomAssembly; TBMinRam.Enabled = !server.HasCustomAssembly; TxtOptArg.Enabled = !server.HasCustomAssembly; TxtOptFlag.Enabled = !server.HasCustomAssembly; TxtJarFile.Enabled = !server.HasCustomAssembly; //Enable possible update settings //Notify needs getting the current and the latest version Boolean notifyRb = server.CanGetCurrentVersion && server.CanFetchRecommendedVersion; Boolean notifyBeta = server.CanGetCurrentVersion && server.CanFetchBetaVersion; Boolean notifyDev = server.CanGetCurrentVersion && server.CanFetchDevVersion; // Updating also needs the possibility to download Boolean updateRb = notifyRb && server.CanDownloadRecommendedVersion; Boolean updateBeta = notifyBeta && server.CanDownloadBetaVersion; Boolean updateDev = notifyDev && server.CanDownloadDevVersion; LblLatestDevValue.Text = "Not available"; if (server.CanFetchDevVersion) { LblLatestDevValue.Text = server.FetchDevVersionUiString; } metroToolTip.SetToolTip(LblLatestDevValue, LblLatestDevValue.Text); LblLatestBetaValue.Text = "Not available"; if (server.CanFetchBetaVersion) { LblLatestBetaValue.Text = server.FetchBetaVersionUiString; } metroToolTip.SetToolTip(LblLatestBetaValue, LblLatestBetaValue.Text); LblLatestRecommendedValue.Text = "Not available"; if (server.CanFetchRecommendedVersion) { LblLatestRecommendedValue.Text = server.FetchRecommendedVersionUiString; } metroToolTip.SetToolTip(LblLatestRecommendedValue, LblLatestRecommendedValue.Text); CBUpdateBehaviour.Items.Clear(); CBUpdateBehaviour.Items.Add("Don't check for updates"); // // DO NOT TRANSLATE BELOW // if (notifyRb || notifyBeta || notifyDev) { CBUpdateBehaviour.Items.Add("Check for updates and notify me"); } if (updateRb || updateBeta || updateDev) { CBUpdateBehaviour.Items.Add("Check for updates and auto update"); } // // DO NOT TRANSLATE ABOVE // int updatebehaviour = Config.ReadInt("starter", "updatebehaviour", 0); CBUpdateBehaviour.SelectedIndex = 0; if (CBUpdateBehaviour.Items.Count > updatebehaviour) { CBUpdateBehaviour.SelectedIndex = updatebehaviour; } CBUpdateBranch.Items.Clear(); // // DO NOT TRANSLATE BELOW // if (notifyRb) { CBUpdateBranch.Items.Add("Recommended builds"); } if (notifyBeta) { CBUpdateBranch.Items.Add("Beta builds"); } if (notifyDev) { CBUpdateBranch.Items.Add("Development builds"); } // // DO NOT TRANSLATE ABOVE // int updatebranch = Config.ReadInt("starter", "updatebranch", 0); if (CBUpdateBranch.Items.Count > 0) { CBUpdateBranch.SelectedIndex = 0; } if (CBUpdateBranch.Items.Count > updatebranch) { CBUpdateBranch.SelectedIndex = updatebranch; } // If there is a custom settings control, load it if (server.HasCustomSettingsControl) { _customControl = server.CustomSettingsControl; GBCustomSettings.Controls.Clear(); GBCustomSettings.Controls.Add(_customControl); GBCustomSettings.Controls[0].Dock = DockStyle.Fill; } else { _customControl = null; GBCustomSettings.Controls.Clear(); } GBServer.UseWaitCursor = false; GBMaintainance.UseWaitCursor = false; Logger.Log(LogLevel.Info, "StarterTab", "Loaded server: " + server.Name); }
/// <summary> /// Launch a new server /// </summary> /// <param name="server">the server type that will be executed</param> /// <param name="javaVersion">the java version to use</param> /// <param name="jarFile">the jar file to run</param> /// <param name="minMem">the minimum amount of memory to set</param> /// <param name="maxMem">the maximum amount of memory to set</param> /// <param name="defaultParameters">the parameters entered by the user (optional)</param> /// <param name="defaultFlags">the flags entered by the user (optional)</param> /// <param name="automated"> /// If this is an automated launch. Automated launches won't check for server updates and limit /// popups. /// </param> public void LaunchServer(IMinecraftServer server, JavaVersion javaVersion, string jarFile, UInt32 minMem, UInt32 maxMem, string defaultParameters = "", string defaultFlags = "", Boolean automated = false) { server.PrepareLaunch(); string parameters = server.GetLaunchParameters(defaultParameters); string flags = server.GetLaunchFlags(defaultFlags); string argument = parameters + " -Xms" + minMem + "M -Xmx" + maxMem + "M -jar \"" + jarFile + "\" " + flags; string executable = JavaApi.GetJavaPath(javaVersion); ProcessHandler.StartServer(executable, argument, server); }
/// <summary> /// Handle server output, raise all events that should be raised /// </summary> /// <param name="text">output text to handle</param> /// <param name="server">the server that should handle the output</param> /// <param name="fromStandardErrorOut">Is this message received on the error stream?</param> public static void HandleOutput(IMinecraftServer server, string text, Boolean fromStandardErrorOut = false) { RaiseOutputReceivedEvent(text); OutputParseResult result = server.ParseOutput(text); if (result == null) return; RaiseOutputParsedEvent(text, result); switch (result.Type) { case MessageType.Info: RaiseInfoMessageReceivedEvent(text, result); // detect an issued stop command (so the GUI knows this isn't a crash) if (result.Message == "[INFO] Stopping server" || result.Message == "[INFO] Stopping the server") ProcessHandler.ProcessHandler.MarkServerAsStopping(); break; case MessageType.Warning: RaiseWarningMessageReceivedEvent(text, result); CheckErrorCause(result.Message); //failed to bind to port comes on standardout, so we need to check anyway break; case MessageType.Severe: RaiseSevereMessageReceivedEvent(text, result); CheckErrorCause(result.Message); break; case MessageType.JavaStackTrace: RaiseJavaStackStraceMessageReceivedEvent(text, result); if (fromStandardErrorOut) CheckErrorCause(result.Message); break; case MessageType.JavaStatus: RaiseJavaStatusMessageReceivedEvent(text, result); if (fromStandardErrorOut) CheckErrorCause(result.Message); break; case MessageType.PlayerJoin: RaisePlayerJoinEvent(text, result, result.Action); break; case MessageType.PlayerLeave: RaisePlayerLeaveEvent(text, result, result.Action); break; case MessageType.PlayerKick: RaisePlayerKickEvent(text, result, result.Action); break; case MessageType.PlayerBan: RaisePlayerBanEvent(text, result, result.Action); break; case MessageType.PlayerIpBan: RaisePlayerIpBanEvent(text, result, result.Action); break; case MessageType.PlayerList: RaisePlayerListReceivedEvent(text, result, new Dictionary<string, string>()); break; default: RaiseUnknownMessageReceivedEvent(text, result); if (fromStandardErrorOut) CheckErrorCause(result.Message); break; } }
/// <summary> /// Handle server output, raise all events that should be raised /// </summary> /// <param name="text">output text to handle</param> /// <param name="server">the server that should handle the output</param> /// <param name="fromStandardErrorOut">Is this message received on the error stream?</param> public static void HandleOutput(IMinecraftServer server, string text, Boolean fromStandardErrorOut = false) { RaiseOutputReceivedEvent(text); OutputParseResult result = server.ParseOutput(text); if (result == null) { return; } RaiseOutputParsedEvent(text, result); switch (result.Type) { case MessageType.Info: RaiseInfoMessageReceivedEvent(text, result); // detect an issued stop command (so the GUI knows this isn't a crash) if (result.Message == "[INFO] Stopping server" || result.Message == "[INFO] Stopping the server") { ProcessHandler.ProcessHandler.MarkServerAsStopping(); } break; case MessageType.Warning: RaiseWarningMessageReceivedEvent(text, result); CheckErrorCause(result.Message); //failed to bind to port comes on standardout, so we need to check anyway break; case MessageType.Severe: RaiseSevereMessageReceivedEvent(text, result); CheckErrorCause(result.Message); break; case MessageType.JavaStackTrace: RaiseJavaStackStraceMessageReceivedEvent(text, result); if (fromStandardErrorOut) { CheckErrorCause(result.Message); } break; case MessageType.JavaStatus: RaiseJavaStatusMessageReceivedEvent(text, result); if (fromStandardErrorOut) { CheckErrorCause(result.Message); } break; case MessageType.PlayerJoin: RaisePlayerJoinEvent(text, result, result.Action); break; case MessageType.PlayerLeave: RaisePlayerLeaveEvent(text, result, result.Action); break; case MessageType.PlayerKick: RaisePlayerKickEvent(text, result, result.Action); break; case MessageType.PlayerBan: RaisePlayerBanEvent(text, result, result.Action); break; case MessageType.PlayerIpBan: RaisePlayerIpBanEvent(text, result, result.Action); break; case MessageType.PlayerList: RaisePlayerListReceivedEvent(text, result, new Dictionary <string, string>()); break; default: RaiseUnknownMessageReceivedEvent(text, result); if (fromStandardErrorOut) { CheckErrorCause(result.Message); } break; } }
/// <summary> /// Load all settings/buttons for a selected server /// </summary> private void LoadServer() { IMinecraftServer server = this.GetSelectedServer(); Logger.Log(LogLevel.Info, "StarterTab", "Loading server: " + server.Name); this.PBServerLogo.Image = server.Logo; this.LLblSite.Text = "Site: " + server.Site; // Enable buttons as needed this.BtnDownloadRec.Enabled = server.CanDownloadRecommendedVersion; this.BtnDownloadBeta.Enabled = server.CanDownloadBetaVersion; this.BtnDownloadDev.Enabled = server.CanDownloadDevVersion; // If this server doesn't use a custom assembly, use the java settings this.CBJavaVersion.Enabled = !server.HasCustomAssembly; this.NumMaxRam.Enabled = !server.HasCustomAssembly; this.NumMinRam.Enabled = !server.HasCustomAssembly; this.TBMaxRam.Enabled = !server.HasCustomAssembly; this.TBMinRam.Enabled = !server.HasCustomAssembly; this.TxtOptArg.Enabled = !server.HasCustomAssembly; this.TxtOptFlag.Enabled = !server.HasCustomAssembly; this.TxtJarFile.Enabled = !server.HasCustomAssembly; //Enable possible update settings //Notify needs getting the current and the latest version Boolean notifyRb = server.CanGetCurrentVersion && server.CanFetchRecommendedVersion; Boolean notifyBeta = server.CanGetCurrentVersion && server.CanFetchBetaVersion; Boolean notifyDev = server.CanGetCurrentVersion && server.CanFetchDevVersion; // Updating also needs the possibility to download Boolean updateRb = server.CanGetCurrentVersion && server.CanDownloadRecommendedVersion && server.CanFetchRecommendedVersion; Boolean updateBeta = server.CanGetCurrentVersion && server.CanDownloadBetaVersion && server.CanFetchBetaVersion; Boolean updateDev = server.CanGetCurrentVersion && server.CanDownloadDevVersion && server.CanFetchDevVersion; this.CBUpdateBehaviour.Items.Clear(); this.CBUpdateBehaviour.Items.Add("Don't check for updates"); this.CBUpdateBehaviour.SelectedIndex = 0; if (notifyRb || notifyBeta || notifyDev) { this.CBUpdateBehaviour.Items.Add("Check for updates and notify me"); } if (updateRb || updateBeta || updateDev) { this.CBUpdateBehaviour.Items.Add("Check for updates and auto update"); } this.CBUpdateBranch.Items.Clear(); if (updateRb) { this.CBUpdateBranch.Items.Add("Recommended builds"); } if (updateBeta) { this.CBUpdateBranch.Items.Add("Beta builds"); } if (updateDev) { this.CBUpdateBranch.Items.Add("Development builds"); } // If there is a custom settings control, load it if (server.HasCustomSettingsControl) { this._customControl = server.CustomSettingsControl; this.GBCustomSettings.Controls.Clear(); this.GBCustomSettings.Controls.Add(this._customControl); this.GBCustomSettings.Controls[0].Dock = DockStyle.Fill; } else { this._customControl = null; this.GBCustomSettings.Controls.Clear(); } Logger.Log(LogLevel.Info, "StarterTab", "Loaded server: " + server.Name); }