public bool SetValue( string key, string value ) {
switch( key ) {
case "ServerName":
return ValidateString( key, value, 1, 64 );
case "MOTD":
return ValidateString( key, value, 0, 64 );
case "MaxPlayers":
return ValidateInt( key, value, 1, MaxPlayersSupported );
case "DefaultClass":
if( value != "" ) {
if( classes.ParseClass( value ) != null ) {
settings[key] = classes.ParseClass( value ).name;
return true;
} else {
Log( "DefaultClass could not be parsed. It should be either blank (indicating \"use lowest class\") or a valid class name", LogType.Warning );
return false;
}
} else {
settings[key] = "";
return true;
}
case "Port":
return ValidateInt( key, value, 1, 65535 );
case "UploadBandwidth":
return ValidateInt( key, value, 1, 10000 );
case "ReservedSlotBehavior":
return ValidateEnum( key, value, "KickIdle", "KickRandom", "IncreaseMaxPlayers" );
case "IsPublic":
case "ClassColorsInChat":// TODO: colors in player names
case "ClassPrefixesInChat":
case "ClassPrefixesInList":
case "SaveOnShutdown":
case "BackupOnStartup":
case "BackupOnJoin":
case "BackupOnlyWhenChanged":
case "SendRedundantBlockUpdates":
case "NoPartialPositionUpdates":
return ValidateBool( key, value );
case "SystemMessageColor":
case "HelpColor":
case "SayColor":
return ValidateColor( key, value );
case "VerifyNames":
return ValidateEnum( key, value, "Always", "Balanced", "Never" );
case "SpamChatCount":
return ValidateInt( key, value, 2, 50 );
case "SpamChatTimer":
return ValidateInt( key, value, 1, 50 );
case "SpamBlockCount":
return ValidateInt( key, value, 2, 500 );
case "SpamBlockTimer":
return ValidateInt( key, value, 1, 50 );
case "SpamChatAction1":
case "SpamChatAction2":
case "SpamChatAction3":
return ValidateEnum( key, value, "Warn", "Mute", "Kick", "Demote", "Ban", "BanIP", "BanAll" );
case "SpamBlockAction1":
case "SpamBlockAction2":
case "SpamBlockAction3":
return ValidateEnum( key, value, "Warn", "Kick", "Demote", "Ban", "BanIP", "BanAll" );
case "SaveInterval":
return ValidateInt( key, value, 0, 1000000 );
case "BackupInterval":
return ValidateInt( key, value, 0, 100000 );
case "MaxBackups":
return ValidateInt( key, value, 0, 100000 );
case "MaxBackupSize":
return ValidateInt( key, value, 0, 1000000 );
case "LogMode":
return ValidateEnum( key, value, "None", "OneFile", "SplitBySession", "SplitByDay" );
case "MaxLogs":
return ValidateInt( key, value, 0, 100000 );
case "PolicyColorCodesInChat":
case "PolicyIllegalCharacters":
return ValidateEnum( key, value, "Allow", "ConsoleOnly", "Disallow" );
case "ProcessPriority":
return ValidateEnum( key, value, "", "High", "AboveNormal", "Normal", "BelowNormal", "Low" );
case "RunOnStartup":
return ValidateEnum( key, value, "Always", "OnUnexpectedShutdown", "Never" );
case "AutomaticUpdates":
return ValidateEnum( key, value, "Disabled", "Notify", "Prompt", "Auto" );
case "BlockUpdateThrottling":
return ValidateInt( key, value, 1, 100000 );
default:
settings[key] = value;
return true;
}
}