mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-27 12:46:05 +01:00
#3246: Fix commands not working due to MinecraftForge changes
This commit is contained in:
parent
9c95d4ba43
commit
d2d157c1fe
@ -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 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user