From a654becac8cae6f716a6e6bf5c3f2c108acc2fee Mon Sep 17 00:00:00 2001 From: KennyTV Date: Tue, 29 Jun 2021 19:19:02 +0200 Subject: [PATCH] Limit number of book pages in 1.17->1.17.1 --- build.gradle.kts | 2 +- .../protocol1_17to1_17_1/Protocol1_17To1_17_1.java | 12 +++++++++++- gradle/libs.versions.toml | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a8cec13f..615bb658 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { allprojects { 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." } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17to1_17_1/Protocol1_17To1_17_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17to1_17_1/Protocol1_17To1_17_1.java index 79240681..88fe3e25 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17to1_17_1/Protocol1_17To1_17_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17to1_17_1/Protocol1_17To1_17_1.java @@ -34,6 +34,7 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol MAX_PAGES) { + pagesTag = new ListTag(pagesTag.getValue().subList(0, MAX_PAGES)); + } + wrapper.write(Type.VAR_INT, pagesTag.size()); for (Tag pageTag : pagesTag) { String page = ((StringTag) pageTag).getValue(); + // Limit page length if (page.length() > MAX_PAGE_LENGTH) { page = page.substring(0, MAX_PAGE_LENGTH); } + wrapper.write(Type.STRING, page); } @@ -132,10 +140,12 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol MAX_TITLE_LENGTH) { title = title.substring(0, MAX_TITLE_LENGTH); } + wrapper.write(Type.STRING, title); } }); diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fe0df1c0..f84de89d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ metadata.format.version = "1.0" [versions] # ViaVersion -viaver = "4.0.1-1.17.1-pre1-SNAPSHOT" +viaver = "4.0.1-1.17.1-pre2-SNAPSHOT" # Common provided netty = "4.0.20.Final"