Add submodule MinecraftProtocolLibrary

This commit is contained in:
BruceChen 2022-12-23 00:50:20 +08:00
parent 87026e1bfb
commit 3f1de66af3
62 changed files with 1093 additions and 450 deletions

View file

@ -5,7 +5,7 @@ using Brigadier.NET.ArgumentTypes;
using Brigadier.NET.Context;
using Brigadier.NET.Exceptions;
using Brigadier.NET.Suggestion;
using MinecraftClient.Mapping;
using MinecraftClient.EntityHandler;
namespace MinecraftClient.CommandHandler.ArgumentType
{

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)

View file

@ -4,7 +4,7 @@ using Brigadier.NET;
using Brigadier.NET.ArgumentTypes;
using Brigadier.NET.Context;
using Brigadier.NET.Suggestion;
using MinecraftClient.Mapping;
using MinecraftClient.EntityHandler;
namespace MinecraftClient.CommandHandler.ArgumentType
{