diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java index 075676e73..257779bfb 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java @@ -11,7 +11,7 @@ import com.mojang.brigadier.builder.RequiredArgumentBuilder; import com.mojang.brigadier.context.StringRange; import com.mojang.brigadier.suggestion.Suggestion; import com.mojang.brigadier.suggestion.Suggestions; -import com.mojang.brigadier.tree.LiteralCommandNode; +import com.mojang.brigadier.tree.CommandNode; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.Unpooled; @@ -67,6 +67,13 @@ import net.md_5.bungee.tab.TabList; public class DownstreamBridge extends PacketHandler { + // #3246: Recent versions of MinecraftForge alter Vanilla behaviour and require a command so that the executable flag is set + // If the flag is not set, then the command will appear and successfully tab complete, but cannot be successfully executed + private static final com.mojang.brigadier.Command DUMMY_COMMAND = (context) -> + { + return 0; + }; + // private final ProxyServer bungee; private final UserConnection con; private final ServerConnection server; @@ -654,9 +661,9 @@ public class DownstreamBridge extends PacketHandler { if ( !bungee.getDisabledCommands().contains( command.getKey() ) && commands.getRoot().getChild( command.getKey() ) == null && command.getValue().hasPermission( con ) ) { - LiteralCommandNode dummy = LiteralArgumentBuilder.literal( command.getKey() ) + CommandNode dummy = LiteralArgumentBuilder.literal( command.getKey() ).executes( DUMMY_COMMAND ) .then( RequiredArgumentBuilder.argument( "args", StringArgumentType.greedyString() ) - .suggests( Commands.SuggestionRegistry.ASK_SERVER ) ) + .suggests( Commands.SuggestionRegistry.ASK_SERVER ).executes( DUMMY_COMMAND ) ) .build(); commands.getRoot().addChild( dummy );