From 91319402f30018c1ba66f9c6c8f3908a5e2bc5b5 Mon Sep 17 00:00:00 2001 From: Thibaut Gautier Date: Sun, 17 Jan 2021 13:12:18 +0100 Subject: [PATCH 1/5] Fixed encoding not properly working with other packet reading libraries Injecting a message to byte encoder beforehand would break outbound packets in ViaVersion. This solution is a good fix which won't impact anything. --- .../myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java index 06bc19f20..63ee36b6d 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java @@ -54,8 +54,10 @@ public class BukkitEncodeHandler extends MessageToByteEncoder implements ViaHand throw (Error) e.getCause(); } } + + } else { + bytebuf.clear().writeBytes((ByteBuf) o); } - transform(bytebuf); } From 7faf4cf81a5ca468461a59bb80cbec4ac0909d7c Mon Sep 17 00:00:00 2001 From: Jo0001 Date: Mon, 1 Feb 2021 14:51:03 +0100 Subject: [PATCH 2/5] Change error message (#2286) --- .../us/myles/ViaVersion/exception/InformativeException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/us/myles/ViaVersion/exception/InformativeException.java b/common/src/main/java/us/myles/ViaVersion/exception/InformativeException.java index 86afaf8ff..95eefd60a 100644 --- a/common/src/main/java/us/myles/ViaVersion/exception/InformativeException.java +++ b/common/src/main/java/us/myles/ViaVersion/exception/InformativeException.java @@ -31,7 +31,7 @@ public class InformativeException extends Exception { @Override public String getMessage() { StringBuilder builder = new StringBuilder(); - builder.append("Please post this error to https://github.com/ViaVersion/ViaVersion/issues\n{"); + builder.append("Please post this error to https://github.com/ViaVersion/ViaVersion/issues and follow the issue template\n{"); int i = 0; for (Map.Entry entry : info.entrySet()) { builder.append(i == 0 ? "" : ", ").append(entry.getKey()).append(": ").append(entry.getValue().toString()); From 6941b48038125d1a37196b0fe1c2e8a7540452f6 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Sat, 6 Feb 2021 10:21:34 -0300 Subject: [PATCH 3/5] fixed pending #2291 changes --- .../myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java | 2 +- .../myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java index 63ee36b6d..4ab8efb3b 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/handlers/BukkitEncodeHandler.java @@ -56,7 +56,7 @@ public class BukkitEncodeHandler extends MessageToByteEncoder implements ViaHand } } else { - bytebuf.clear().writeBytes((ByteBuf) o); + bytebuf.writeBytes((ByteBuf) o); } transform(bytebuf); } diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java index 6b643081c..ecd85a684 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java @@ -35,8 +35,9 @@ public class SpongeEncodeHandler extends MessageToByteEncoder implements throw (Error) e.getCause(); } } + } else { + bytebuf.write((ByteBuf) o) } - transform(bytebuf); } From 100ae1c6802d88a043538a8e2f75f07d916573c0 Mon Sep 17 00:00:00 2001 From: creeper123123321 <7974274+creeper123123321@users.noreply.github.com> Date: Sat, 6 Feb 2021 11:18:51 -0300 Subject: [PATCH 4/5] Update SpongeEncodeHandler.java --- .../myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java index ecd85a684..cc4345775 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java @@ -36,7 +36,7 @@ public class SpongeEncodeHandler extends MessageToByteEncoder implements } } } else { - bytebuf.write((ByteBuf) o) + bytebuf.writeBytes((ByteBuf) o) } transform(bytebuf); } From 22793dbac4c826f54b17acfad9dbf82fd0350295 Mon Sep 17 00:00:00 2001 From: Myles Date: Sat, 6 Feb 2021 14:30:18 +0000 Subject: [PATCH 5/5] Re-add a semicolon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🥇 --- .../myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java index cc4345775..d6d3b0240 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java @@ -36,7 +36,7 @@ public class SpongeEncodeHandler extends MessageToByteEncoder implements } } } else { - bytebuf.writeBytes((ByteBuf) o) + bytebuf.writeBytes((ByteBuf) o); } transform(bytebuf); }