3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-10-03 08:41:05 +02:00

Only soft fail CUSTOM_PAYLOAD content reading (#3873)

Reading of the channel shouldn't be soft failed as the game code only try catches content reading
Dieser Commit ist enthalten in:
EnZaXD 2024-05-22 09:44:38 +02:00 committet von GitHub
Ursprung 01589b3c49
Commit 9b1c97919c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -81,10 +81,14 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
registerClientbound(ClientboundPackets1_19_4.CUSTOM_PAYLOAD, new PacketHandlers() { registerClientbound(ClientboundPackets1_19_4.CUSTOM_PAYLOAD, new PacketHandlers() {
@Override @Override
protected void register() { protected void register() {
map(Types.STRING); // Channel
handlerSoftFail(Protocol1_20To1_20_2::sanitizeCustomPayload); handlerSoftFail(Protocol1_20To1_20_2::sanitizeCustomPayload);
} }
}); });
registerServerbound(ServerboundPackets1_20_2.CUSTOM_PAYLOAD, Protocol1_20To1_20_2::sanitizeCustomPayload); registerServerbound(ServerboundPackets1_20_2.CUSTOM_PAYLOAD, wrapper -> {
wrapper.passthrough(Types.STRING); // Channel
sanitizeCustomPayload(wrapper);
});
registerClientbound(ClientboundPackets1_19_4.RESOURCE_PACK, wrapper -> { registerClientbound(ClientboundPackets1_19_4.RESOURCE_PACK, wrapper -> {
final String url = wrapper.passthrough(Types.STRING); final String url = wrapper.passthrough(Types.STRING);
@ -205,7 +209,7 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
} }
private static void sanitizeCustomPayload(final PacketWrapper wrapper) { private static void sanitizeCustomPayload(final PacketWrapper wrapper) {
final String channel = Key.namespaced(wrapper.passthrough(Types.STRING)); final String channel = Key.namespaced(wrapper.get(Types.STRING, 0));
if (channel.equals("minecraft:brand")) { if (channel.equals("minecraft:brand")) {
wrapper.passthrough(Types.STRING); wrapper.passthrough(Types.STRING);
wrapper.clearInputBuffer(); wrapper.clearInputBuffer();