From 01589b3c496d0f3251bf3ec3ed1bd4b86d0b56da Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 21 May 2024 20:47:48 +0200 Subject: [PATCH] Always throw on serverbound custom payload errors Old server versions did suppress exceptions, but that doesn't matter for us --- .../rewriter/ItemPacketRewriter1_13.java | 2 +- .../v1_15_2to1_16/Protocol1_15_2To1_16.java | 2 +- .../v1_20to1_20_2/Protocol1_20To1_20_2.java | 24 +++++++++---------- .../rewriter/PlayerPacketRewriter1_9.java | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/ItemPacketRewriter1_13.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/ItemPacketRewriter1_13.java index 86334ef43..e6e45f061 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/ItemPacketRewriter1_13.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/rewriter/ItemPacketRewriter1_13.java @@ -224,7 +224,7 @@ public class ItemPacketRewriter1_13 extends ItemRewriter { + handler(wrapper -> { String channel = wrapper.get(Types.STRING, 0); String old = channel; channel = getOldPluginChannelId(channel); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java index 2a17b3f49..da21e8b76 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_15_2to1_16/Protocol1_15_2To1_16.java @@ -165,7 +165,7 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol { + handler(wrapper -> { final String channel = wrapper.get(Types.STRING, 0); final String namespacedChannel = Key.namespaced(channel); if (channel.length() > 32) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/Protocol1_20To1_20_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/Protocol1_20To1_20_2.java index c37b7ed14..520b3430b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/Protocol1_20To1_20_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20to1_20_2/Protocol1_20To1_20_2.java @@ -78,21 +78,13 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol { - final String channel = Key.namespaced(wrapper.get(Types.STRING, 0)); - if (channel.equals("minecraft:brand")) { - wrapper.passthrough(Types.STRING); - wrapper.clearInputBuffer(); - } - }); + handlerSoftFail(Protocol1_20To1_20_2::sanitizeCustomPayload); } - }; - registerClientbound(ClientboundPackets1_19_4.CUSTOM_PAYLOAD, sanitizeCustomPayload); - registerServerbound(ServerboundPackets1_20_2.CUSTOM_PAYLOAD, sanitizeCustomPayload); + }); + registerServerbound(ServerboundPackets1_20_2.CUSTOM_PAYLOAD, Protocol1_20To1_20_2::sanitizeCustomPayload); registerClientbound(ClientboundPackets1_19_4.RESOURCE_PACK, wrapper -> { final String url = wrapper.passthrough(Types.STRING); @@ -212,6 +204,14 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol { + handler(wrapper -> { String name = wrapper.get(Types.STRING, 0); if (name.equals("MC|BSign")) { Item item = wrapper.passthrough(Types.ITEM1_8);