update brig in the API and patch cleanup

This commit is contained in:
Jake Potrebic
2024-12-18 18:30:29 -08:00
parent 5922e6334b
commit 49f715fdda
8 changed files with 72 additions and 29 deletions

View File

@@ -183,7 +183,6 @@
+ private void sendAsync(ServerPlayer player, java.util.Collection<CommandNode<CommandSourceStack>> dispatcherRootChildren) {
+ // Paper end - Perf: Async command map building
+ Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
+ // Paper - brigadier API removes the need to fill the map twice
RootCommandNode<SharedSuggestionProvider> rootCommandNode = new RootCommandNode<>();
map.put(this.dispatcher.getRoot(), rootCommandNode);
- this.fillUsableCommands(this.dispatcher.getRoot(), rootCommandNode, player.createCommandSourceStack(), map);
@@ -276,6 +275,7 @@
- argumentBuilder.executes(commandContext -> 0);
+ // Paper start - fix suggestions due to falsely equal nodes
+ // Always create a new instance
+ //noinspection Convert2Lambda
+ argumentBuilder.executes(new com.mojang.brigadier.Command<>() {
+ @Override
+ public int run(com.mojang.brigadier.context.CommandContext<SharedSuggestionProvider> commandContext) {

View File

@@ -4,11 +4,11 @@
public static void resolveChatMessage(CommandContext<CommandSourceStack> context, String key, Consumer<PlayerChatMessage> callback) throws CommandSyntaxException {
MessageArgument.Message message = context.getArgument(key, MessageArgument.Message.class);
+ // Paper start
+ // Paper start - brig message argument support
+ resolveChatMessage(message, context, key, callback);
+ }
+ public static void resolveChatMessage(MessageArgument.Message message, CommandContext<CommandSourceStack> context, String key, Consumer<PlayerChatMessage> callback) throws CommandSyntaxException {
+ // Paper end
+ // Paper end - brig message argument support
CommandSourceStack commandSourceStack = context.getSource();
Component component = message.resolveComponent(commandSourceStack);
CommandSigningContext signingContext = commandSourceStack.getSigningContext();