public static ConsoleCommandData SharedParseCommand( string text, out string commandName, ushort textPosition = 0) { if (string.IsNullOrEmpty(text)) { commandName = string.Empty; return(null); } ConsoleCommandParser.ParseCommandNameAndArguments( text, textPosition, out commandName, out var arguments, out var argumentIndexForSuggestion); BaseConsoleCommand consoleCommand = null; foreach (var command in allCommands) { if (command.GetNameOrAlias(commandName) .Equals(commandName, StringComparison.OrdinalIgnoreCase)) { consoleCommand = command; break; } } if (consoleCommand == null) { // unknown command return(null); } var kind = consoleCommand.Kind; if (IsClient && (kind & ConsoleCommandKinds.Client) == 0) { // non-client command return(null); } if (IsServer && (kind & ConsoleCommandKinds.ServerOperator) == 0 && (kind & ConsoleCommandKinds.ServerEveryone) == 0) { // non-server command return(null); } return(new ConsoleCommandData(consoleCommand, arguments, (byte)argumentIndexForSuggestion)); }
public static ConsoleCommandData SharedParseCommand( string text, out string commandName, ushort textPosition = 0) { if (string.IsNullOrEmpty(text)) { commandName = string.Empty; return(null); } ConsoleCommandParser.ParseCommandNameAndArguments( text, textPosition, out commandName, out var arguments, out var argumentIndexForSuggestion); var consoleCommand = SharedFindConsoleCommandByName(commandName); if (consoleCommand is null) { // unknown command return(null); } var kind = consoleCommand.Kind; if (IsClient && (kind & ConsoleCommandKinds.Client) == 0) { // non-client command return(null); } if (IsServer && (kind & ConsoleCommandKinds.ServerOperator) == 0 && (kind & ConsoleCommandKinds.ServerEveryone) == 0 && (kind & ConsoleCommandKinds.ServerModerator) == 0) { // non-server command return(null); } return(new ConsoleCommandData(consoleCommand, arguments, (byte)argumentIndexForSuggestion)); }