3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Prevent kick when signing empty book (#2700)

Dieser Commit ist enthalten in:
MrMicky 2021-10-03 10:11:34 +02:00 committet von GitHub
Ursprung 69409d71d1
Commit e64a0fb62e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.Position;
@ -31,6 +32,8 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import java.util.Collections;
public class PlayerPackets {
public static void register(Protocol protocol) {
@ -58,21 +61,26 @@ public class PlayerPackets {
Item item = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
protocol.getItemRewriter().handleItemToServer(item);
// Client limit when editing a book was upped from 50 to 100 in 1.14, but some anti-exploit plugins ban with a size higher than the old client limit
if (Via.getConfig().isTruncate1_14Books()) {
if (item == null) return;
CompoundTag tag = item.tag();
CompoundTag tag = item.tag();
if (tag == null) return;
Tag pages = tag.get("pages");
if (!(pages instanceof ListTag)) return;
// Fix for https://github.com/ViaVersion/ViaVersion/issues/2660
if (pages == null) {
tag.put("pages", new ListTag(Collections.singletonList(new StringTag())));
}
// Client limit when editing a book was upped from 50 to 100 in 1.14, but some anti-exploit plugins ban with a size higher than the old client limit
if (Via.getConfig().isTruncate1_14Books() && pages instanceof ListTag) {
ListTag listTag = (ListTag) pages;
if (listTag.size() <= 50) return;
if (listTag.size() > 50) {
listTag.setValue(listTag.getValue().subList(0, 50));
}
}
}
});
}
});