diff --git a/Commands/CommandReader.cs b/Commands/CommandReader.cs index d84bad819..f09ff9160 100644 --- a/Commands/CommandReader.cs +++ b/Commands/CommandReader.cs @@ -61,7 +61,7 @@ namespace ClassicalSharp.Commands { public bool NextOf( out T value, TryParseFunc parser ) { bool success = parser( Next(), out value ); - if( !success ) value = default( T); + if( !success ) value = default( T ); return success; } @@ -76,28 +76,22 @@ namespace ClassicalSharp.Commands { } public int RemainingArgs { - get { - int count = 0; - int pos = curOffset; - while( MoveNext() ) { - count++; - } - curOffset = pos; - return count; - } + get { return CountArgsFrom( curOffset ); } } public int TotalArgs { - get { - int count = 0; - int pos = curOffset; - curOffset = firstArgOffset; - while( MoveNext() ) { - count++; - } - curOffset = pos; - return count; + get { return CountArgsFrom( firstArgOffset ); } + } + + int CountArgsFrom( int startOffset ) { + int count = 0; + int pos = curOffset; + curOffset = startOffset; + while( MoveNext() ) { + count++; } + curOffset = pos; + return count; } public void Reset() { diff --git a/Commands/DefaultCommands.cs b/Commands/DefaultCommands.cs index 45f4f05f6..e7a4b9dd5 100644 --- a/Commands/DefaultCommands.cs +++ b/Commands/DefaultCommands.cs @@ -125,9 +125,7 @@ namespace ClassicalSharp.Commands { Window.AddChat( "&e/client: &cYou didn't specify a command to get help with." ); } else { Command cmd = Window.CommandManager.GetMatchingCommand( commandName ); - if( cmd == null ) { - Window.AddChat( "&e/client: Unrecognised command: \"&f" + commandName + "&e\"." ); - } else { + if( cmd != null ) { string[] help = cmd.Help; for( int i = 0; i < help.Length; i++ ) { Window.AddChat( help[i] );