diff --git a/src/SampSharp.GameMode/SAMP/Commands/CommandsManager.cs b/src/SampSharp.GameMode/SAMP/Commands/CommandsManager.cs index 49de76638..2149db9d3 100644 --- a/src/SampSharp.GameMode/SAMP/Commands/CommandsManager.cs +++ b/src/SampSharp.GameMode/SAMP/Commands/CommandsManager.cs @@ -218,7 +218,7 @@ private static IEnumerable GetCommandGroupPaths(MethodInfo method) public ICommand GetCommandForText(BasePlayer player, string commandText) { ICommand candidate = null; - var isFullMath = false; + var isFullMatch = false; var candidateLength = 0; foreach (var command in _commands) @@ -227,9 +227,9 @@ public ICommand GetCommandForText(BasePlayer player, string commandText) { case CommandCallableResponse.True: - if (candidateLength < matchedNameLength || candidateLength == matchedNameLength && !isFullMath) + if (candidateLength < matchedNameLength || candidateLength == matchedNameLength && !isFullMatch) { - isFullMath = true; + isFullMatch = true; candidateLength = matchedNameLength; candidate = command; } diff --git a/src/SampSharp.GameMode/SAMP/Commands/DefaultCommand.cs b/src/SampSharp.GameMode/SAMP/Commands/DefaultCommand.cs index 8d1372625..8293c6ab3 100644 --- a/src/SampSharp.GameMode/SAMP/Commands/DefaultCommand.cs +++ b/src/SampSharp.GameMode/SAMP/Commands/DefaultCommand.cs @@ -294,7 +294,7 @@ public virtual CommandCallableResponse CanInvoke(BasePlayer player, string comma if (!name.Matches(commandText, IsCaseIgnored)) continue; matchedNameLength = name.Length; - commandText = commandText.Substring(name.Length); + commandText = commandText.Substring(name.Length).Trim(); var result = GetArguments(commandText, out _, out var argumentsLength); matchedNameLength += argumentsLength; return result diff --git a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/EnumType.cs b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/EnumType.cs index 9c11b408e..35349ea71 100644 --- a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/EnumType.cs +++ b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/EnumType.cs @@ -56,13 +56,13 @@ public EnumType() /// public bool Parse(ref string commandText, out object output, bool isNullable) { - var text = commandText.TrimStart(); + commandText = commandText.TrimStart(); output = null; - if (string.IsNullOrEmpty(text)) + if (string.IsNullOrEmpty(commandText)) return false; - var word = text.Split(' ').First(); + var word = commandText.Split(' ').First(); var lowerWord = word.ToLower(); // find all candiates containing the input word, case insensitive. diff --git a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/FloatType.cs b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/FloatType.cs index c42a70339..95782437d 100644 --- a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/FloatType.cs +++ b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/FloatType.cs @@ -36,13 +36,13 @@ public class FloatType : ICommandParameterType /// public bool Parse(ref string commandText, out object output, bool isNullable) { - var text = commandText.TrimStart(); + commandText = commandText.TrimStart(); output = null; - if (string.IsNullOrEmpty(text)) + if (string.IsNullOrEmpty(commandText)) return false; - var word = text.Split(' ').First(); + var word = commandText.Split(' ').First(); // Unify input culture. var preProcessedWord = word; diff --git a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/IntegerType.cs b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/IntegerType.cs index aeafd4cd9..3eccb6d25 100644 --- a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/IntegerType.cs +++ b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/IntegerType.cs @@ -39,14 +39,14 @@ public class IntegerType : ICommandParameterType /// public bool Parse(ref string commandText, out object output, bool isNullable) { - var text = commandText.TrimStart(); + commandText = commandText.TrimStart(); output = null; - if (string.IsNullOrEmpty(text)) + if (string.IsNullOrEmpty(commandText)) return false; - var word = text.Split(' ').First(); + var word = commandText.Split(' ').First(); // Regular base 10 numbers (eg. 14143) diff --git a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/NullableEnumType.cs b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/NullableEnumType.cs index 7f794b05e..b91dfc7ff 100644 --- a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/NullableEnumType.cs +++ b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/NullableEnumType.cs @@ -57,13 +57,13 @@ public NullableEnumType() /// public bool Parse(ref string commandText, out object output, bool isNullable) { - var text = commandText.TrimStart(); + commandText = commandText.TrimStart(); output = null; - if (string.IsNullOrEmpty(text)) + if (string.IsNullOrEmpty(commandText)) return false; - var word = text.Split(' ').First(); + var word = commandText.Split(' ').First(); var lowerWord = word.ToLower(); // find all candiates containing the input word, case insensitive. diff --git a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/PlayerType.cs b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/PlayerType.cs index 4dc4cf5d6..e0924b2d6 100644 --- a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/PlayerType.cs +++ b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/PlayerType.cs @@ -37,13 +37,13 @@ public class PlayerType : ICommandParameterType /// public bool Parse(ref string commandText, out object output, bool isNullable) { - var text = commandText.TrimStart(); + commandText = commandText.TrimStart(); output = null; - if (string.IsNullOrEmpty(text)) + if (string.IsNullOrEmpty(commandText)) return false; - var word = text.Split(' ').First(); + var word = commandText.Split(' ').First(); // find a player with a matching id. if (int.TryParse(word, NumberStyles.Integer, CultureInfo.InvariantCulture, out var id)) diff --git a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/TextType.cs b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/TextType.cs index d115176b0..351f67fad 100644 --- a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/TextType.cs +++ b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/TextType.cs @@ -33,15 +33,15 @@ public class TextType : ICommandParameterType /// public bool Parse(ref string commandText, out object output, bool isNullable) { - var text = commandText.Trim(); + commandText = commandText.Trim(); - if (string.IsNullOrEmpty(text)) + if (string.IsNullOrEmpty(commandText)) { output = null; return false; } - output = text; + output = commandText; commandText = string.Empty; return true; } diff --git a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/VehicleType.cs b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/VehicleType.cs index 50e80f1df..a2b46cbf1 100644 --- a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/VehicleType.cs +++ b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/VehicleType.cs @@ -37,13 +37,13 @@ public class VehicleType : ICommandParameterType /// public bool Parse(ref string commandText, out object output, bool isNullable) { - var text = commandText.TrimStart(); + commandText = commandText.TrimStart(); output = null; - if (string.IsNullOrEmpty(text)) + if (string.IsNullOrEmpty(commandText)) return false; - var word = text.Split(' ').First(); + var word = commandText.Split(' ').First(); // find a vehicle with a matching id. if (!int.TryParse(word, NumberStyles.Integer, CultureInfo.InvariantCulture, out var id)) diff --git a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/WordType.cs b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/WordType.cs index 770ca72c4..f7e14e2a7 100644 --- a/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/WordType.cs +++ b/src/SampSharp.GameMode/SAMP/Commands/ParameterTypes/WordType.cs @@ -35,15 +35,15 @@ public class WordType : ICommandParameterType /// public bool Parse(ref string commandText, out object output, bool isNullable) { - var text = commandText.TrimStart(); + commandText = commandText.TrimStart(); - if (string.IsNullOrEmpty(text)) + if (string.IsNullOrEmpty(commandText)) { output = null; return false; } - var word = text.Split(' ').First(); + var word = commandText.Split(' ').First(); commandText = commandText.Substring(word.Length).TrimStart(' ');