mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 11:35:18 +01:00
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:
parent
c5756fe45c
commit
01589b3c49
@ -224,7 +224,7 @@ public class ItemPacketRewriter1_13 extends ItemRewriter<ClientboundPackets1_12_
|
|||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.STRING); // Channel
|
map(Types.STRING); // Channel
|
||||||
handlerSoftFail(wrapper -> {
|
handler(wrapper -> {
|
||||||
String channel = wrapper.get(Types.STRING, 0);
|
String channel = wrapper.get(Types.STRING, 0);
|
||||||
String old = channel;
|
String old = channel;
|
||||||
channel = getOldPluginChannelId(channel);
|
channel = getOldPluginChannelId(channel);
|
||||||
|
@ -165,7 +165,7 @@ public class Protocol1_15_2To1_16 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.STRING); // Channel
|
map(Types.STRING); // Channel
|
||||||
handlerSoftFail(wrapper -> {
|
handler(wrapper -> {
|
||||||
final String channel = wrapper.get(Types.STRING, 0);
|
final String channel = wrapper.get(Types.STRING, 0);
|
||||||
final String namespacedChannel = Key.namespaced(channel);
|
final String namespacedChannel = Key.namespaced(channel);
|
||||||
if (channel.length() > 32) {
|
if (channel.length() > 32) {
|
||||||
|
@ -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);
|
||||||
soundRewriter.registerSound1_19_3(ClientboundPackets1_19_4.SOUND_ENTITY);
|
soundRewriter.registerSound1_19_3(ClientboundPackets1_19_4.SOUND_ENTITY);
|
||||||
|
|
||||||
final PacketHandlers sanitizeCustomPayload = 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(wrapper -> {
|
|
||||||
final String channel = Key.namespaced(wrapper.get(Types.STRING, 0));
|
|
||||||
if (channel.equals("minecraft:brand")) {
|
|
||||||
wrapper.passthrough(Types.STRING);
|
|
||||||
wrapper.clearInputBuffer();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
registerClientbound(ClientboundPackets1_19_4.CUSTOM_PAYLOAD, sanitizeCustomPayload);
|
registerServerbound(ServerboundPackets1_20_2.CUSTOM_PAYLOAD, Protocol1_20To1_20_2::sanitizeCustomPayload);
|
||||||
registerServerbound(ServerboundPackets1_20_2.CUSTOM_PAYLOAD, sanitizeCustomPayload);
|
|
||||||
|
|
||||||
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);
|
||||||
@ -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
|
@Override
|
||||||
public void transform(final Direction direction, final State state, final PacketWrapper packetWrapper) throws InformativeException, CancelException {
|
public void transform(final Direction direction, final State state, final PacketWrapper packetWrapper) throws InformativeException, CancelException {
|
||||||
if (direction == Direction.SERVERBOUND) {
|
if (direction == Direction.SERVERBOUND) {
|
||||||
|
@ -416,7 +416,7 @@ public class PlayerPacketRewriter1_9 {
|
|||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.STRING); // 0 - Channel Name
|
map(Types.STRING); // 0 - Channel Name
|
||||||
handlerSoftFail(wrapper -> {
|
handler(wrapper -> {
|
||||||
String name = wrapper.get(Types.STRING, 0);
|
String name = wrapper.get(Types.STRING, 0);
|
||||||
if (name.equals("MC|BSign")) {
|
if (name.equals("MC|BSign")) {
|
||||||
Item item = wrapper.passthrough(Types.ITEM1_8);
|
Item item = wrapper.passthrough(Types.ITEM1_8);
|
||||||
|
Loading…
Reference in New Issue
Block a user