mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 06:50:12 +01:00
33 lines
2 KiB
Diff
33 lines
2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Rick <rickw320@hotmail.com>
|
|
Date: Tue, 26 Nov 2024 20:45:52 +0100
|
|
Subject: [PATCH] Fix incorrect command serialization by creating new Command
|
|
|
|
Fixes #11649 - As noted in the issue, when CommandNodes are serialized
|
|
they are used as the key in a Map. Their equals()/hashcode() should only
|
|
match if they are equal nodes (name & command), but due to the erasure of the command field pre-serialization, nodes with different commands can be mapped onto the same value. This causes the client to interpret both nodes as the same, causing suggestions where they should not.
|
|
|
|
This is fixed by creating a different no-op command for the
|
|
erasure, instead of them holding the same lambda.
|
|
|
|
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
|
index 56d6bbd37556f11a603aa3c8647217cc9a2dc5da..2e4dbcbfd002909da89b4e7d070ac2325b452a08 100644
|
|
--- a/src/main/java/net/minecraft/commands/Commands.java
|
|
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
|
@@ -586,9 +586,14 @@ public class Commands {
|
|
return true;
|
|
});
|
|
if (argumentbuilder.getCommand() != null) {
|
|
- argumentbuilder.executes((commandcontext) -> {
|
|
- return 0;
|
|
+ // Paper start - fix suggestions due to falsely equal nodes
|
|
+ argumentbuilder.executes(new com.mojang.brigadier.Command<io.papermc.paper.command.brigadier.CommandSourceStack>() {
|
|
+ @Override
|
|
+ public int run(com.mojang.brigadier.context.CommandContext<io.papermc.paper.command.brigadier.CommandSourceStack> commandContext) throws CommandSyntaxException {
|
|
+ return 0;
|
|
+ }
|
|
});
|
|
+ // Paper end
|
|
}
|
|
|
|
if (argumentbuilder instanceof RequiredArgumentBuilder) {
|