Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-16 04:50:08 +01:00
Fix invalid book view not visible in 1.20.3->.5 (#4139)
Dieser Commit ist enthalten in:
Ursprung
95581a6fa5
Commit
ebc0e61be8
@ -1163,13 +1163,24 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
}
|
||||
|
||||
private void updateWrittenBookPages(final UserConnection connection, final StructuredDataContainer data, final CompoundTag tag) {
|
||||
final String title = tag.getString("title");
|
||||
final String author = tag.getString("author");
|
||||
final ListTag<StringTag> pagesTag = tag.getListTag("pages", StringTag.class);
|
||||
final CompoundTag filteredPagesTag = tag.getCompoundTag("filtered_pages");
|
||||
if (pagesTag == null) {
|
||||
return;
|
||||
|
||||
boolean valid = author != null && title != null && title.length() <= 32 && pagesTag != null;
|
||||
if (valid) {
|
||||
for (final StringTag page : pagesTag) {
|
||||
if (page.getValue().length() > Short.MAX_VALUE) {
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final List<FilterableComponent> pages = new ArrayList<>();
|
||||
if (valid) {
|
||||
final CompoundTag filteredPagesTag = tag.getCompoundTag("filtered_pages");
|
||||
|
||||
for (int i = 0; i < pagesTag.size(); i++) {
|
||||
final StringTag page = pagesTag.get(i);
|
||||
Tag filtered = null;
|
||||
@ -1195,15 +1206,20 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
|
||||
pages.add(new FilterableComponent(parsedPage, filtered));
|
||||
}
|
||||
} else {
|
||||
final CompoundTag invalidPage = new CompoundTag();
|
||||
invalidPage.putString("text", "* Invalid book tag *");
|
||||
invalidPage.putString("color", "#AA0000"); // dark red
|
||||
|
||||
pages.add(new FilterableComponent(invalidPage, null));
|
||||
}
|
||||
|
||||
final String title = tag.getString("title", "");
|
||||
final String filteredTitle = tag.getString("filtered_title"); // Nullable
|
||||
final String author = tag.getString("author", "");
|
||||
final int generation = tag.getInt("generation");
|
||||
final boolean resolved = tag.getBoolean("resolved");
|
||||
final WrittenBook writtenBook = new WrittenBook(
|
||||
new FilterableString(limit(title, 32), limit(filteredTitle, 32)),
|
||||
author,
|
||||
new FilterableString(limit(title == null ? "" : title, 32), limit(filteredTitle, 32)),
|
||||
author == null ? "" : author,
|
||||
clamp(generation, 0, 3),
|
||||
pages.toArray(new FilterableComponent[0]),
|
||||
resolved
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren