From c0704194ec34c8a662a8bf91f64f6574598d556e Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 7 Jun 2018 21:49:20 +1000 Subject: [PATCH 01/24] Revert lombok update - breaks incremental compilation --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 42f208d741..e7cec244eb 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.projectlombok lombok - 1.18.0 + 1.16.16 provided From 76dc32ee3259c9d52ce71467c926c055693f5e92 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 20 Jun 2018 15:43:57 +1000 Subject: [PATCH 02/24] Enable IPv6 networking stack --- proxy/src/main/java/net/md_5/bungee/BungeeCord.java | 1 - 1 file changed, 1 deletion(-) diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 778732395f..5ca4fe8ae5 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -249,7 +249,6 @@ public BungeeCord() throws IOException @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE") public void start() throws Exception { - System.setProperty( "java.net.preferIPv4Stack", "true" ); // Minecraft does not support IPv6 System.setProperty( "io.netty.selectorAutoRebuildThreshold", "0" ); // Seems to cause Bungee to stop accepting connections if ( System.getProperty( "io.netty.leakDetectionLevel" ) == null ) { From 730715e68b7a6fe4b64e3b7a9b3b166d35f30abe Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 21 Jun 2018 12:52:03 +1000 Subject: [PATCH 03/24] #2437: Behave more like underlying servers and don't send no permission messages during tab completion --- api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java index 71a5a15829..096538a7a7 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java @@ -147,7 +147,7 @@ public boolean dispatchCommand(CommandSender sender, String commandLine, List Date: Sun, 8 Jul 2018 01:59:30 +0200 Subject: [PATCH 04/24] #2450: Instantiate PluginManager (and EventBus) after the BungeeCord Logger --- .../src/main/java/net/md_5/bungee/BungeeCord.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 5ca4fe8ae5..d0b987361d 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -138,7 +138,7 @@ public class BungeeCord extends ProxyServer * Plugin manager. */ @Getter - public final PluginManager pluginManager = new PluginManager( this ); + public final PluginManager pluginManager; @Getter @Setter private ReconnectHandler reconnectHandler; @@ -170,12 +170,6 @@ public class BungeeCord extends ProxyServer { // TODO: Proper fallback when we interface the manager - getPluginManager().registerCommand( null, new CommandReload() ); - getPluginManager().registerCommand( null, new CommandEnd() ); - getPluginManager().registerCommand( null, new CommandIP() ); - getPluginManager().registerCommand( null, new CommandBungee() ); - getPluginManager().registerCommand( null, new CommandPerms() ); - registerChannel( "BungeeCord" ); } @@ -220,6 +214,13 @@ public BungeeCord() throws IOException System.setErr( new PrintStream( new LoggingOutputStream( logger, Level.SEVERE ), true ) ); System.setOut( new PrintStream( new LoggingOutputStream( logger, Level.INFO ), true ) ); + pluginManager = new PluginManager( this ); + getPluginManager().registerCommand( null, new CommandReload() ); + getPluginManager().registerCommand( null, new CommandEnd() ); + getPluginManager().registerCommand( null, new CommandIP() ); + getPluginManager().registerCommand( null, new CommandBungee() ); + getPluginManager().registerCommand( null, new CommandPerms() ); + if ( !Boolean.getBoolean( "net.md_5.bungee.native.disable" ) ) { if ( EncryptionUtil.nativeFactory.load() ) From ff42394bdb9cc302516126cd43558b7dd0f306a3 Mon Sep 17 00:00:00 2001 From: Rincewind34 Date: Sun, 8 Jul 2018 09:55:45 +0200 Subject: [PATCH 05/24] #2427: [Trivial] Fix small mistake in Title documentation --- api/src/main/java/net/md_5/bungee/api/Title.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/net/md_5/bungee/api/Title.java b/api/src/main/java/net/md_5/bungee/api/Title.java index 601518ba5d..4717f40de2 100644 --- a/api/src/main/java/net/md_5/bungee/api/Title.java +++ b/api/src/main/java/net/md_5/bungee/api/Title.java @@ -65,7 +65,7 @@ public interface Title * duration specified in {@link #fadeOut(int)}. The default value for the * official Minecraft version is 60 (3 seconds). * - * @param ticks The amount of ticks (1/20 second) for the fade in effect. + * @param ticks The amount of ticks (1/20 second) for the stay effect. * @return This title configuration. */ public Title stay(int ticks); From 7410ce9077e0be81b29fd40f6a3cbf784a0238ae Mon Sep 17 00:00:00 2001 From: Minecrell Date: Mon, 9 Jul 2018 01:57:21 +0200 Subject: [PATCH 06/24] #2449: Avoid stopping if already in progress Currently it is possible to stop the proxy multiple times, causing the shutdown routines to be called twice. This doesn't make any sense and may even cause problems with some plugins. Cancel early if stopping is already in progress to avoid this. --- proxy/src/main/java/net/md_5/bungee/BungeeCord.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index d0b987361d..fd4c2bf91e 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -379,8 +379,14 @@ public void stop() } @Override - public void stop(final String reason) + public synchronized void stop(final String reason) { + if ( !isRunning ) + { + return; + } + isRunning = false; + new Thread( "Shutdown Thread" ) { @Override @@ -388,8 +394,6 @@ public void stop(final String reason) @SuppressWarnings("TooBroadCatch") public void run() { - BungeeCord.this.isRunning = false; - stopListeners(); getLogger().info( "Closing pending connections" ); From d591d0ed291e11772b612c3b247c5b053a5eb037 Mon Sep 17 00:00:00 2001 From: Nathan Poirier Date: Mon, 9 Jul 2018 01:58:00 +0200 Subject: [PATCH 07/24] #2451: Fix direction in BadPacketException message --- .../main/java/net/md_5/bungee/protocol/MinecraftDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java index e7cb380342..ea44573d15 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java @@ -34,7 +34,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) t if ( in.isReadable() ) { - throw new BadPacketException( "Did not read all bytes from packet " + packet.getClass() + " " + packetId + " Protocol " + protocol + " Direction " + prot ); + throw new BadPacketException( "Did not read all bytes from packet " + packet.getClass() + " " + packetId + " Protocol " + protocol + " Direction " + prot.getDirection() ); } } else { From c416c44f438e24293062aae0189075fc67854385 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 9 Jul 2018 09:59:33 +1000 Subject: [PATCH 08/24] Deprecate not API ProxyServer.start method --- api/src/main/java/net/md_5/bungee/api/ProxyServer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyServer.java b/api/src/main/java/net/md_5/bungee/api/ProxyServer.java index 11c5b68576..ccc8153fe8 100644 --- a/api/src/main/java/net/md_5/bungee/api/ProxyServer.java +++ b/api/src/main/java/net/md_5/bungee/api/ProxyServer.java @@ -159,7 +159,9 @@ public static void setInstance(ProxyServer instance) * * @throws Exception any exception thrown during startup causing the * instance to fail to boot + * @deprecated not API, will be removed in a future version */ + @Deprecated public abstract void start() throws Exception; /** From fa542c70df4c797be510bfd36327181348f0f2bf Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 9 Jul 2018 12:52:53 +1000 Subject: [PATCH 09/24] Fix incorrect whitespacing --- proxy/src/main/java/net/md_5/bungee/BungeeCord.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index fd4c2bf91e..2555348f0c 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -273,7 +273,7 @@ public void start() throws Exception registerChannel( ForgeConstants.FML_TAG ); registerChannel( ForgeConstants.FML_HANDSHAKE_TAG ); registerChannel( ForgeConstants.FORGE_REGISTER ); - + getLogger().warning( "MinecraftForge support is currently unmaintained and may have unresolved issues. Please use at your own risk." ); } From ceb9ea1e52b0391a824a3a87c3e07e6db9ca178b Mon Sep 17 00:00:00 2001 From: PROgrm_JARvis Date: Mon, 11 Jun 2018 22:56:32 +0300 Subject: [PATCH 10/24] #2436: Extend chat module with Joiner functional interface support --- .../bungee/api/chat/ComponentBuilder.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/chat/src/main/java/net/md_5/bungee/api/chat/ComponentBuilder.java b/chat/src/main/java/net/md_5/bungee/api/chat/ComponentBuilder.java index 7f4ae5ca38..dfdc7bf0b1 100644 --- a/chat/src/main/java/net/md_5/bungee/api/chat/ComponentBuilder.java +++ b/chat/src/main/java/net/md_5/bungee/api/chat/ComponentBuilder.java @@ -166,6 +166,37 @@ public ComponentBuilder append(String text, FormatRetention retention) return this; } + /** + * Allows joining additional components to this builder using the given + * {@link Joiner} and {@link FormatRetention#ALL}. + * + * Simply executes the provided joiner on this instance to facilitate a + * chain pattern. + * + * @param joiner joiner used for operation + * @return this ComponentBuilder for chaining + */ + public ComponentBuilder append(Joiner joiner) + { + return joiner.join( this, FormatRetention.ALL ); + } + + /** + * Allows joining additional components to this builder using the given + * {@link Joiner}. + * + * Simply executes the provided joiner on this instance to facilitate a + * chain pattern. + * + * @param joiner joiner used for operation + * @param retention the formatting to retain + * @return this ComponentBuilder for chaining + */ + public ComponentBuilder append(Joiner joiner, FormatRetention retention) + { + return joiner.join( this, retention ); + } + /** * Sets the color of the current part. * @@ -332,4 +363,25 @@ public static enum FormatRetention */ ALL } + + /** + * Functional interface to join additional components to a ComponentBuilder. + */ + public interface Joiner + { + + /** + * Joins additional components to the provided {@link ComponentBuilder} + * and then returns it to fulfill a chain pattern. + * + * Retention may be ignored and is to be understood as an optional + * recommendation to the Joiner and not as a guarantee to have a + * previous component in builder unmodified. + * + * @param componentBuilder to which to append additional components + * @param retention the formatting to possibly retain + * @return input componentBuilder for chaining + */ + ComponentBuilder join(ComponentBuilder componentBuilder, FormatRetention retention); + } } From b1cc72e2127622385abfcb8d7cc0cc3a976576f6 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 15 Jul 2018 10:00:00 +1000 Subject: [PATCH 11/24] Minecraft 1.13-pre7 support --- README.md | 2 +- api/pom.xml | 4 +- .../java/net/md_5/bungee/api/ProxyServer.java | 10 - .../md_5/bungee/api/config/ServerInfo.java | 8 + .../bungee/api/connection/ProxiedPlayer.java | 4 + .../md_5/bungee/api/connection/Server.java | 4 + .../java/net/md_5/bungee/api/score/Team.java | 2 +- bootstrap/pom.xml | 4 +- chat/pom.xml | 4 +- config/pom.xml | 4 +- event/pom.xml | 4 +- log/pom.xml | 4 +- module/cmd-alert/pom.xml | 4 +- module/cmd-find/pom.xml | 4 +- module/cmd-list/pom.xml | 4 +- module/cmd-send/pom.xml | 4 +- module/cmd-server/pom.xml | 4 +- module/pom.xml | 4 +- module/reconnect-yaml/pom.xml | 4 +- native/pom.xml | 4 +- pom.xml | 2 +- protocol/pom.xml | 4 +- .../protocol/AbstractPacketHandler.java | 10 + .../net/md_5/bungee/protocol/Protocol.java | 91 ++++++--- .../bungee/protocol/ProtocolConstants.java | 7 +- .../protocol/packet/LoginPayloadRequest.java | 51 +++++ .../protocol/packet/LoginPayloadResponse.java | 58 ++++++ .../bungee/protocol/packet/PluginMessage.java | 33 +++- .../protocol/packet/ScoreboardObjective.java | 36 +++- .../protocol/packet/TabCompleteRequest.java | 55 ++++-- .../protocol/packet/TabCompleteResponse.java | 76 +++++++- .../net/md_5/bungee/protocol/packet/Team.java | 34 +++- .../protocol/packet/PluginMessageTest.java | 17 ++ proxy/pom.xml | 4 +- .../main/java/net/md_5/bungee/BungeeCord.java | 8 +- .../java/net/md_5/bungee/PacketConstants.java | 1 - .../java/net/md_5/bungee/ServerConnector.java | 19 +- .../bungee/connection/DownstreamBridge.java | 13 +- .../bungee/connection/InitialHandler.java | 17 ++ .../md_5/bungee/connection/PingHandler.java | 11 ++ .../bungee/connection/UpstreamBridge.java | 9 +- .../net/md_5/bungee/entitymap/EntityMap.java | 89 +++++++-- .../md_5/bungee/entitymap/EntityMap_1_13.java | 183 ++++++++++++++++++ .../java/net/md_5/bungee/util/BufUtil.java | 15 ++ query/pom.xml | 4 +- 45 files changed, 797 insertions(+), 136 deletions(-) create mode 100644 protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadRequest.java create mode 100644 protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadResponse.java create mode 100644 protocol/src/test/java/net/md_5/bungee/protocol/packet/PluginMessageTest.java create mode 100644 proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java create mode 100644 proxy/src/main/java/net/md_5/bungee/util/BufUtil.java diff --git a/README.md b/README.md index 331a448902..8bb27482e6 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,4 @@ Binaries -------- Precompiled binaries are available for end users on [Jenkins](https://www.spigotmc.org/go/bungeecord-dl). -(c) 2012-2017 SpigotMC Pty. Ltd. +(c) 2012-2018 SpigotMC Pty. Ltd. diff --git a/api/pom.xml b/api/pom.xml index 96a4673887..5432a6ebd4 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-api - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar BungeeCord-API diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyServer.java b/api/src/main/java/net/md_5/bungee/api/ProxyServer.java index ccc8153fe8..baae54f64b 100644 --- a/api/src/main/java/net/md_5/bungee/api/ProxyServer.java +++ b/api/src/main/java/net/md_5/bungee/api/ProxyServer.java @@ -154,16 +154,6 @@ public static void setInstance(ProxyServer instance) */ public abstract void stop(String reason); - /** - * Start this instance so that it may accept connections. - * - * @throws Exception any exception thrown during startup causing the - * instance to fail to boot - * @deprecated not API, will be removed in a future version - */ - @Deprecated - public abstract void start() throws Exception; - /** * Register a channel for use with plugin messages. This is required by some * server / client implementations. diff --git a/api/src/main/java/net/md_5/bungee/api/config/ServerInfo.java b/api/src/main/java/net/md_5/bungee/api/config/ServerInfo.java index e9f1ff6696..7b7c987f0e 100644 --- a/api/src/main/java/net/md_5/bungee/api/config/ServerInfo.java +++ b/api/src/main/java/net/md_5/bungee/api/config/ServerInfo.java @@ -56,6 +56,10 @@ public interface ServerInfo * Send data by any available means to this server. This data may be queued * and there is no guarantee of its timely arrival. * + * In recent Minecraft versions channel names must contain a colon separator + * and consist of [a-z0-9/._-]. This will be enforced in a future version. + * The "BungeeCord" channel is an exception and may only take this form. + * * @param channel the channel to send this data via * @param data the data to send */ @@ -64,6 +68,10 @@ public interface ServerInfo /** * Send data by any available means to this server. * + * In recent Minecraft versions channel names must contain a colon separator + * and consist of [a-z0-9/._-]. This will be enforced in a future version. + * The "BungeeCord" channel is an exception and may only take this form. + * * @param channel the channel to send this data via * @param data the data to send * @param queue hold the message for later sending if it cannot be sent diff --git a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java index a7334c87cd..333d39729e 100644 --- a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java +++ b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java @@ -140,6 +140,10 @@ public enum MainHand /** * Send a plugin message to this player. * + * In recent Minecraft versions channel names must contain a colon separator + * and consist of [a-z0-9/._-]. This will be enforced in a future version. + * The "BungeeCord" channel is an exception and may only take this form. + * * @param channel the channel to send this data via * @param data the data to send */ diff --git a/api/src/main/java/net/md_5/bungee/api/connection/Server.java b/api/src/main/java/net/md_5/bungee/api/connection/Server.java index 06eb6d1af1..b4653403b2 100644 --- a/api/src/main/java/net/md_5/bungee/api/connection/Server.java +++ b/api/src/main/java/net/md_5/bungee/api/connection/Server.java @@ -18,6 +18,10 @@ public interface Server extends Connection /** * Send data by any available means to this server. * + * In recent Minecraft versions channel names must contain a colon separator + * and consist of [a-z0-9/._-]. This will be enforced in a future version. + * The "BungeeCord" channel is an exception and may only take this form. + * * @param channel the channel to send this data via * @param data the data to send */ diff --git a/api/src/main/java/net/md_5/bungee/api/score/Team.java b/api/src/main/java/net/md_5/bungee/api/score/Team.java index 4166037120..849ba1cf93 100644 --- a/api/src/main/java/net/md_5/bungee/api/score/Team.java +++ b/api/src/main/java/net/md_5/bungee/api/score/Team.java @@ -19,7 +19,7 @@ public class Team private byte friendlyFire; private String nameTagVisibility; private String collisionRule; - private byte color; + private int color; private Set players = new HashSet<>(); public Collection getPlayers() diff --git a/bootstrap/pom.xml b/bootstrap/pom.xml index 9b5c98f7d5..615ac3f5c2 100644 --- a/bootstrap/pom.xml +++ b/bootstrap/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-bootstrap - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar BungeeCord-Bootstrap diff --git a/chat/pom.xml b/chat/pom.xml index 970e309738..92f04c6205 100644 --- a/chat/pom.xml +++ b/chat/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-chat - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar BungeeCord-Chat diff --git a/config/pom.xml b/config/pom.xml index 255270c629..7241c6bac2 100644 --- a/config/pom.xml +++ b/config/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-config - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar BungeeCord-Config diff --git a/event/pom.xml b/event/pom.xml index 6132e8e9f0..93c4aa3971 100644 --- a/event/pom.xml +++ b/event/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-event - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar BungeeCord-Event diff --git a/log/pom.xml b/log/pom.xml index 2fcbbad651..87b839adb4 100644 --- a/log/pom.xml +++ b/log/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-log - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar BungeeCord-Log diff --git a/module/cmd-alert/pom.xml b/module/cmd-alert/pom.xml index 220f042112..44d5b21ebe 100644 --- a/module/cmd-alert/pom.xml +++ b/module/cmd-alert/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-alert - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar cmd_alert diff --git a/module/cmd-find/pom.xml b/module/cmd-find/pom.xml index 928f63a816..e320447a21 100644 --- a/module/cmd-find/pom.xml +++ b/module/cmd-find/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-find - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar cmd_find diff --git a/module/cmd-list/pom.xml b/module/cmd-list/pom.xml index 689b83ee59..230af0cc40 100644 --- a/module/cmd-list/pom.xml +++ b/module/cmd-list/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-list - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar cmd_list diff --git a/module/cmd-send/pom.xml b/module/cmd-send/pom.xml index e50a4becf3..23f9a02b8e 100644 --- a/module/cmd-send/pom.xml +++ b/module/cmd-send/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-send - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar cmd_send diff --git a/module/cmd-server/pom.xml b/module/cmd-server/pom.xml index daf146dca4..0731bd8e23 100644 --- a/module/cmd-server/pom.xml +++ b/module/cmd-server/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-server - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar cmd_server diff --git a/module/pom.xml b/module/pom.xml index aff2c070de..107cb0efbd 100644 --- a/module/pom.xml +++ b/module/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-module - 1.12-SNAPSHOT + 1.13-SNAPSHOT pom BungeeCord Modules diff --git a/module/reconnect-yaml/pom.xml b/module/reconnect-yaml/pom.xml index 8e82446f7c..809cf79ccb 100644 --- a/module/reconnect-yaml/pom.xml +++ b/module/reconnect-yaml/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-reconnect-yaml - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar reconnect_yaml diff --git a/native/pom.xml b/native/pom.xml index 082f090859..15c0ada28f 100644 --- a/native/pom.xml +++ b/native/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-native - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar BungeeCord-Native diff --git a/pom.xml b/pom.xml index e7cec244eb..9cad53d8ce 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ net.md-5 bungeecord-parent - 1.12-SNAPSHOT + 1.13-SNAPSHOT pom BungeeCord-Parent diff --git a/protocol/pom.xml b/protocol/pom.xml index bf4b399a58..ab9868bdf9 100644 --- a/protocol/pom.xml +++ b/protocol/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-protocol - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar BungeeCord-Protocol diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java b/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java index 6f782c8fe3..93f324e29f 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/AbstractPacketHandler.java @@ -22,6 +22,8 @@ import net.md_5.bungee.protocol.packet.EncryptionResponse; import net.md_5.bungee.protocol.packet.LegacyHandshake; import net.md_5.bungee.protocol.packet.LegacyPing; +import net.md_5.bungee.protocol.packet.LoginPayloadRequest; +import net.md_5.bungee.protocol.packet.LoginPayloadResponse; import net.md_5.bungee.protocol.packet.LoginRequest; import net.md_5.bungee.protocol.packet.LoginSuccess; import net.md_5.bungee.protocol.packet.PingPacket; @@ -148,4 +150,12 @@ public void handle(SetCompression setCompression) throws Exception public void handle(BossBar bossBar) throws Exception { } + + public void handle(LoginPayloadRequest request) throws Exception + { + } + + public void handle(LoginPayloadResponse response) throws Exception + { + } } 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 cd065631cb..76c2bea011 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 @@ -20,6 +20,8 @@ import net.md_5.bungee.protocol.packet.KeepAlive; import net.md_5.bungee.protocol.packet.Kick; import net.md_5.bungee.protocol.packet.Login; +import net.md_5.bungee.protocol.packet.LoginPayloadRequest; +import net.md_5.bungee.protocol.packet.LoginPayloadResponse; import net.md_5.bungee.protocol.packet.LoginRequest; import net.md_5.bungee.protocol.packet.LoginSuccess; import net.md_5.bungee.protocol.packet.PingPacket; @@ -61,90 +63,104 @@ public enum Protocol KeepAlive.class, map( ProtocolConstants.MINECRAFT_1_8, 0x00 ), map( ProtocolConstants.MINECRAFT_1_9, 0x1F ), - map( ProtocolConstants.MINECRAFT_1_12, 0x1F ) + map( ProtocolConstants.MINECRAFT_1_12, 0x1F ), + map( ProtocolConstants.MINECRAFT_1_13, 0x21 ) ); TO_CLIENT.registerPacket( Login.class, map( ProtocolConstants.MINECRAFT_1_8, 0x01 ), map( ProtocolConstants.MINECRAFT_1_9, 0x23 ), - map( ProtocolConstants.MINECRAFT_1_12, 0x23 ) + map( ProtocolConstants.MINECRAFT_1_12, 0x23 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x25 ) ); TO_CLIENT.registerPacket( Chat.class, map( ProtocolConstants.MINECRAFT_1_8, 0x02 ), map( ProtocolConstants.MINECRAFT_1_9, 0x0F ), - map( ProtocolConstants.MINECRAFT_1_12, 0x0F ) + map( ProtocolConstants.MINECRAFT_1_12, 0x0F ), + map( ProtocolConstants.MINECRAFT_1_13, 0x0E ) ); TO_CLIENT.registerPacket( Respawn.class, map( ProtocolConstants.MINECRAFT_1_8, 0x07 ), map( ProtocolConstants.MINECRAFT_1_9, 0x33 ), map( ProtocolConstants.MINECRAFT_1_12, 0x34 ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x35 ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x35 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x38 ) ); TO_CLIENT.registerPacket( BossBar.class, map( ProtocolConstants.MINECRAFT_1_9, 0x0C ), - map( ProtocolConstants.MINECRAFT_1_12, 0x0C ) + map( ProtocolConstants.MINECRAFT_1_12, 0x0C ), + map( ProtocolConstants.MINECRAFT_1_13, 0x0C ) ); TO_CLIENT.registerPacket( PlayerListItem.class, // PlayerInfo map( ProtocolConstants.MINECRAFT_1_8, 0x38 ), map( ProtocolConstants.MINECRAFT_1_9, 0x2D ), map( ProtocolConstants.MINECRAFT_1_12, 0x2D ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x2E ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x2E ), + map( ProtocolConstants.MINECRAFT_1_13, 0x30 ) ); TO_CLIENT.registerPacket( TabCompleteResponse.class, map( ProtocolConstants.MINECRAFT_1_8, 0x3A ), map( ProtocolConstants.MINECRAFT_1_9, 0x0E ), - map( ProtocolConstants.MINECRAFT_1_12, 0x0E ) + map( ProtocolConstants.MINECRAFT_1_12, 0x0E ), + map( ProtocolConstants.MINECRAFT_1_13, 0x10 ) ); TO_CLIENT.registerPacket( ScoreboardObjective.class, map( ProtocolConstants.MINECRAFT_1_8, 0x3B ), map( ProtocolConstants.MINECRAFT_1_9, 0x3F ), map( ProtocolConstants.MINECRAFT_1_12, 0x41 ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x42 ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x42 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x45 ) ); TO_CLIENT.registerPacket( ScoreboardScore.class, map( ProtocolConstants.MINECRAFT_1_8, 0x3C ), map( ProtocolConstants.MINECRAFT_1_9, 0x42 ), map( ProtocolConstants.MINECRAFT_1_12, 0x44 ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x45 ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x45 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x48 ) ); TO_CLIENT.registerPacket( ScoreboardDisplay.class, map( ProtocolConstants.MINECRAFT_1_8, 0x3D ), map( ProtocolConstants.MINECRAFT_1_9, 0x38 ), map( ProtocolConstants.MINECRAFT_1_12, 0x3A ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x3B ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x3B ), + map( ProtocolConstants.MINECRAFT_1_13, 0x3E ) ); TO_CLIENT.registerPacket( Team.class, map( ProtocolConstants.MINECRAFT_1_8, 0x3E ), map( ProtocolConstants.MINECRAFT_1_9, 0x41 ), map( ProtocolConstants.MINECRAFT_1_12, 0x43 ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x44 ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x44 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x47 ) ); TO_CLIENT.registerPacket( PluginMessage.class, map( ProtocolConstants.MINECRAFT_1_8, 0x3F ), map( ProtocolConstants.MINECRAFT_1_9, 0x18 ), - map( ProtocolConstants.MINECRAFT_1_12, 0x18 ) + map( ProtocolConstants.MINECRAFT_1_12, 0x18 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x19 ) ); TO_CLIENT.registerPacket( Kick.class, map( ProtocolConstants.MINECRAFT_1_8, 0x40 ), map( ProtocolConstants.MINECRAFT_1_9, 0x1A ), - map( ProtocolConstants.MINECRAFT_1_12, 0x1A ) + map( ProtocolConstants.MINECRAFT_1_12, 0x1A ), + map( ProtocolConstants.MINECRAFT_1_13, 0x1B ) ); TO_CLIENT.registerPacket( Title.class, map( ProtocolConstants.MINECRAFT_1_8, 0x45 ), map( ProtocolConstants.MINECRAFT_1_12, 0x47 ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x48 ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x48 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x4B ) ); TO_CLIENT.registerPacket( PlayerListHeaderFooter.class, @@ -152,7 +168,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_9, 0x48 ), map( ProtocolConstants.MINECRAFT_1_9_4, 0x47 ), map( ProtocolConstants.MINECRAFT_1_12, 0x49 ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x4A ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x4A ), + map( ProtocolConstants.MINECRAFT_1_13, 0x4E ) ); TO_SERVER.registerPacket( @@ -160,35 +177,40 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_8, 0x00 ), map( ProtocolConstants.MINECRAFT_1_9, 0x0B ), map( ProtocolConstants.MINECRAFT_1_12, 0x0C ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x0B ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x0B ), + map( ProtocolConstants.MINECRAFT_1_13, 0x0E ) ); TO_SERVER.registerPacket( Chat.class, map( ProtocolConstants.MINECRAFT_1_8, 0x01 ), map( ProtocolConstants.MINECRAFT_1_9, 0x02 ), map( ProtocolConstants.MINECRAFT_1_12, 0x03 ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x02 ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x02 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x02 ) ); TO_SERVER.registerPacket( TabCompleteRequest.class, map( ProtocolConstants.MINECRAFT_1_8, 0x14 ), map( ProtocolConstants.MINECRAFT_1_9, 0x01 ), map( ProtocolConstants.MINECRAFT_1_12, 0x02 ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x01 ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x01 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x05 ) ); TO_SERVER.registerPacket( ClientSettings.class, map( ProtocolConstants.MINECRAFT_1_8, 0x15 ), map( ProtocolConstants.MINECRAFT_1_9, 0x04 ), map( ProtocolConstants.MINECRAFT_1_12, 0x05 ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x04 ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x04 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x04 ) ); TO_SERVER.registerPacket( PluginMessage.class, map( ProtocolConstants.MINECRAFT_1_8, 0x17 ), map( ProtocolConstants.MINECRAFT_1_9, 0x09 ), map( ProtocolConstants.MINECRAFT_1_12, 0x0A ), - map( ProtocolConstants.MINECRAFT_1_12_1, 0x09 ) + map( ProtocolConstants.MINECRAFT_1_12_1, 0x09 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x0A ) ); } }, @@ -221,30 +243,44 @@ public enum Protocol { { + TO_CLIENT.registerPacket( + LoginPayloadRequest.class, + map( ProtocolConstants.MINECRAFT_1_13, 0x00 ) + ); TO_CLIENT.registerPacket( Kick.class, - map( ProtocolConstants.MINECRAFT_1_8, 0x00 ) + map( ProtocolConstants.MINECRAFT_1_8, 0x00 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x01 ) ); TO_CLIENT.registerPacket( EncryptionRequest.class, - map( ProtocolConstants.MINECRAFT_1_8, 0x01 ) + map( ProtocolConstants.MINECRAFT_1_8, 0x01 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x02 ) ); TO_CLIENT.registerPacket( LoginSuccess.class, - map( ProtocolConstants.MINECRAFT_1_8, 0x02 ) + map( ProtocolConstants.MINECRAFT_1_8, 0x02 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x03 ) ); TO_CLIENT.registerPacket( SetCompression.class, - map( ProtocolConstants.MINECRAFT_1_8, 0x03 ) + map( ProtocolConstants.MINECRAFT_1_8, 0x03 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x04 ) ); + TO_SERVER.registerPacket( + LoginPayloadResponse.class, + map( ProtocolConstants.MINECRAFT_1_13, 0x00 ) + ); TO_SERVER.registerPacket( LoginRequest.class, - map( ProtocolConstants.MINECRAFT_1_8, 0x00 ) + map( ProtocolConstants.MINECRAFT_1_8, 0x00 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x01 ) ); TO_SERVER.registerPacket( EncryptionResponse.class, - map( ProtocolConstants.MINECRAFT_1_8, 0x01 ) + map( ProtocolConstants.MINECRAFT_1_8, 0x01 ), + map( ProtocolConstants.MINECRAFT_1_13, 0x02 ) ); } }; @@ -327,7 +363,8 @@ public static class DirectionData { linkedProtocols.put( ProtocolConstants.MINECRAFT_1_8, Arrays.asList( ProtocolConstants.MINECRAFT_1_9, - ProtocolConstants.MINECRAFT_1_12 + ProtocolConstants.MINECRAFT_1_12, + ProtocolConstants.MINECRAFT_1_13 ) ); linkedProtocols.put( ProtocolConstants.MINECRAFT_1_9, Arrays.asList( ProtocolConstants.MINECRAFT_1_9_1, diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java index ac9adf3323..bba6cb2df1 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java @@ -17,12 +17,14 @@ public class ProtocolConstants public static final int MINECRAFT_1_12 = 335; public static final int MINECRAFT_1_12_1 = 338; public static final int MINECRAFT_1_12_2 = 340; + public static final int MINECRAFT_1_13 = 389; public static final List SUPPORTED_VERSIONS = Arrays.asList( "1.8.x", "1.9.x", "1.10.x", "1.11.x", - "1.12.x" + "1.12.x", + "1.13.x" ); public static final List SUPPORTED_VERSION_IDS = Arrays.asList( ProtocolConstants.MINECRAFT_1_8, ProtocolConstants.MINECRAFT_1_9, @@ -34,7 +36,8 @@ public class ProtocolConstants ProtocolConstants.MINECRAFT_1_11_1, ProtocolConstants.MINECRAFT_1_12, ProtocolConstants.MINECRAFT_1_12_1, - ProtocolConstants.MINECRAFT_1_12_2 + ProtocolConstants.MINECRAFT_1_12_2, + ProtocolConstants.MINECRAFT_1_13 ); public enum Direction diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadRequest.java new file mode 100644 index 0000000000..a73f1bff08 --- /dev/null +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadRequest.java @@ -0,0 +1,51 @@ +package net.md_5.bungee.protocol.packet; + +import net.md_5.bungee.protocol.DefinedPacket; +import io.netty.buffer.ByteBuf; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import net.md_5.bungee.protocol.AbstractPacketHandler; +import net.md_5.bungee.protocol.OverflowPacketException; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class LoginPayloadRequest extends DefinedPacket +{ + + private int id; + private String channel; + private byte[] data; + + @Override + public void read(ByteBuf buf) + { + id = readVarInt( buf ); + channel = readString( buf ); + + int len = buf.readableBytes(); + if ( len > 1048576 ) + { + throw new OverflowPacketException( "Payload may not be larger than 1048576 bytes" ); + } + data = new byte[ len ]; + buf.readBytes( data ); + } + + @Override + public void write(ByteBuf buf) + { + writeVarInt( id, buf ); + writeString( channel, buf ); + buf.writeBytes( data ); + } + + @Override + public void handle(AbstractPacketHandler handler) throws Exception + { + handler.handle( this ); + } +} diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadResponse.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadResponse.java new file mode 100644 index 0000000000..962ea3b64a --- /dev/null +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginPayloadResponse.java @@ -0,0 +1,58 @@ +package net.md_5.bungee.protocol.packet; + +import net.md_5.bungee.protocol.DefinedPacket; +import io.netty.buffer.ByteBuf; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import net.md_5.bungee.protocol.AbstractPacketHandler; +import net.md_5.bungee.protocol.OverflowPacketException; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +public class LoginPayloadResponse extends DefinedPacket +{ + + private int id; + private byte[] data; + + @Override + public void read(ByteBuf buf) + { + id = readVarInt( buf ); + + if ( buf.readBoolean() ) + { + int len = buf.readableBytes(); + if ( len > 1048576 ) + { + throw new OverflowPacketException( "Payload may not be larger than 1048576 bytes" ); + } + data = new byte[ len ]; + buf.readBytes( data ); + } + } + + @Override + public void write(ByteBuf buf) + { + writeVarInt( id, buf ); + if ( data != null ) + { + buf.writeBoolean( true ); + buf.writeBytes( data ); + } else + { + buf.writeBoolean( false ); + } + } + + @Override + public void handle(AbstractPacketHandler handler) throws Exception + { + handler.handle( this ); + } +} diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java index d578402bd1..8d4eacbc54 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java @@ -1,5 +1,6 @@ package net.md_5.bungee.protocol.packet; +import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import net.md_5.bungee.protocol.DefinedPacket; @@ -7,6 +8,7 @@ import java.io.ByteArrayInputStream; import java.io.DataInput; import java.io.DataInputStream; +import java.util.Locale; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -21,12 +23,37 @@ public class PluginMessage extends DefinedPacket { + public static final Function MODERNISE = new Function() + { + @Override + public String apply(String tag) + { + // Transform as per Bukkit + if ( tag.equals( "BungeeCord" ) ) + { + return "bungeecord:main"; + } + if ( tag.equals( "bungeecord:main" ) ) + { + return "BungeeCord"; + } + + // Code that gets to here is UNLIKELY to be viable on the Bukkit side of side things, + // but we keep it anyway. It will eventually be enforced API side. + if ( tag.indexOf( ':' ) != -1 ) + { + return tag; + } + + return "bungeecord:legacy/" + tag.toLowerCase( Locale.ROOT ); + } + }; public static final Predicate SHOULD_RELAY = new Predicate() { @Override public boolean apply(PluginMessage input) { - return ( input.getTag().equals( "REGISTER" ) || input.getTag().equals( "MC|Brand" ) ) && input.getData().length < Byte.MAX_VALUE; + return ( input.getTag().equals( "REGISTER" ) || input.getTag().equals( "minecraft:register" ) || input.getTag().equals( "MC|Brand" ) || input.getTag().equals( "minecraft:brand" ) ) && input.getData().length < Byte.MAX_VALUE; } }; // @@ -41,7 +68,7 @@ public boolean apply(PluginMessage input) @Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - tag = readString( buf ); + tag = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( readString( buf ) ) : readString( buf ); int maxSize = direction == ProtocolConstants.Direction.TO_SERVER ? Short.MAX_VALUE : 0x100000; Preconditions.checkArgument( buf.readableBytes() < maxSize ); data = new byte[ buf.readableBytes() ]; @@ -51,7 +78,7 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco @Override public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - writeString( tag, buf ); + writeString( ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( tag ) : tag, buf ); buf.writeBytes( data ); } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java index ef9b8cf68a..6279d9f35e 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java @@ -2,6 +2,7 @@ import net.md_5.bungee.protocol.DefinedPacket; import io.netty.buffer.ByteBuf; +import java.util.Locale; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; @@ -18,7 +19,7 @@ public class ScoreboardObjective extends DefinedPacket private String name; private String value; - private String type; + private HealthDisplay type; /** * 0 to create, 1 to remove, 2 to update display text. */ @@ -32,7 +33,13 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco if ( action == 0 || action == 2 ) { value = readString( buf ); - type = readString( buf ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { + type = HealthDisplay.values()[readVarInt( buf )]; + } else + { + type = HealthDisplay.fromString( readString( buf ) ); + } } } @@ -44,7 +51,13 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc if ( action == 0 || action == 2 ) { writeString( value, buf ); - writeString( type, buf ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { + writeVarInt( type.ordinal(), buf ); + } else + { + writeString( type.toString(), buf ); + } } } @@ -53,4 +66,21 @@ public void handle(AbstractPacketHandler handler) throws Exception { handler.handle( this ); } + + public enum HealthDisplay + { + + INTEGER, HEARTS; + + @Override + public String toString() + { + return super.toString().toLowerCase( Locale.ROOT ); + } + + public static HealthDisplay fromString(String s) + { + return valueOf( s.toUpperCase( Locale.ROOT ) ); + } + } } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java index e3bcbc330b..f9eaa7ce80 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java @@ -2,7 +2,6 @@ import net.md_5.bungee.protocol.DefinedPacket; import io.netty.buffer.ByteBuf; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; @@ -11,44 +10,74 @@ @Data @NoArgsConstructor -@AllArgsConstructor @EqualsAndHashCode(callSuper = false) public class TabCompleteRequest extends DefinedPacket { + private int transactionId; private String cursor; private boolean assumeCommand; private boolean hasPositon; private long position; + public TabCompleteRequest(int transactionId, String cursor) + { + this.transactionId = transactionId; + this.cursor = cursor; + } + + public TabCompleteRequest(String cursor, boolean assumeCommand, boolean hasPosition, long position) + { + this.cursor = cursor; + this.assumeCommand = assumeCommand; + this.hasPositon = hasPosition; + this.position = position; + } + @Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - cursor = readString( buf ); - if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) { - assumeCommand = buf.readBoolean(); + transactionId = readVarInt( buf ); } + cursor = readString( buf ); - if ( hasPositon = buf.readBoolean() ) + if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 ) { - position = buf.readLong(); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) + { + assumeCommand = buf.readBoolean(); + } + + if ( hasPositon = buf.readBoolean() ) + { + position = buf.readLong(); + } } } @Override public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - writeString( cursor, buf ); - if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) { - buf.writeBoolean( assumeCommand ); + writeVarInt( transactionId, buf ); } + writeString( cursor, buf ); - buf.writeBoolean( hasPositon ); - if ( hasPositon ) + if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 ) { - buf.writeLong( position ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) + { + buf.writeBoolean( assumeCommand ); + } + + buf.writeBoolean( hasPositon ); + if ( hasPositon ) + { + buf.writeLong( position ); + } } } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteResponse.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteResponse.java index ebce9a6ae5..e99ceb54b1 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteResponse.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteResponse.java @@ -2,32 +2,88 @@ import net.md_5.bungee.protocol.DefinedPacket; import io.netty.buffer.ByteBuf; +import java.util.LinkedList; import java.util.List; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import net.md_5.bungee.protocol.AbstractPacketHandler; +import net.md_5.bungee.protocol.ProtocolConstants; @Data @NoArgsConstructor -@AllArgsConstructor @EqualsAndHashCode(callSuper = false) public class TabCompleteResponse extends DefinedPacket { + private int transactionId; + private int start; + private int length; + private List matches; private List commands; + public TabCompleteResponse(int transactionId, int start, int length, List matches) + { + this.transactionId = transactionId; + this.start = start; + this.length = length; + this.matches = matches; + } + + public TabCompleteResponse(List commands) + { + this.commands = commands; + } + @Override - public void read(ByteBuf buf) + public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - commands = readStringArray( buf ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { + transactionId = readVarInt( buf ); + start = readVarInt( buf ); + length = readVarInt( buf ); + + int cnt = readVarInt( buf ); + matches = new LinkedList<>(); + for ( int i = 0; i < cnt; i++ ) + { + String match = readString( buf ); + String tooltip = buf.readBoolean() ? readString( buf ) : null; + + matches.add( new CommandMatch( match, tooltip ) ); + } + } + + if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 ) + { + commands = readStringArray( buf ); + } } @Override - public void write(ByteBuf buf) + public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - writeStringArray( commands, buf ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { + writeVarInt( transactionId, buf ); + writeVarInt( start, buf ); + writeVarInt( length, buf ); + + writeVarInt( matches.size(), buf ); + for ( CommandMatch match : matches ) + { + writeString( match.match, buf ); + buf.writeBoolean( match.tooltip != null ); + writeString( match.tooltip, buf ); + } + } + + if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 ) + { + writeStringArray( commands, buf ); + } } @Override @@ -35,4 +91,14 @@ public void handle(AbstractPacketHandler handler) throws Exception { handler.handle( this ); } + + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class CommandMatch + { + + private String match; + private String tooltip; + } } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java index b470579952..f93508d908 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java @@ -26,7 +26,7 @@ public class Team extends DefinedPacket private String suffix; private String nameTagVisibility; private String collisionRule; - private byte color; + private int color; private byte friendlyFire; private String[] players; @@ -47,15 +47,23 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco if ( mode == 0 || mode == 2 ) { displayName = readString( buf ); - prefix = readString( buf ); - suffix = readString( buf ); + if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 ) + { + prefix = readString( buf ); + suffix = readString( buf ); + } friendlyFire = buf.readByte(); nameTagVisibility = readString( buf ); if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) { collisionRule = readString( buf ); } - color = buf.readByte(); + color = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? readVarInt( buf ) : buf.readByte(); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { + prefix = readString( buf ); + suffix = readString( buf ); + } } if ( mode == 0 || mode == 3 || mode == 4 ) { @@ -76,15 +84,27 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc if ( mode == 0 || mode == 2 ) { writeString( displayName, buf ); - writeString( prefix, buf ); - writeString( suffix, buf ); + if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 ) + { + writeString( prefix, buf ); + writeString( suffix, buf ); + } buf.writeByte( friendlyFire ); writeString( nameTagVisibility, buf ); if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ) { writeString( collisionRule, buf ); } - buf.writeByte( color ); + + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { + writeVarInt( color, buf ); + writeString( prefix, buf ); + writeString( suffix, buf ); + } else + { + buf.writeByte( color ); + } } if ( mode == 0 || mode == 3 || mode == 4 ) { diff --git a/protocol/src/test/java/net/md_5/bungee/protocol/packet/PluginMessageTest.java b/protocol/src/test/java/net/md_5/bungee/protocol/packet/PluginMessageTest.java new file mode 100644 index 0000000000..754421693b --- /dev/null +++ b/protocol/src/test/java/net/md_5/bungee/protocol/packet/PluginMessageTest.java @@ -0,0 +1,17 @@ +package net.md_5.bungee.protocol.packet; + +import org.junit.Assert; +import org.junit.Test; + +public class PluginMessageTest +{ + + @Test + public void testModerniseChannel() + { + Assert.assertEquals( "bungeecord:main", PluginMessage.MODERNISE.apply( "BungeeCord" ) ); + Assert.assertEquals( "BungeeCord", PluginMessage.MODERNISE.apply( "bungeecord:main" ) ); + Assert.assertEquals( "bungeecord:legacy/foo", PluginMessage.MODERNISE.apply( "FoO" ) ); + Assert.assertEquals( "foo:bar", PluginMessage.MODERNISE.apply( "foo:bar" ) ); + } +} diff --git a/proxy/pom.xml b/proxy/pom.xml index dcd6e5c4e6..6968ecb2b4 100644 --- a/proxy/pom.xml +++ b/proxy/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-proxy - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar BungeeCord-Proxy diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 2555348f0c..8d6fc41e5d 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -246,7 +246,6 @@ public BungeeCord() throws IOException * * @throws Exception */ - @Override @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE") public void start() throws Exception { @@ -616,8 +615,13 @@ public Collection getChannels() return Collections.unmodifiableCollection( pluginChannels ); } - public PluginMessage registerChannels() + public PluginMessage registerChannels(int protocolVersion) { + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { + return new PluginMessage( "minecraft:register", Util.format( Iterables.transform( pluginChannels, PluginMessage.MODERNISE ), "\00" ).getBytes( Charsets.UTF_8 ), false ); + } + return new PluginMessage( "REGISTER", Util.format( pluginChannels, "\00" ).getBytes( Charsets.UTF_8 ), false ); } diff --git a/proxy/src/main/java/net/md_5/bungee/PacketConstants.java b/proxy/src/main/java/net/md_5/bungee/PacketConstants.java index 2747561b7f..ea6aa6a8a1 100644 --- a/proxy/src/main/java/net/md_5/bungee/PacketConstants.java +++ b/proxy/src/main/java/net/md_5/bungee/PacketConstants.java @@ -14,5 +14,4 @@ public class PacketConstants { 0, 0, 0, 0, 0, 2 }, false ); - public static final PluginMessage I_AM_BUNGEE = new PluginMessage( "BungeeCord", new byte[ 0 ], false ); } diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index b34247ce40..d81cda980e 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -6,6 +6,7 @@ import java.util.Queue; import java.util.Set; import java.util.UUID; +import java.util.logging.Level; import lombok.Getter; import lombok.RequiredArgsConstructor; import net.md_5.bungee.api.ChatColor; @@ -30,7 +31,9 @@ import net.md_5.bungee.netty.HandlerBoss; import net.md_5.bungee.netty.PacketHandler; import net.md_5.bungee.protocol.DefinedPacket; +import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.Protocol; +import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.packet.EncryptionRequest; import net.md_5.bungee.protocol.packet.Handshake; import net.md_5.bungee.protocol.packet.Kick; @@ -42,6 +45,7 @@ import net.md_5.bungee.protocol.packet.ScoreboardObjective; import net.md_5.bungee.protocol.packet.ScoreboardScore; import net.md_5.bungee.protocol.packet.SetCompression; +import net.md_5.bungee.util.BufUtil; @RequiredArgsConstructor public class ServerConnector extends PacketHandler @@ -118,6 +122,15 @@ public void disconnected(ChannelWrapper channel) throws Exception user.getPendingConnects().remove( target ); } + @Override + public void handle(PacketWrapper packet) throws Exception + { + if ( packet.packet == null ) + { + throw new IllegalArgumentException( "Unexpected packet received during server login process!\n" + BufUtil.dump( packet.buf, 64 ) ); + } + } + @Override public void handle(LoginSuccess loginSuccess) throws Exception { @@ -162,7 +175,7 @@ public void handle(Login login) throws Exception ServerConnectedEvent event = new ServerConnectedEvent( user, server ); bungee.getPluginManager().callEvent( event ); - ch.write( BungeeCord.getInstance().registerChannels() ); + ch.write( BungeeCord.getInstance().registerChannels( user.getPendingConnection().getVersion() ) ); Queue packetQueue = target.getPacketQueue(); synchronized ( packetQueue ) { @@ -201,7 +214,7 @@ public void handle(Login login) throws Exception ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer(); DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand ); - user.unsafe().sendPacket( new PluginMessage( "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler.isServerForge() ) ); + user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler.isServerForge() ) ); brand.release(); user.setDimension( login.getDimension() ); @@ -213,7 +226,7 @@ public void handle(Login login) throws Exception Scoreboard serverScoreboard = user.getServerSentScoreboard(); for ( Objective objective : serverScoreboard.getObjectives() ) { - user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), objective.getType(), (byte) 1 ) ); + user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), ScoreboardObjective.HealthDisplay.fromString( objective.getType() ), (byte) 1 ) ); } for ( Score score : serverScoreboard.getScores() ) { 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 931f3f30d5..842425bb35 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 @@ -30,6 +30,7 @@ import net.md_5.bungee.netty.PacketHandler; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.PacketWrapper; +import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.packet.BossBar; import net.md_5.bungee.protocol.packet.KeepAlive; import net.md_5.bungee.protocol.packet.PlayerListItem; @@ -125,7 +126,7 @@ public void handle(ScoreboardObjective objective) throws Exception switch ( objective.getAction() ) { case 0: - serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue(), objective.getType() ) ); + serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue(), objective.getType().toString() ) ); break; case 1: serverScoreboard.removeObjective( objective.getName() ); @@ -135,7 +136,7 @@ public void handle(ScoreboardObjective objective) throws Exception if ( oldObjective != null ) { oldObjective.setValue( objective.getValue() ); - oldObjective.setType( objective.getType() ); + oldObjective.setType( objective.getType().toString() ); } break; default: @@ -231,7 +232,7 @@ public void handle(PluginMessage pluginMessage) throws Exception throw CancelSendSignal.INSTANCE; } - if ( pluginMessage.getTag().equals( "MC|Brand" ) ) + if ( pluginMessage.getTag().equals( con.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand" ) ) { ByteBuf brand = Unpooled.wrappedBuffer( pluginMessage.getData() ); String serverBrand = DefinedPacket.readString( brand ); @@ -476,6 +477,12 @@ public void handle(SetCompression setCompression) throws Exception @Override public void handle(TabCompleteResponse tabCompleteResponse) throws Exception { + if ( tabCompleteResponse.getCommands() == null ) + { + // Passthrough on 1.13 style command responses - unclear of a sane way to process them at the moment, contributions welcome + return; + } + TabCompleteResponseEvent tabCompleteResponseEvent = new TabCompleteResponseEvent( server, con, tabCompleteResponse.getCommands() ); if ( !bungee.getPluginManager().callEvent( tabCompleteResponseEvent ).isCancelled() ) diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 1c65e00206..e5d361e3c3 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -57,6 +57,7 @@ import net.md_5.bungee.protocol.packet.Kick; import net.md_5.bungee.protocol.packet.LegacyHandshake; import net.md_5.bungee.protocol.packet.LegacyPing; +import net.md_5.bungee.protocol.packet.LoginPayloadResponse; import net.md_5.bungee.protocol.packet.LoginRequest; import net.md_5.bungee.protocol.packet.LoginSuccess; import net.md_5.bungee.protocol.packet.PingPacket; @@ -64,6 +65,7 @@ import net.md_5.bungee.protocol.packet.StatusRequest; import net.md_5.bungee.protocol.packet.StatusResponse; import net.md_5.bungee.util.BoundedArrayList; +import net.md_5.bungee.util.BufUtil; @RequiredArgsConstructor public class InitialHandler extends PacketHandler implements PendingConnection @@ -129,6 +131,15 @@ public void exception(Throwable t) throws Exception disconnect( ChatColor.RED + Util.exception( t ) ); } + @Override + public void handle(PacketWrapper packet) throws Exception + { + if ( packet.packet == null ) + { + throw new IllegalArgumentException( "Unexpected packet received during login process!\n" + BufUtil.dump( packet.buf, 64 ) ); + } + } + @Override public void handle(PluginMessage pluginMessage) throws Exception { @@ -532,6 +543,12 @@ public void run() bungee.getPluginManager().callEvent( new LoginEvent( InitialHandler.this, complete ) ); } + @Override + public void handle(LoginPayloadResponse response) throws Exception + { + disconnect( "Unexpected custom LoginPayloadResponse" ); + } + @Override public void disconnect(String reason) { diff --git a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java index 3cd5cf6962..76f496ce23 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java @@ -13,10 +13,12 @@ import net.md_5.bungee.netty.PipelineUtils; import net.md_5.bungee.protocol.MinecraftDecoder; import net.md_5.bungee.protocol.MinecraftEncoder; +import net.md_5.bungee.protocol.PacketWrapper; import net.md_5.bungee.protocol.Protocol; import net.md_5.bungee.protocol.packet.Handshake; import net.md_5.bungee.protocol.packet.StatusRequest; import net.md_5.bungee.protocol.packet.StatusResponse; +import net.md_5.bungee.util.BufUtil; @RequiredArgsConstructor public class PingHandler extends PacketHandler @@ -48,6 +50,15 @@ public void exception(Throwable t) throws Exception callback.done( null, t ); } + @Override + public void handle(PacketWrapper packet) throws Exception + { + if ( packet.packet == null ) + { + throw new IllegalArgumentException( "Unexpected packet received during ping process!\n" + BufUtil.dump( packet.buf, 64 ) ); + } + } + @Override @SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") public void handle(StatusResponse statusResponse) throws Exception 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 92d22502f6..99933dc87c 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 @@ -40,7 +40,7 @@ public UpstreamBridge(ProxyServer bungee, UserConnection con) BungeeCord.getInstance().addConnection( con ); con.getTabListHandler().onConnect(); - con.unsafe().sendPacket( BungeeCord.getInstance().registerChannels() ); + con.unsafe().sendPacket( BungeeCord.getInstance().registerChannels( con.getPendingConnection().getVersion() ) ); } @Override @@ -167,7 +167,12 @@ public void handle(TabCompleteRequest tabComplete) throws Exception List results = tabCompleteEvent.getSuggestions(); if ( !results.isEmpty() ) { - con.unsafe().sendPacket( new TabCompleteResponse( results ) ); + // Unclear how to handle 1.13 commands at this point. Because we don't inject into the command packets we are unlikely to get this far unless + // Bungee plugins are adding results for commands they don't own anyway + if ( con.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_13 ) + { + con.unsafe().sendPacket( new TabCompleteResponse( results ) ); + } throw CancelSendSignal.INSTANCE; } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java index 847a3ecac7..cae566f5e0 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java @@ -47,6 +47,8 @@ public static EntityMap getEntityMap(int version) case ProtocolConstants.MINECRAFT_1_12_1: case ProtocolConstants.MINECRAFT_1_12_2: return EntityMap_1_12_1.INSTANCE; + case ProtocolConstants.MINECRAFT_1_13: + return EntityMap_1_13.INSTANCE; } throw new RuntimeException( "Version " + version + " has no entity map" ); } @@ -76,11 +78,21 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId) rewrite( packet, oldId, newId, serverboundInts, serverboundVarInts ); } + public void rewriteServerbound(ByteBuf packet, int oldId, int newId, int protocolVersion) + { + rewriteServerbound( packet, oldId, newId ); + } + public void rewriteClientbound(ByteBuf packet, int oldId, int newId) { rewrite( packet, oldId, newId, clientboundInts, clientboundVarInts ); } + public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion) + { + rewriteClientbound( packet, oldId, newId ); + } + protected static void rewriteInt(ByteBuf packet, int oldId, int newId, int offset) { int readId = packet.getInt( offset ); @@ -111,6 +123,11 @@ protected static void rewriteVarInt(ByteBuf packet, int oldId, int newId, int of } protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, int metaIndex) + { + rewriteMetaVarInt( packet, oldId, newId, metaIndex, -1 ); + } + + protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, int metaIndex, int protocolVersion) { int readerIndex = packet.readerIndex(); @@ -118,6 +135,37 @@ protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, in while ( ( index = packet.readUnsignedByte() ) != 0xFF ) { int type = DefinedPacket.readVarInt( packet ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) + { + switch ( type ) + { + case 5: // optional chat + if ( packet.readBoolean() ) + { + DefinedPacket.readString( packet ); + } + break; + case 14: // particle + int particleId = DefinedPacket.readVarInt( packet ); + switch ( particleId ) + { + case 3: + case 20: + DefinedPacket.readVarInt( packet ); // block state + break; + case 11: // dust + packet.skipBytes( 16 ); // float, float, float, flat + break; + case 27: // item + readSkipSlot( packet ); + break; + } + break; + default: + type--; + break; + } + } switch ( type ) { @@ -141,24 +189,7 @@ protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, in DefinedPacket.readString( packet ); break; case 5: - if ( packet.readShort() != -1 ) - { - packet.skipBytes( 3 ); // byte, short - - int position = packet.readerIndex(); - if ( packet.readByte() != 0 ) - { - packet.readerIndex( position ); - - try - { - new NBTInputStream( new ByteBufInputStream( packet ), false ).readTag(); - } catch ( IOException ex ) - { - throw Throwables.propagate( ex ); - } - } - } + readSkipSlot( packet ); break; case 6: packet.skipBytes( 1 ); // boolean @@ -204,6 +235,28 @@ protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, in packet.readerIndex( readerIndex ); } + private static void readSkipSlot(ByteBuf packet) + { + if ( packet.readShort() != -1 ) + { + packet.skipBytes( 3 ); // byte, short + + int position = packet.readerIndex(); + if ( packet.readByte() != 0 ) + { + packet.readerIndex( position ); + + try + { + new NBTInputStream( new ByteBufInputStream( packet ), false ).readTag(); + } catch ( IOException ex ) + { + throw Throwables.propagate( ex ); + } + } + } + } + // Handles simple packets private static void rewrite(ByteBuf packet, int oldId, int newId, boolean[] ints, boolean[] varints) { diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java new file mode 100644 index 0000000000..3d474dbbc7 --- /dev/null +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_13.java @@ -0,0 +1,183 @@ +package net.md_5.bungee.entitymap; + +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import io.netty.buffer.ByteBuf; +import net.md_5.bungee.BungeeCord; +import net.md_5.bungee.UserConnection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.protocol.DefinedPacket; +import net.md_5.bungee.protocol.ProtocolConstants; + +import java.util.UUID; + +class EntityMap_1_13 extends EntityMap +{ + + static final EntityMap_1_13 INSTANCE = new EntityMap_1_13(); + + EntityMap_1_13() + { + addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity + addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb + addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving + addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting + addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn + addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation + addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation + addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus + addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity + addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove + addRewrite( 0x29, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook + addRewrite( 0x2A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook + addRewrite( 0x33, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed + addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect + addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation + addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera + addRewrite( 0x3F, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata + addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity + addRewrite( 0x41, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity + addRewrite( 0x42, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment + addRewrite( 0x46, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount + addRewrite( 0x4F, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect + addRewrite( 0x50, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport + addRewrite( 0x52, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes + addRewrite( 0x53, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect + + addRewrite( 0x0D, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity + addRewrite( 0x19, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction + } + + @Override + @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") + public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion) + { + super.rewriteClientbound( packet, oldId, newId ); + + // Special cases + int readerIndex = packet.readerIndex(); + int packetId = DefinedPacket.readVarInt( packet ); + int packetIdLength = packet.readerIndex() - readerIndex; + int jumpIndex = packet.readerIndex(); + switch ( packetId ) + { + case 0x40 /* Attach Entity : PacketPlayOutAttachEntity */: + rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); + break; + case 0x4F /* Collect Item : PacketPlayOutCollect */: + DefinedPacket.readVarInt( packet ); + rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); + break; + case 0x46 /* Set Passengers : PacketPlayOutMount */: + DefinedPacket.readVarInt( packet ); + jumpIndex = packet.readerIndex(); + // Fall through on purpose to int array of IDs + case 0x35 /* Destroy Entities : PacketPlayOutEntityDestroy */: + int count = DefinedPacket.readVarInt( packet ); + int[] ids = new int[ count ]; + for ( int i = 0; i < count; i++ ) + { + ids[i] = DefinedPacket.readVarInt( packet ); + } + packet.readerIndex( jumpIndex ); + packet.writerIndex( jumpIndex ); + DefinedPacket.writeVarInt( count, packet ); + for ( int id : ids ) + { + if ( id == oldId ) + { + id = newId; + } else if ( id == newId ) + { + id = oldId; + } + DefinedPacket.writeVarInt( id, packet ); + } + break; + case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: + DefinedPacket.readVarInt( packet ); + DefinedPacket.readUUID( packet ); + int type = packet.readUnsignedByte(); + + if ( type == 60 || type == 90 || type == 91 ) + { + if ( type == 60 || type == 91 ) + { + oldId = oldId + 1; + newId = newId + 1; + } + + packet.skipBytes( 26 ); // double, double, double, byte, byte + int position = packet.readerIndex(); + int readId = packet.readInt(); + if ( readId == oldId ) + { + packet.setInt( position, newId ); + } else if ( readId == newId ) + { + packet.setInt( position, oldId ); + } + } + break; + case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: + DefinedPacket.readVarInt( packet ); // Entity ID + int idLength = packet.readerIndex() - readerIndex - packetIdLength; + UUID uuid = DefinedPacket.readUUID( packet ); + ProxiedPlayer player; + if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) + { + int previous = packet.writerIndex(); + packet.readerIndex( readerIndex ); + packet.writerIndex( readerIndex + packetIdLength + idLength ); + DefinedPacket.writeUUID( player.getUniqueId(), packet ); + packet.writerIndex( previous ); + } + break; + case 0x2F /* Combat Event : PacketPlayOutCombatEvent */: + int event = packet.readUnsignedByte(); + if ( event == 1 /* End Combat*/ ) + { + DefinedPacket.readVarInt( packet ); + rewriteInt( packet, oldId, newId, packet.readerIndex() ); + } else if ( event == 2 /* Entity Dead */ ) + { + int position = packet.readerIndex(); + rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); + packet.readerIndex( position ); + DefinedPacket.readVarInt( packet ); + rewriteInt( packet, oldId, newId, packet.readerIndex() ); + } + break; + case 0x3F /* EntityMetadata : PacketPlayOutEntityMetadata */: + DefinedPacket.readVarInt( packet ); // Entity ID + rewriteMetaVarInt( packet, oldId + 1, newId + 1, 6, protocolVersion ); // fishing hook + rewriteMetaVarInt( packet, oldId, newId, 7, protocolVersion ); // fireworks (et al) + break; + } + packet.readerIndex( readerIndex ); + } + + @Override + public void rewriteServerbound(ByteBuf packet, int oldId, int newId) + { + super.rewriteServerbound( packet, oldId, newId ); + // Special cases + int readerIndex = packet.readerIndex(); + int packetId = DefinedPacket.readVarInt( packet ); + int packetIdLength = packet.readerIndex() - readerIndex; + + if ( packetId == 0x28 /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + { + UUID uuid = DefinedPacket.readUUID( packet ); + ProxiedPlayer player; + if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) + { + int previous = packet.writerIndex(); + packet.readerIndex( readerIndex ); + packet.writerIndex( readerIndex + packetIdLength ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + packet.writerIndex( previous ); + } + } + packet.readerIndex( readerIndex ); + } +} diff --git a/proxy/src/main/java/net/md_5/bungee/util/BufUtil.java b/proxy/src/main/java/net/md_5/bungee/util/BufUtil.java new file mode 100644 index 0000000000..d765be111c --- /dev/null +++ b/proxy/src/main/java/net/md_5/bungee/util/BufUtil.java @@ -0,0 +1,15 @@ +package net.md_5.bungee.util; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufUtil; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +public class BufUtil +{ + + public static String dump(ByteBuf buf, int maxLen) + { + return ByteBufUtil.hexDump( buf, 0, Math.min( buf.writerIndex(), maxLen ) ); + } +} diff --git a/query/pom.xml b/query/pom.xml index 9ecb2612b7..fdd44b20e0 100644 --- a/query/pom.xml +++ b/query/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.12-SNAPSHOT + 1.13-SNAPSHOT ../pom.xml net.md-5 bungeecord-query - 1.12-SNAPSHOT + 1.13-SNAPSHOT jar BungeeCord-Query From ab810744ecccb6b566520c9f952b4aa8fe17d697 Mon Sep 17 00:00:00 2001 From: Lucas Dallabona Date: Fri, 13 Jul 2018 00:33:05 -0300 Subject: [PATCH 12/24] #2458: Fix NPE when using null in tab list methods --- .../java/net/md_5/bungee/util/ChatComponentTransformer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/src/main/java/net/md_5/bungee/util/ChatComponentTransformer.java b/proxy/src/main/java/net/md_5/bungee/util/ChatComponentTransformer.java index 2a711698d0..3457aaa7da 100644 --- a/proxy/src/main/java/net/md_5/bungee/util/ChatComponentTransformer.java +++ b/proxy/src/main/java/net/md_5/bungee/util/ChatComponentTransformer.java @@ -51,7 +51,7 @@ public static ChatComponentTransformer getInstance() */ public BaseComponent[] transform(ProxiedPlayer player, BaseComponent... component) { - if ( component == null || component.length < 1 ) + if ( component == null || component.length < 1 || ( component.length == 1 && component[0] == null ) ) { return new BaseComponent[] { From 77b0a38c2673769372cb7329ce7f4c9eb129b89a Mon Sep 17 00:00:00 2001 From: Simon Chuu Date: Mon, 9 Jul 2018 03:20:11 -0400 Subject: [PATCH 13/24] #2457: Allow objects in `with` to be translated into a string (for integer, float, etc.) --- .../net/md_5/bungee/api/chat/TranslatableComponent.java | 6 +++--- .../net/md_5/bungee/api/chat/TranslatableComponentTest.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chat/src/main/java/net/md_5/bungee/api/chat/TranslatableComponent.java b/chat/src/main/java/net/md_5/bungee/api/chat/TranslatableComponent.java index 53ee9b0daf..16e8d2a462 100644 --- a/chat/src/main/java/net/md_5/bungee/api/chat/TranslatableComponent.java +++ b/chat/src/main/java/net/md_5/bungee/api/chat/TranslatableComponent.java @@ -71,12 +71,12 @@ public TranslatableComponent(String translate, Object... with) List temp = new ArrayList(); for ( Object w : with ) { - if ( w instanceof String ) + if ( w instanceof BaseComponent ) { - temp.add( new TextComponent( (String) w ) ); + temp.add( (BaseComponent) w ); } else { - temp.add( (BaseComponent) w ); + temp.add( new TextComponent( String.valueOf( w ) ) ); } } setWith( temp ); diff --git a/chat/src/test/java/net/md_5/bungee/api/chat/TranslatableComponentTest.java b/chat/src/test/java/net/md_5/bungee/api/chat/TranslatableComponentTest.java index 0837c67299..2391c22f74 100644 --- a/chat/src/test/java/net/md_5/bungee/api/chat/TranslatableComponentTest.java +++ b/chat/src/test/java/net/md_5/bungee/api/chat/TranslatableComponentTest.java @@ -9,7 +9,7 @@ public class TranslatableComponentTest @Test public void testMissingPlaceholdersAdded() { - TranslatableComponent testComponent = new TranslatableComponent( "Test string with %s placeholders: %s", "2", "aoeu" ); + TranslatableComponent testComponent = new TranslatableComponent( "Test string with %s placeholders: %s", 2, "aoeu" ); assertEquals( "Test string with 2 placeholders: aoeu", testComponent.toPlainText() ); assertEquals( "§fTest string with §f2§f placeholders: §faoeu", testComponent.toLegacyText() ); } From 5cdb181cc51587386c13d2bfb5a034f72ccae126 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 15 Jul 2018 21:20:58 +1000 Subject: [PATCH 14/24] #2465: Sync SnakeYAML version with Bukkit --- config/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/pom.xml b/config/pom.xml index 7241c6bac2..4bb5af6949 100644 --- a/config/pom.xml +++ b/config/pom.xml @@ -22,7 +22,7 @@ org.yaml snakeyaml - 1.19 + 1.21 compile From 0a95af5dc1a0c6106edea718b87ddadca05201a3 Mon Sep 17 00:00:00 2001 From: NayXegp Date: Sun, 15 Jul 2018 11:58:10 +0200 Subject: [PATCH 15/24] #2464: Improve information about missing packet IDs --- protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 76c2bea011..28a1fea0c0 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 @@ -461,7 +461,7 @@ final int getId(Class packet, int version) { throw new BadPacketException( "Unsupported protocol version" ); } - Preconditions.checkArgument( protocolData.packetMap.containsKey( packet ), "Cannot get ID for packet " + packet ); + Preconditions.checkArgument( protocolData.packetMap.containsKey( packet ), "Cannot get ID for packet %s in phase %s with direction %s", packet, protocolPhase, direction ); return protocolData.packetMap.get( packet ); } From 671c4d13418b765a720726f342fa9ecdf7edf90b Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 22 Jul 2018 12:00:00 +1000 Subject: [PATCH 16/24] Minecraft 1.13 support --- .../net/md_5/bungee/protocol/Protocol.java | 30 ++++++++----------- .../bungee/protocol/ProtocolConstants.java | 2 +- .../main/java/net/md_5/bungee/Metrics.java | 2 +- 3 files changed, 14 insertions(+), 20 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 28a1fea0c0..9509f8ee79 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 @@ -243,43 +243,37 @@ public enum Protocol { { - TO_CLIENT.registerPacket( - LoginPayloadRequest.class, - map( ProtocolConstants.MINECRAFT_1_13, 0x00 ) - ); TO_CLIENT.registerPacket( Kick.class, - map( ProtocolConstants.MINECRAFT_1_8, 0x00 ), - map( ProtocolConstants.MINECRAFT_1_13, 0x01 ) + map( ProtocolConstants.MINECRAFT_1_8, 0x00 ) ); TO_CLIENT.registerPacket( EncryptionRequest.class, - map( ProtocolConstants.MINECRAFT_1_8, 0x01 ), - map( ProtocolConstants.MINECRAFT_1_13, 0x02 ) + map( ProtocolConstants.MINECRAFT_1_8, 0x01 ) ); TO_CLIENT.registerPacket( LoginSuccess.class, - map( ProtocolConstants.MINECRAFT_1_8, 0x02 ), - map( ProtocolConstants.MINECRAFT_1_13, 0x03 ) + map( ProtocolConstants.MINECRAFT_1_8, 0x02 ) ); TO_CLIENT.registerPacket( SetCompression.class, - map( ProtocolConstants.MINECRAFT_1_8, 0x03 ), + map( ProtocolConstants.MINECRAFT_1_8, 0x03 ) + ); + TO_CLIENT.registerPacket( + LoginPayloadRequest.class, map( ProtocolConstants.MINECRAFT_1_13, 0x04 ) ); - TO_SERVER.registerPacket( - LoginPayloadResponse.class, - map( ProtocolConstants.MINECRAFT_1_13, 0x00 ) - ); TO_SERVER.registerPacket( LoginRequest.class, - map( ProtocolConstants.MINECRAFT_1_8, 0x00 ), - map( ProtocolConstants.MINECRAFT_1_13, 0x01 ) + map( ProtocolConstants.MINECRAFT_1_8, 0x00 ) ); TO_SERVER.registerPacket( EncryptionResponse.class, - map( ProtocolConstants.MINECRAFT_1_8, 0x01 ), + map( ProtocolConstants.MINECRAFT_1_8, 0x01 ) + ); + TO_SERVER.registerPacket( + LoginPayloadResponse.class, map( ProtocolConstants.MINECRAFT_1_13, 0x02 ) ); } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java index bba6cb2df1..b2dc942340 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java @@ -17,7 +17,7 @@ public class ProtocolConstants public static final int MINECRAFT_1_12 = 335; public static final int MINECRAFT_1_12_1 = 338; public static final int MINECRAFT_1_12_2 = 340; - public static final int MINECRAFT_1_13 = 389; + public static final int MINECRAFT_1_13 = 393; public static final List SUPPORTED_VERSIONS = Arrays.asList( "1.8.x", "1.9.x", diff --git a/proxy/src/main/java/net/md_5/bungee/Metrics.java b/proxy/src/main/java/net/md_5/bungee/Metrics.java index 95239878de..a7ce8d8247 100644 --- a/proxy/src/main/java/net/md_5/bungee/Metrics.java +++ b/proxy/src/main/java/net/md_5/bungee/Metrics.java @@ -21,7 +21,7 @@ public class Metrics extends TimerTask /** * The base url of the metrics domain */ - private static final String BASE_URL = "http://mcstats.org"; + private static final String BASE_URL = "https://mcstats.spigotmc.org"; /** * The url used to report a server's status */ From 7ce9ae50e7d5786dd5802a4bd7cefda79d50fa69 Mon Sep 17 00:00:00 2001 From: Mystiflow Date: Wed, 11 Jul 2018 09:22:41 +0100 Subject: [PATCH 17/24] #2447: Add API for fluent server connect requests API allows for more control over callback to see why the callback was performed whilst maintaining backwards compatibility --- .../md_5/bungee/api/ServerConnectRequest.java | 101 ++++++++++++++++++ .../bungee/api/connection/ProxiedPlayer.java | 10 ++ .../java/net/md_5/bungee/UserConnection.java | 24 +++-- 3 files changed, 128 insertions(+), 7 deletions(-) create mode 100644 api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java diff --git a/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java b/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java new file mode 100644 index 0000000000..be0b5ec02b --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java @@ -0,0 +1,101 @@ +package net.md_5.bungee.api; + +import lombok.Builder; +import lombok.Getter; +import lombok.NonNull; +import net.md_5.bungee.api.config.ServerInfo; +import net.md_5.bungee.api.event.ServerConnectEvent; + +/** + * A request to connect a server. + */ +@Getter +@Builder +public class ServerConnectRequest +{ + + /** + * The result from this callback after request has been executed by proxy. + */ + public enum Result + { + + /** + * ServerConnectEvent to the new server was canceled. + */ + EVENT_CANCEL, + /** + * Already connected to target server. + */ + ALREADY_CONNECTED, + /** + * Already connecting to target server. + */ + ALREADY_CONNECTING, + /** + * Successfully connected to server. + */ + SUCCESS, + /** + * Connection failed, error can be accessed from callback method handle. + */ + FAIL + } + + /** + * Target server to connect to. + */ + @NonNull + private final ServerInfo target; + /** + * Reason for connecting to server. + */ + @NonNull + private final ServerConnectEvent.Reason reason; + /** + * Callback to execute post request. + */ + private final Callback result; + /** + * Timeout in milliseconds for request. + */ + private final int connectTimeout; + /** + * Should the player be attempted to connect to the next server in their + * queue if the initial request fails. + */ + private final boolean retry; + + /** + * Class that sets default properties/adds methods to the lombok builder + * generated class. + */ + public static class ServerConnectRequestBuilder + { + + private Callback result; + private int connectTimeout = 5000; // TODO: Configurable + + /** + * Sets the callback to execute on explicit succession of the request. + * + * @param callback the callback to execute + * @return this builder for chaining + * @deprecated recommended to use callback providing generic type of + * {@link Result} + */ + @Deprecated + public ServerConnectRequestBuilder callback(final Callback callback) + { + this.result = new Callback() + { + @Override + public void done(final Result result, final Throwable error) + { + callback.done( ( result == Result.SUCCESS ) ? Boolean.TRUE : Boolean.FALSE, error ); + } + }; + return this; + } + } +} diff --git a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java index 333d39729e..e3e999b0db 100644 --- a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java +++ b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java @@ -6,6 +6,7 @@ import net.md_5.bungee.api.Callback; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.ServerConnectRequest; import net.md_5.bungee.api.SkinConfiguration; import net.md_5.bungee.api.Title; import net.md_5.bungee.api.chat.BaseComponent; @@ -123,6 +124,15 @@ public enum MainHand */ void connect(ServerInfo target, Callback callback, ServerConnectEvent.Reason reason); + /** + * Connects / transfers this user to the specified connection, gracefully + * closing the current one. Depending on the implementation, this method + * might return before the user has been connected. + * + * @param request request to connect with + */ + void connect(ServerConnectRequest request); + /** * Gets the server this player is connected to. * diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index dfa4b71b87..8f84aa173a 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -27,6 +27,7 @@ import net.md_5.bungee.api.Callback; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.ServerConnectRequest; import net.md_5.bungee.api.SkinConfiguration; import net.md_5.bungee.api.Title; import net.md_5.bungee.api.chat.BaseComponent; @@ -253,12 +254,21 @@ public void connect(ServerInfo info, final Callback callback, final boo { Preconditions.checkNotNull( info, "info" ); - ServerConnectEvent event = new ServerConnectEvent( this, info, reason ); + connect( ServerConnectRequest.builder().callback( callback ).retry( retry ).reason( reason ).target( info ).build() ); + } + + @Override + public void connect(final ServerConnectRequest request) + { + Preconditions.checkNotNull( request, "request" ); + + final Callback callback = request.getResult(); + ServerConnectEvent event = new ServerConnectEvent( this, request.getTarget(), request.getReason() ); if ( bungee.getPluginManager().callEvent( event ).isCancelled() ) { if ( callback != null ) { - callback.done( false, null ); + callback.done( ServerConnectRequest.Result.EVENT_CANCEL, null ); } if ( getServer() == null && !ch.isClosing() ) @@ -274,7 +284,7 @@ public void connect(ServerInfo info, final Callback callback, final boo { if ( callback != null ) { - callback.done( false, null ); + callback.done( ServerConnectRequest.Result.ALREADY_CONNECTED, null ); } sendMessage( bungee.getTranslation( "already_connected" ) ); @@ -284,7 +294,7 @@ public void connect(ServerInfo info, final Callback callback, final boo { if ( callback != null ) { - callback.done( false, null ); + callback.done( ServerConnectRequest.Result.ALREADY_CONNECTING, null ); } sendMessage( bungee.getTranslation( "already_connecting" ) ); @@ -312,7 +322,7 @@ public void operationComplete(ChannelFuture future) throws Exception { if ( callback != null ) { - callback.done( future.isSuccess(), future.cause() ); + callback.done( ( future.isSuccess() ) ? ServerConnectRequest.Result.SUCCESS : ServerConnectRequest.Result.FAIL, future.cause() ); } if ( !future.isSuccess() ) @@ -321,7 +331,7 @@ public void operationComplete(ChannelFuture future) throws Exception pendingConnects.remove( target ); ServerInfo def = updateAndGetNextServer( target ); - if ( retry && def != null && ( getServer() == null || def != getServer().getInfo() ) ) + if ( request.isRetry() && def != null && ( getServer() == null || def != getServer().getInfo() ) ) { sendMessage( bungee.getTranslation( "fallback_lobby" ) ); connect( def, null, true, ServerConnectEvent.Reason.LOBBY_FALLBACK ); @@ -339,7 +349,7 @@ public void operationComplete(ChannelFuture future) throws Exception .channel( PipelineUtils.getChannel() ) .group( ch.getHandle().eventLoop() ) .handler( initializer ) - .option( ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000 ) // TODO: Configurable + .option( ChannelOption.CONNECT_TIMEOUT_MILLIS, request.getConnectTimeout() ) .remoteAddress( target.getAddress() ); // Windows is bugged, multi homed users will just have to live with random connecting IPs if ( getPendingConnection().getListener().isSetLocalAddress() && !PlatformDependent.isWindows() ) From 95ed7a5775e956e00062a3bd6e00a3c4edbf4d70 Mon Sep 17 00:00:00 2001 From: maol3 Date: Sat, 21 Jul 2018 10:56:49 +0200 Subject: [PATCH 18/24] #2474: Allow ALL in the Message channel --- .../bungee/connection/DownstreamBridge.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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 842425bb35..8f6f5c0f7c 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 @@ -391,10 +391,21 @@ public void handle(PluginMessage pluginMessage) throws Exception } if ( subChannel.equals( "Message" ) ) { - ProxiedPlayer target = bungee.getPlayer( in.readUTF() ); - if ( target != null ) + String target = in.readUTF(); + String message = in.readUTF(); + if ( target.equals( "ALL" ) ) + { + for ( ProxiedPlayer player : bungee.getPlayers() ) + { + player.sendMessage( message ); + } + } else { - target.sendMessage( in.readUTF() ); + ProxiedPlayer player = bungee.getPlayer( target ); + if ( player != null ) + { + player.sendMessage( message ); + } } } if ( subChannel.equals( "GetServer" ) ) From c9f22868b3dfc6e42ad19185e1eb515c5c227723 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 22 Jul 2018 20:13:30 +1000 Subject: [PATCH 19/24] Revert "#2447: Add API for fluent server connect requests" This reverts commit 7ce9ae50e7d5786dd5802a4bd7cefda79d50fa69. --- .../md_5/bungee/api/ServerConnectRequest.java | 101 ------------------ .../bungee/api/connection/ProxiedPlayer.java | 10 -- .../java/net/md_5/bungee/UserConnection.java | 24 ++--- 3 files changed, 7 insertions(+), 128 deletions(-) delete mode 100644 api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java diff --git a/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java b/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java deleted file mode 100644 index be0b5ec02b..0000000000 --- a/api/src/main/java/net/md_5/bungee/api/ServerConnectRequest.java +++ /dev/null @@ -1,101 +0,0 @@ -package net.md_5.bungee.api; - -import lombok.Builder; -import lombok.Getter; -import lombok.NonNull; -import net.md_5.bungee.api.config.ServerInfo; -import net.md_5.bungee.api.event.ServerConnectEvent; - -/** - * A request to connect a server. - */ -@Getter -@Builder -public class ServerConnectRequest -{ - - /** - * The result from this callback after request has been executed by proxy. - */ - public enum Result - { - - /** - * ServerConnectEvent to the new server was canceled. - */ - EVENT_CANCEL, - /** - * Already connected to target server. - */ - ALREADY_CONNECTED, - /** - * Already connecting to target server. - */ - ALREADY_CONNECTING, - /** - * Successfully connected to server. - */ - SUCCESS, - /** - * Connection failed, error can be accessed from callback method handle. - */ - FAIL - } - - /** - * Target server to connect to. - */ - @NonNull - private final ServerInfo target; - /** - * Reason for connecting to server. - */ - @NonNull - private final ServerConnectEvent.Reason reason; - /** - * Callback to execute post request. - */ - private final Callback result; - /** - * Timeout in milliseconds for request. - */ - private final int connectTimeout; - /** - * Should the player be attempted to connect to the next server in their - * queue if the initial request fails. - */ - private final boolean retry; - - /** - * Class that sets default properties/adds methods to the lombok builder - * generated class. - */ - public static class ServerConnectRequestBuilder - { - - private Callback result; - private int connectTimeout = 5000; // TODO: Configurable - - /** - * Sets the callback to execute on explicit succession of the request. - * - * @param callback the callback to execute - * @return this builder for chaining - * @deprecated recommended to use callback providing generic type of - * {@link Result} - */ - @Deprecated - public ServerConnectRequestBuilder callback(final Callback callback) - { - this.result = new Callback() - { - @Override - public void done(final Result result, final Throwable error) - { - callback.done( ( result == Result.SUCCESS ) ? Boolean.TRUE : Boolean.FALSE, error ); - } - }; - return this; - } - } -} diff --git a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java index e3e999b0db..333d39729e 100644 --- a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java +++ b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java @@ -6,7 +6,6 @@ import net.md_5.bungee.api.Callback; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.ServerConnectRequest; import net.md_5.bungee.api.SkinConfiguration; import net.md_5.bungee.api.Title; import net.md_5.bungee.api.chat.BaseComponent; @@ -124,15 +123,6 @@ public enum MainHand */ void connect(ServerInfo target, Callback callback, ServerConnectEvent.Reason reason); - /** - * Connects / transfers this user to the specified connection, gracefully - * closing the current one. Depending on the implementation, this method - * might return before the user has been connected. - * - * @param request request to connect with - */ - void connect(ServerConnectRequest request); - /** * Gets the server this player is connected to. * diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index 8f84aa173a..dfa4b71b87 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -27,7 +27,6 @@ import net.md_5.bungee.api.Callback; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.ServerConnectRequest; import net.md_5.bungee.api.SkinConfiguration; import net.md_5.bungee.api.Title; import net.md_5.bungee.api.chat.BaseComponent; @@ -254,21 +253,12 @@ public void connect(ServerInfo info, final Callback callback, final boo { Preconditions.checkNotNull( info, "info" ); - connect( ServerConnectRequest.builder().callback( callback ).retry( retry ).reason( reason ).target( info ).build() ); - } - - @Override - public void connect(final ServerConnectRequest request) - { - Preconditions.checkNotNull( request, "request" ); - - final Callback callback = request.getResult(); - ServerConnectEvent event = new ServerConnectEvent( this, request.getTarget(), request.getReason() ); + ServerConnectEvent event = new ServerConnectEvent( this, info, reason ); if ( bungee.getPluginManager().callEvent( event ).isCancelled() ) { if ( callback != null ) { - callback.done( ServerConnectRequest.Result.EVENT_CANCEL, null ); + callback.done( false, null ); } if ( getServer() == null && !ch.isClosing() ) @@ -284,7 +274,7 @@ public void connect(final ServerConnectRequest request) { if ( callback != null ) { - callback.done( ServerConnectRequest.Result.ALREADY_CONNECTED, null ); + callback.done( false, null ); } sendMessage( bungee.getTranslation( "already_connected" ) ); @@ -294,7 +284,7 @@ public void connect(final ServerConnectRequest request) { if ( callback != null ) { - callback.done( ServerConnectRequest.Result.ALREADY_CONNECTING, null ); + callback.done( false, null ); } sendMessage( bungee.getTranslation( "already_connecting" ) ); @@ -322,7 +312,7 @@ public void operationComplete(ChannelFuture future) throws Exception { if ( callback != null ) { - callback.done( ( future.isSuccess() ) ? ServerConnectRequest.Result.SUCCESS : ServerConnectRequest.Result.FAIL, future.cause() ); + callback.done( future.isSuccess(), future.cause() ); } if ( !future.isSuccess() ) @@ -331,7 +321,7 @@ public void operationComplete(ChannelFuture future) throws Exception pendingConnects.remove( target ); ServerInfo def = updateAndGetNextServer( target ); - if ( request.isRetry() && def != null && ( getServer() == null || def != getServer().getInfo() ) ) + if ( retry && def != null && ( getServer() == null || def != getServer().getInfo() ) ) { sendMessage( bungee.getTranslation( "fallback_lobby" ) ); connect( def, null, true, ServerConnectEvent.Reason.LOBBY_FALLBACK ); @@ -349,7 +339,7 @@ public void operationComplete(ChannelFuture future) throws Exception .channel( PipelineUtils.getChannel() ) .group( ch.getHandle().eventLoop() ) .handler( initializer ) - .option( ChannelOption.CONNECT_TIMEOUT_MILLIS, request.getConnectTimeout() ) + .option( ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000 ) // TODO: Configurable .remoteAddress( target.getAddress() ); // Windows is bugged, multi homed users will just have to live with random connecting IPs if ( getPendingConnection().getListener().isSetLocalAddress() && !PlatformDependent.isWindows() ) From 176b75b97edaaea8551123664ebc4c9975e05225 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 23 Jul 2018 11:12:20 +1000 Subject: [PATCH 20/24] #2477: Fix entity rewrites not applying --- .../java/net/md_5/bungee/connection/DownstreamBridge.java | 2 +- .../java/net/md_5/bungee/connection/UpstreamBridge.java | 2 +- .../src/main/java/net/md_5/bungee/entitymap/EntityMap.java | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) 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 8f6f5c0f7c..22a5ac0547 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 @@ -101,7 +101,7 @@ public boolean shouldHandle(PacketWrapper packet) throws Exception @Override public void handle(PacketWrapper packet) throws Exception { - con.getEntityRewrite().rewriteClientbound( packet.buf, con.getServerEntityId(), con.getClientEntityId() ); + con.getEntityRewrite().rewriteClientbound( packet.buf, con.getServerEntityId(), con.getClientEntityId(), con.getPendingConnection().getVersion() ); con.sendPacket( packet ); } 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 99933dc87c..9666e7a243 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 @@ -109,7 +109,7 @@ public void handle(PacketWrapper packet) throws Exception { if ( con.getServer() != null ) { - con.getEntityRewrite().rewriteServerbound( packet.buf, con.getClientEntityId(), con.getServerEntityId() ); + con.getEntityRewrite().rewriteServerbound( packet.buf, con.getClientEntityId(), con.getServerEntityId(), con.getPendingConnection().getVersion() ); con.getServer().getCh().write( packet ); } } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java index cae566f5e0..049aa2e8ee 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java @@ -145,7 +145,7 @@ protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, in DefinedPacket.readString( packet ); } break; - case 14: // particle + case 15: // particle int particleId = DefinedPacket.readVarInt( packet ); switch ( particleId ) { @@ -162,7 +162,10 @@ protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, in } break; default: - type--; + if ( type >= 6 ) + { + type--; + } break; } } From a710698277d6edd83e82c7e9269f56956539655e Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 23 Jul 2018 12:07:30 +1000 Subject: [PATCH 21/24] #2482: Fix error in reading slots --- .../main/java/net/md_5/bungee/entitymap/EntityMap.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java index 049aa2e8ee..faa94c87b9 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java @@ -157,7 +157,7 @@ protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, in packet.skipBytes( 16 ); // float, float, float, flat break; case 27: // item - readSkipSlot( packet ); + readSkipSlot( packet, protocolVersion ); break; } break; @@ -192,7 +192,7 @@ protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, in DefinedPacket.readString( packet ); break; case 5: - readSkipSlot( packet ); + readSkipSlot( packet, protocolVersion ); break; case 6: packet.skipBytes( 1 ); // boolean @@ -238,11 +238,11 @@ protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, in packet.readerIndex( readerIndex ); } - private static void readSkipSlot(ByteBuf packet) + private static void readSkipSlot(ByteBuf packet, int protocolVersion) { if ( packet.readShort() != -1 ) { - packet.skipBytes( 3 ); // byte, short + packet.skipBytes( ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? 1 : 3 ); // byte vs byte, short int position = packet.readerIndex(); if ( packet.readByte() != 0 ) From d2cf50f9ee383342be1770dce134ae018a7e5c54 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 23 Jul 2018 12:44:42 +1000 Subject: [PATCH 22/24] #2482: Fix error reading custom names --- proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java index faa94c87b9..c65a848190 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java @@ -144,7 +144,7 @@ protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, in { DefinedPacket.readString( packet ); } - break; + continue; case 15: // particle int particleId = DefinedPacket.readVarInt( packet ); switch ( particleId ) @@ -160,7 +160,7 @@ protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, in readSkipSlot( packet, protocolVersion ); break; } - break; + continue; default: if ( type >= 6 ) { From 6fadb4250cb7f89feb2a98d9de973f6d627e33ae Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 23 Jul 2018 14:29:05 +1000 Subject: [PATCH 23/24] Use shorter legacy prefix (doesn't really matter because no chance of such a plugin working) --- .../java/net/md_5/bungee/protocol/packet/PluginMessage.java | 2 +- .../java/net/md_5/bungee/protocol/packet/PluginMessageTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java index 8d4eacbc54..a71cc710fa 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java @@ -45,7 +45,7 @@ public String apply(String tag) return tag; } - return "bungeecord:legacy/" + tag.toLowerCase( Locale.ROOT ); + return "legacy:" + tag.toLowerCase( Locale.ROOT ); } }; public static final Predicate SHOULD_RELAY = new Predicate() diff --git a/protocol/src/test/java/net/md_5/bungee/protocol/packet/PluginMessageTest.java b/protocol/src/test/java/net/md_5/bungee/protocol/packet/PluginMessageTest.java index 754421693b..00a897a273 100644 --- a/protocol/src/test/java/net/md_5/bungee/protocol/packet/PluginMessageTest.java +++ b/protocol/src/test/java/net/md_5/bungee/protocol/packet/PluginMessageTest.java @@ -11,7 +11,7 @@ public void testModerniseChannel() { Assert.assertEquals( "bungeecord:main", PluginMessage.MODERNISE.apply( "BungeeCord" ) ); Assert.assertEquals( "BungeeCord", PluginMessage.MODERNISE.apply( "bungeecord:main" ) ); - Assert.assertEquals( "bungeecord:legacy/foo", PluginMessage.MODERNISE.apply( "FoO" ) ); + Assert.assertEquals( "legacy:foo", PluginMessage.MODERNISE.apply( "FoO" ) ); Assert.assertEquals( "foo:bar", PluginMessage.MODERNISE.apply( "foo:bar" ) ); } } From 2da2561fdbc922a2dd8460c1c143623c05fa82fa Mon Sep 17 00:00:00 2001 From: ghac Date: Sun, 29 Jul 2018 22:22:44 +0200 Subject: [PATCH 24/24] Fix problem with the login process because of double-reading/writing the tag. --- .../java/net/md_5/bungee/protocol/packet/PluginMessage.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java index 6da1432c37..b6e71fb64a 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java @@ -70,7 +70,6 @@ public boolean apply(PluginMessage input) @Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - tag = readString( buf ); if ( protocolVersion < ProtocolConstants.MINECRAFT_1_8 ) { tag = readString( buf ); @@ -88,7 +87,6 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco @Override public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { - writeString( tag, buf ); if ( protocolVersion < ProtocolConstants.MINECRAFT_1_8 ) { writeString( tag, buf );