Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-20 06:50:10 +01:00
Limit number of book pages in 1.17->1.17.1
Dieser Commit ist enthalten in:
Ursprung
77a5b2212b
Commit
a654becac8
@ -5,7 +5,7 @@ plugins {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
group = "com.viaversion"
|
group = "com.viaversion"
|
||||||
version = "4.0.1-1.17.1-pre1-SNAPSHOT"
|
version = "4.0.1-1.17.1-pre2-SNAPSHOT"
|
||||||
description = "Allow older clients to join newer server versions."
|
description = "Allow older clients to join newer server versions."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
|
|||||||
|
|
||||||
private static final int MAX_PAGE_LENGTH = 8192;
|
private static final int MAX_PAGE_LENGTH = 8192;
|
||||||
private static final int MAX_TITLE_LENGTH = 128;
|
private static final int MAX_TITLE_LENGTH = 128;
|
||||||
|
private static final int MAX_PAGES = 200; // Actually limited to 100 when handling the read packet, but /shrug
|
||||||
|
|
||||||
public Protocol1_17To1_17_1() {
|
public Protocol1_17To1_17_1() {
|
||||||
super(ClientboundPackets1_17.class, ClientboundPackets1_17.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
|
super(ClientboundPackets1_17.class, ClientboundPackets1_17.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
|
||||||
@ -108,6 +109,7 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
|
|||||||
CompoundTag tag = item.tag();
|
CompoundTag tag = item.tag();
|
||||||
ListTag pagesTag;
|
ListTag pagesTag;
|
||||||
StringTag titleTag = null;
|
StringTag titleTag = null;
|
||||||
|
// Sanity checks
|
||||||
if (tag == null || (pagesTag = tag.get("pages")) == null
|
if (tag == null || (pagesTag = tag.get("pages")) == null
|
||||||
|| (signing && (titleTag = tag.get("title")) == null)) {
|
|| (signing && (titleTag = tag.get("title")) == null)) {
|
||||||
wrapper.write(Type.VAR_INT, 0); // Pages length
|
wrapper.write(Type.VAR_INT, 0); // Pages length
|
||||||
@ -115,13 +117,19 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write pages
|
// Write pages - limit them first
|
||||||
|
if (pagesTag.size() > MAX_PAGES) {
|
||||||
|
pagesTag = new ListTag(pagesTag.getValue().subList(0, MAX_PAGES));
|
||||||
|
}
|
||||||
|
|
||||||
wrapper.write(Type.VAR_INT, pagesTag.size());
|
wrapper.write(Type.VAR_INT, pagesTag.size());
|
||||||
for (Tag pageTag : pagesTag) {
|
for (Tag pageTag : pagesTag) {
|
||||||
String page = ((StringTag) pageTag).getValue();
|
String page = ((StringTag) pageTag).getValue();
|
||||||
|
// Limit page length
|
||||||
if (page.length() > MAX_PAGE_LENGTH) {
|
if (page.length() > MAX_PAGE_LENGTH) {
|
||||||
page = page.substring(0, MAX_PAGE_LENGTH);
|
page = page.substring(0, MAX_PAGE_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.write(Type.STRING, page);
|
wrapper.write(Type.STRING, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,10 +140,12 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
|
|||||||
titleTag = tag.get("title");
|
titleTag = tag.get("title");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Limit title length
|
||||||
String title = titleTag.getValue();
|
String title = titleTag.getValue();
|
||||||
if (title.length() > MAX_TITLE_LENGTH) {
|
if (title.length() > MAX_TITLE_LENGTH) {
|
||||||
title = title.substring(0, MAX_TITLE_LENGTH);
|
title = title.substring(0, MAX_TITLE_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.write(Type.STRING, title);
|
wrapper.write(Type.STRING, title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@ metadata.format.version = "1.0"
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
# ViaVersion
|
# ViaVersion
|
||||||
viaver = "4.0.1-1.17.1-pre1-SNAPSHOT"
|
viaver = "4.0.1-1.17.1-pre2-SNAPSHOT"
|
||||||
|
|
||||||
# Common provided
|
# Common provided
|
||||||
netty = "4.0.20.Final"
|
netty = "4.0.20.Final"
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren