Skip to content

Commit 3da77e7

Browse files
committed
remove no-longer-needed hack redirect fix
1 parent f53c204 commit 3da77e7

2 files changed

Lines changed: 5 additions & 42 deletions

File tree

paper-server/patches/features/0009-Fix-entity-type-tags-suggestions-in-selectors.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ index cf923441da598637be74a5ffa4b4f948e01ff532..cbf32be9235921ebcaca88225120c2ca
3535
+ // Paper end - tell clients to ask server for suggestions for EntityArguments
3636
}
3737
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
38-
index b957894779d462ccfbf99c12dc3fc4c9f70f9747..2fb952b9891b21a6e668496e0065df4115ada82e 100644
38+
index 304563c8af5bfe9e5c6d39c0eef196be526e77a6..8d4127eb3f21849c89c347c270f24239ab708b5e 100644
3939
--- a/net/minecraft/commands/Commands.java
4040
+++ b/net/minecraft/commands/Commands.java
41-
@@ -503,6 +503,7 @@ public class Commands {
41+
@@ -502,6 +502,7 @@ public class Commands {
42+
CommandSourceStack source,
4243
Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> commandNodeToSuggestionNode
4344
) {
44-
commandNodeToSuggestionNode.keySet().removeIf((node) -> !org.spigotmc.SpigotConfig.sendNamespaced && node.getName().contains(":")); // Paper - Remove namedspaced from result nodes to prevent redirect trimming ~ see comment below
4545
+ boolean registeredAskServerSuggestionsForTree = false; // Paper - tell clients to ask server for suggestions for EntityArguments
4646
for (CommandNode<CommandSourceStack> commandNode : children) { // Paper - Perf: Async command map building; pass copy of children
4747
// Paper start - Brigadier API
4848
if (commandNode.clientNode != null) {
49-
@@ -566,6 +567,12 @@ public class Commands {
49+
@@ -529,6 +530,12 @@ public class Commands {
5050
RequiredArgumentBuilder<SharedSuggestionProvider, ?> requiredArgumentBuilder = (RequiredArgumentBuilder<SharedSuggestionProvider, ?>)argumentBuilder;
5151
if (requiredArgumentBuilder.getSuggestionsProvider() != null) {
5252
requiredArgumentBuilder.suggests(SuggestionProviders.safelySwap(requiredArgumentBuilder.getSuggestionsProvider()));

paper-server/patches/sources/net/minecraft/commands/Commands.java.patch

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
}
145145

146146
return null;
147-
@@ -360,25 +_,130 @@
147+
@@ -360,25 +_,93 @@
148148
}
149149

150150
public void sendCommands(ServerPlayer player) {
@@ -218,7 +218,6 @@
218218
Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> commandNodeToSuggestionNode
219219
) {
220220
- for (CommandNode<CommandSourceStack> commandNode : rootCommandSource.getChildren()) {
221-
+ commandNodeToSuggestionNode.keySet().removeIf((node) -> !org.spigotmc.SpigotConfig.sendNamespaced && node.getName().contains(":")); // Paper - Remove namedspaced from result nodes to prevent redirect trimming ~ see comment below
222221
+ for (CommandNode<CommandSourceStack> commandNode : children) { // Paper - Perf: Async command map building; pass copy of children
223222
+ // Paper start - Brigadier API
224223
+ if (commandNode.clientNode != null) {
@@ -228,42 +227,6 @@
228227
+ if (!org.spigotmc.SpigotConfig.sendNamespaced && commandNode.getName().contains(":")) continue; // Spigot
229228
if (commandNode.canUse(source)) {
230229
ArgumentBuilder<SharedSuggestionProvider, ?> argumentBuilder = (ArgumentBuilder) commandNode.createBuilder();
231-
+ // Paper start
232-
+ /*
233-
+ Because of how commands can be yeeted right left and center due to bad bukkit practices
234-
+ we need to be able to ensure that ALL commands are registered (even redirects).
235-
+
236-
+ What this will do is IF the redirect seems to be "dead" it will create a builder and essentially populate (flatten)
237-
+ all the children from the dead redirect to the node.
238-
+
239-
+ So, if minecraft:msg redirects to msg but the original msg node has been overriden minecraft:msg will now act as msg and will explicilty inherit its children.
240-
+
241-
+ The only way to fix this is to either:
242-
+ - Send EVERYTHING flattened, don't use redirects
243-
+ - Don't allow command nodes to be deleted
244-
+ - Do this :)
245-
+ */
246-
+
247-
+ // Is there an invalid command redirect?
248-
+ if (argumentBuilder.getRedirect() != null && commandNodeToSuggestionNode.get(argumentBuilder.getRedirect()) == null) {
249-
+ // Create the argument builder with the same values as the specified node, but with a different literal and populated children
250-
+
251-
+ CommandNode<SharedSuggestionProvider> redirect = argumentBuilder.getRedirect();
252-
+ // Diff copied from LiteralCommand#createBuilder
253-
+ final com.mojang.brigadier.builder.LiteralArgumentBuilder<SharedSuggestionProvider> builder = com.mojang.brigadier.builder.LiteralArgumentBuilder.literal(commandNode.getName());
254-
+ builder.requires(redirect.getRequirement());
255-
+ // builder.forward(redirect.getRedirect(), redirect.getRedirectModifier(), redirect.isFork()); We don't want to migrate the forward, since it's invalid.
256-
+ if (redirect.getCommand() != null) {
257-
+ builder.executes(redirect.getCommand());
258-
+ }
259-
+ // Diff copied from LiteralCommand#createBuilder
260-
+ for (CommandNode<SharedSuggestionProvider> child : redirect.getChildren()) {
261-
+ builder.then(child);
262-
+ }
263-
+
264-
+ argumentBuilder = builder;
265-
+ }
266-
+ // Paper end
267230
argumentBuilder.requires(suggestions -> true);
268231
if (argumentBuilder.getCommand() != null) {
269232
- argumentBuilder.executes(commandContext -> 0);

0 commit comments

Comments
 (0)