Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 16:40:10 +01:00
Push book contents through component conversion in 1.8->1.9 (#3790)
Dieser Commit ist enthalten in:
Ursprung
bd8e469216
Commit
98c5d38d0c
@ -20,9 +20,10 @@ package com.viaversion.viaversion.protocols.protocol1_9to1_8;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
|
import com.viaversion.viaversion.util.ComponentUtil;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
import com.viaversion.viaversion.util.SerializerVersion;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -227,24 +228,11 @@ public class ItemRewriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < pages.size(); i++) {
|
for (int i = 0; i < pages.size(); i++) {
|
||||||
StringTag pageTag = pages.get(i);
|
final StringTag pageTag = pages.get(i);
|
||||||
String value = pageTag.getValue();
|
final String value = pageTag.getValue();
|
||||||
if (value.replaceAll(" ", "").isEmpty()) {
|
|
||||||
value = "\"" + fixBookSpaceChars(value) + "\"";
|
|
||||||
} else {
|
|
||||||
value = fixBookSpaceChars(value);
|
|
||||||
}
|
|
||||||
pageTag.setValue(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String fixBookSpaceChars(String str) {
|
pageTag.setValue(ComponentUtil.convertJson(value, SerializerVersion.V1_9, SerializerVersion.V1_8).toString());
|
||||||
if (!str.startsWith(" ")) {
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
// hacky but it works :)
|
|
||||||
str = "§r" + str;
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toClient(Item item) {
|
public static void toClient(Item item) {
|
||||||
@ -287,15 +275,15 @@ public class ItemRewriter {
|
|||||||
|
|
||||||
ListTag<StringTag> pages = tag.getListTag("pages", StringTag.class);
|
ListTag<StringTag> pages = tag.getListTag("pages", StringTag.class);
|
||||||
if (pages == null) {
|
if (pages == null) {
|
||||||
pages = new ListTag<>(Collections.singletonList(new StringTag(Protocol1_9To1_8.fixJson("").toString())));
|
pages = new ListTag<>(Collections.singletonList(new StringTag(ComponentUtil.emptyJsonComponent().toString())));
|
||||||
tag.put("pages", pages);
|
tag.put("pages", pages);
|
||||||
item.setTag(tag);
|
item.setTag(tag);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < pages.size(); i++) {
|
for (int i = 0; i < pages.size(); i++) {
|
||||||
StringTag page = pages.get(i);
|
final StringTag page = pages.get(i);
|
||||||
page.setValue(Protocol1_9To1_8.fixJson(page.getValue()).toString());
|
page.setValue(ComponentUtil.convertJson(page.getValue(), SerializerVersion.V1_8, SerializerVersion.V1_9).toString());
|
||||||
}
|
}
|
||||||
item.setTag(tag);
|
item.setTag(tag);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren