Merge some upgrades from AsyncMCC branch

This commit is contained in:
BruceChen 2023-01-14 21:32:19 +08:00
parent 1298654693
commit b4d7d64cdd
2 changed files with 59 additions and 37 deletions

View file

@ -21,14 +21,20 @@ namespace MinecraftClient.CommandHandler.ArgumentType
public override WindowActionType Parse(IStringReader reader)
{
reader.SkipWhitespace();
string inputStr = reader.ReadString();
foreach (var action in SupportActions)
string inputStr = reader.ReadString().ToLower();
return inputStr switch
{
string actionStr = action.ToString();
if (string.Compare(inputStr, actionStr, true) == 0)
return action;
}
throw CommandSyntaxException.BuiltInExceptions.LiteralIncorrect().CreateWithContext(reader, inputStr);
"left" => WindowActionType.LeftClick,
"leftclick" => WindowActionType.LeftClick,
"right" => WindowActionType.RightClick,
"rightclick" => WindowActionType.RightClick,
"mid" => WindowActionType.MiddleClick,
"middle" => WindowActionType.MiddleClick,
"middleclick" => WindowActionType.MiddleClick,
"shift" => WindowActionType.ShiftClick,
"shiftclick" => WindowActionType.ShiftClick,
_ => throw CommandSyntaxException.BuiltInExceptions.LiteralIncorrect().CreateWithContext(reader, inputStr)
};
}
public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)