Always throw on serverbound custom payload errors

Old server versions did suppress exceptions, but that doesn't matter for us
This commit is contained in:
Nassim Jahnke 2024-05-21 20:47:48 +02:00
parent c5756fe45c
commit 01589b3c49
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
4 changed files with 15 additions and 15 deletions

View File

@ -224,7 +224,7 @@ public class ItemPacketRewriter1_13 extends ItemRewriter<ClientboundPackets1_12_
@Override
public void register() {
map(Types.STRING); // Channel
handlerSoftFail(wrapper -> {
handler(wrapper -> {
String channel = wrapper.get(Types.STRING, 0);
String old = channel;
channel = getOldPluginChannelId(channel);

View File

@ -165,7 +165,7 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol<ClientboundPackets1_1
@Override
public void register() {
map(Types.STRING); // Channel
handlerSoftFail(wrapper -> {
handler(wrapper -> {
final String channel = wrapper.get(Types.STRING, 0);
final String namespacedChannel = Key.namespaced(channel);
if (channel.length() > 32) {

View File

@ -78,21 +78,13 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
soundRewriter.registerSound1_19_3(ClientboundPackets1_19_4.SOUND);
soundRewriter.registerSound1_19_3(ClientboundPackets1_19_4.SOUND_ENTITY);
final PacketHandlers sanitizeCustomPayload = new PacketHandlers() {
registerClientbound(ClientboundPackets1_19_4.CUSTOM_PAYLOAD, new PacketHandlers() {
@Override
protected void register() {
map(Types.STRING); // Channel
handlerSoftFail(wrapper -> {
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<ClientboundPack
});
}
private static void sanitizeCustomPayload(final PacketWrapper wrapper) {
final String channel = Key.namespaced(wrapper.passthrough(Types.STRING));
if (channel.equals("minecraft:brand")) {
wrapper.passthrough(Types.STRING);
wrapper.clearInputBuffer();
}
}
@Override
public void transform(final Direction direction, final State state, final PacketWrapper packetWrapper) throws InformativeException, CancelException {
if (direction == Direction.SERVERBOUND) {

View File

@ -416,7 +416,7 @@ public class PlayerPacketRewriter1_9 {
@Override
public void register() {
map(Types.STRING); // 0 - Channel Name
handlerSoftFail(wrapper -> {
handler(wrapper -> {
String name = wrapper.get(Types.STRING, 0);
if (name.equals("MC|BSign")) {
Item item = wrapper.passthrough(Types.ITEM1_8);