public Server(string serverId = null, string configLocation = null) { this.serverId = serverId; serverDir = string.IsNullOrEmpty(this.serverId) ? null : MultiAdminConfig.GlobalServersFolder + Path.DirectorySeparatorChar + this.serverId; this.configLocation = configLocation ?? MultiAdminConfig.GlobalConfigLocation ?? serverDir; logDir = (string.IsNullOrEmpty(serverDir) ? string.Empty : serverDir + Path.DirectorySeparatorChar) + "logs"; // Load config serverConfig = string.IsNullOrEmpty(this.configLocation) ? new MultiAdminConfig() : new MultiAdminConfig(this.configLocation + Path.DirectorySeparatorChar + MultiAdminConfig.ConfigFileName); // Register all features RegisterFeatures(); }
public Server(string serverId = null, string configLocation = null, uint?port = null, string[] args = null) { this.serverId = serverId; serverDir = string.IsNullOrEmpty(this.serverId) ? null : Utils.GetFullPathSafe(Path.Combine(MultiAdminConfig.GlobalConfig.ServersFolder.Value, this.serverId)); this.configLocation = Utils.GetFullPathSafe(configLocation) ?? Utils.GetFullPathSafe(MultiAdminConfig.GlobalConfig.ConfigLocation.Value) ?? Utils.GetFullPathSafe(serverDir); // Load config serverConfig = MultiAdminConfig.GlobalConfig; // Load config hierarchy string serverConfigLocation = this.configLocation; while (!string.IsNullOrEmpty(serverConfigLocation)) { // Update the Server object's config location with the valid config location this.configLocation = serverConfigLocation; // Load the child MultiAdminConfig serverConfig = new MultiAdminConfig(Path.Combine(serverConfigLocation, MultiAdminConfig.ConfigFileName), serverConfig); // Set the server config location to the value from the config, this should be empty or null if there is no valid value serverConfigLocation = Utils.GetFullPathSafe(serverConfig.ConfigLocation.Value); // If the config hierarchy already contains the MultiAdmin config from the target path, stop looping // Without this, a user could unintentionally cause a lockup when their server starts up due to infinite looping if (serverConfig.ConfigHierarchyContainsPath(serverConfigLocation)) { break; } } // Set port this.port = port; // Set args this.args = args; logDir = Utils.GetFullPathSafe(Path.Combine(string.IsNullOrEmpty(serverDir) ? "" : serverDir, serverConfig.LogLocation.Value)); // Register all features RegisterFeatures(); }
public Server(string serverId = null, string configLocation = null, uint?port = null) { this.serverId = serverId; serverDir = string.IsNullOrEmpty(this.serverId) ? null : Utils.GetFullPathSafe(MultiAdminConfig.GlobalConfig.ServersFolder + Path.DirectorySeparatorChar + this.serverId); this.configLocation = Utils.GetFullPathSafe(configLocation) ?? Utils.GetFullPathSafe(MultiAdminConfig.GlobalConfig.ConfigLocation) ?? Utils.GetFullPathSafe(serverDir); this.port = port; logDir = Utils.GetFullPathSafe((string.IsNullOrEmpty(serverDir) ? string.Empty : serverDir + Path.DirectorySeparatorChar) + "logs"); // Load config serverConfig = string.IsNullOrEmpty(this.configLocation) ? MultiAdminConfig.GlobalConfig : new MultiAdminConfig(this.configLocation + Path.DirectorySeparatorChar + MultiAdminConfig.ConfigFileName); // Register all features RegisterFeatures(); }