From 0d6f3ee3745a9d551c90ca654e0092b6f173ce0c Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 17 Feb 2019 10:10:41 +1100 Subject: [PATCH] Make 1.13 command injection normal functionality --- .../net/md_5/bungee/protocol/Protocol.java | 11 ++++------- .../net/md_5/bungee/conf/Configuration.java | 6 ------ .../bungee/connection/DownstreamBridge.java | 19 ++++++++----------- .../bungee/connection/UpstreamBridge.java | 2 +- 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java index 6e2abdc5..e6c3729c 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java @@ -180,13 +180,10 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_12, 0x1B ), map( ProtocolConstants.MINECRAFT_1_13, 0x1C ) ); - if ( Boolean.getBoolean( "net.md-5.bungee.protocol.register_commands" ) ) - { - TO_CLIENT.registerPacket( - Commands.class, - map( ProtocolConstants.MINECRAFT_1_13, 0x11 ) - ); - } + TO_CLIENT.registerPacket( + Commands.class, + map( ProtocolConstants.MINECRAFT_1_13, 0x11 ) + ); TO_SERVER.registerPacket( KeepAlive.class, diff --git a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java index 77d28348..49638c3a 100644 --- a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java +++ b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java @@ -61,7 +61,6 @@ public class Configuration implements ProxyConfig private int compressionThreshold = 256; private boolean preventProxyConnections; private boolean forgeSupport; - private boolean injectCommands; public void load() { @@ -93,11 +92,6 @@ public class Configuration implements ProxyConfig compressionThreshold = adapter.getInt( "network_compression_threshold", compressionThreshold ); preventProxyConnections = adapter.getBoolean( "prevent_proxy_connections", preventProxyConnections ); forgeSupport = adapter.getBoolean( "forge_support", forgeSupport ); - injectCommands = adapter.getBoolean( "inject_commands", injectCommands ); - if ( injectCommands ) - { - System.setProperty( "net.md-5.bungee.protocol.register_commands", "true" ); - } disabledCommands = new CaseInsensitiveSet( (Collection) adapter.getList( "disabled_commands", Arrays.asList( "disabledcommandhere" ) ) ); 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 75aebc65..0f96a796 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 @@ -575,20 +575,17 @@ public class DownstreamBridge extends PacketHandler { boolean modified = false; - if ( BungeeCord.getInstance().config.isInjectCommands() ) + for ( Map.Entry command : bungee.getPluginManager().getCommands() ) { - for ( Map.Entry command : bungee.getPluginManager().getCommands() ) + if ( !bungee.getDisabledCommands().contains( command.getKey() ) && commands.getRoot().getChild( command.getKey() ) == null && command.getValue().hasPermission( con ) ) { - if ( !bungee.getDisabledCommands().contains( command.getKey() ) && commands.getRoot().getChild( command.getKey() ) == null && command.getValue().hasPermission( con ) ) - { - LiteralCommandNode dummy = LiteralArgumentBuilder.literal( command.getKey() ) - .then( RequiredArgumentBuilder.argument( "args", StringArgumentType.greedyString() ) - .suggests( Commands.SuggestionRegistry.ASK_SERVER ) ) - .build(); - commands.getRoot().addChild( dummy ); + LiteralCommandNode dummy = LiteralArgumentBuilder.literal( command.getKey() ) + .then( RequiredArgumentBuilder.argument( "args", StringArgumentType.greedyString() ) + .suggests( Commands.SuggestionRegistry.ASK_SERVER ) ) + .build(); + commands.getRoot().addChild( dummy ); - modified = true; - } + modified = true; } } diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java index 83d7630e..540cf213 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java @@ -176,7 +176,7 @@ public class UpstreamBridge extends PacketHandler if ( con.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_13 ) { con.unsafe().sendPacket( new TabCompleteResponse( results ) ); - } else if ( BungeeCord.getInstance().config.isInjectCommands() ) + } else { int start = tabComplete.getCursor().lastIndexOf( ' ' ) + 1; int end = tabComplete.getCursor().length();