/// <summary> /// Configures the path, jar and memory size for this server instance. /// </summary> /// <param name="profile">The server profile to apply.</param> public void ConfigureServer(ServerProfile profile) { ConfigureServer( profile.Path, profile.Jar, profile.MemorySize ); }
/// <summary> /// Assigns the passed ID to the specified server profile. /// </summary> /// <param name="profileIndex">The index of the server profile to assign an ID to.</param> /// <param name="newID">The ID to assign to this server profile.</param> public void AssignID(int profileIndex, int newID) { if (profileIndex >= 0 && profileIndex < mvarProfiles.Count) { ServerProfile profile = mvarProfiles[profileIndex]; profile.ID = newID; mvarProfiles[profileIndex] = profile; Changed = true; } }
private void LoadConfig() { string fileName = Path + "ServerProfile.cfg"; configINI.Load(fileName); int count = FixInt(configINI.GetValue("Profiles", "Count")); mvarProfiles.Clear(); for (int p = 0; p < count; p++) { string name = configINI.GetValue("Profile" + p.ToString(), "Name"); string serverPath = configINI.GetValue("Profile" + p.ToString(), "ServerPath"); string serverJar = configINI.GetValue("Profile" + p.ToString(), "ServerJar"); int memory = FixInt(configINI.GetValue("Profile" + p.ToString(), "Memory")); string startupMode = configINI.GetValue("Profile" + p.ToString(), "StartupMode").Trim().ToLower(); bool autoStart = false; if (startupMode.Length > 0 && startupMode[0] == 'a') { autoStart = true; } ServerProfile profile = new ServerProfile(name, serverPath, serverJar, memory, autoStart); int scheduleCount = FixInt(configINI.GetValue("Schedule" + p.ToString(), "Count")); if (scheduleCount > 0) { for (int s = 0; s < scheduleCount; s++) { string timeStamp = configINI.GetValue("Schedule" + p.ToString(), "Time" + s.ToString()); // Is this time stamp valid? if (timeStamp.Length == 5 && timeStamp[2] == ':') { string[] parts = timeStamp.Split(':'); if (parts.Length == 2) { int h = FixInt(parts[0]); int m = FixInt(parts[1]); if (h >= 0 && h < 24) { if (m == 0 || m == 15 || m == 30 || m == 45) { // When we reach this point, we have a valid time for the schedule string scheduleType = configINI.GetValue("Schedule" + p.ToString(), "Type" + s.ToString()).Trim().ToLower(); string backupPath = ""; if (scheduleType.Length > 0 && scheduleType[0] == 'b') { // If the schedule type starts with a 'b', we assume it's a backup schedule backupPath = configINI.GetValue("Schedule" + p.ToString(), "Path" + s.ToString()).Trim(); if (backupPath.Length > 0 && backupPath[1] == ':') { // Set the schedule type to backup, since we got a potentially valid path scheduleType = "backup"; } else { // The stored path doesnt seem to be useful, so // ... we'll default back to a restart schedule scheduleType = "restart"; } } else { // Otherwise we'll force a restart schedule scheduleType = "restart"; } // Finally store the schedule data ... Array.Resize(ref profile.Schedules, profile.Schedules.Length + 1); // switch (scheduleType) { case "backup": profile.Schedules[profile.Schedules.Length - 1] = new ScheduleProfile(-1, h, m, backupPath); break; case "restart": profile.Schedules[profile.Schedules.Length - 1] = new ScheduleProfile(-1, h, m); break; } } } } } } } mvarProfiles.Add(profile); } Changed = false; }
/// <summary> /// Removes the specified profile from the profile list. /// </summary> /// <param name="profile">The profile to remove.</param> public void Remove(ServerProfile profile) { mvarProfiles.Remove(profile); Changed = true; }
/// <summary> /// Adds the passed server profile to the config list. /// </summary> /// <param name="profile">The profile to add.</param> public void Add(ServerProfile profile) { mvarProfiles.Add(profile); Changed = true; }