Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Properly format book data
Dieser Commit ist enthalten in:
Ursprung
3f5362a857
Commit
49b20e37cb
@ -186,6 +186,41 @@ public class ItemRewriter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void rewriteBookToServer(Item item) {
|
||||
short id = item.getId();
|
||||
if (id != 387) {
|
||||
return;
|
||||
}
|
||||
CompoundTag tag = item.getTag();
|
||||
ListTag pages = tag.get("pages");
|
||||
if (pages == null) { // is this even possible?
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < pages.size(); i++) {
|
||||
Tag pageTag = pages.get(i);
|
||||
if (!(pageTag instanceof StringTag)) {
|
||||
continue;
|
||||
}
|
||||
StringTag stag = (StringTag) pageTag;
|
||||
String value = stag.getValue();
|
||||
if (value.replaceAll(" ", "").isEmpty()) {
|
||||
value = "\"" + fixBookSpaceChars(value) + "\"";
|
||||
} else {
|
||||
value = fixBookSpaceChars(value);
|
||||
}
|
||||
stag.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
private static String fixBookSpaceChars(String str) {
|
||||
if (!str.startsWith(" ")) {
|
||||
return str;
|
||||
}
|
||||
// hacky but it works :)
|
||||
str = "\u00A7r" + str;
|
||||
return str;
|
||||
}
|
||||
|
||||
public static void toClient(Item item) {
|
||||
if (item != null) {
|
||||
|
@ -500,8 +500,9 @@ public class PlayerPackets {
|
||||
String name = wrapper.get(Type.STRING, 0);
|
||||
if (name.equalsIgnoreCase("MC|BSign")) {
|
||||
Item item = wrapper.passthrough(Type.ITEM);
|
||||
if (item != null) {
|
||||
if (item != null) { //TODO: HERE
|
||||
item.setId((short) 387); // Written Book
|
||||
ItemRewriter.rewriteBookToServer(item);
|
||||
}
|
||||
}
|
||||
if (name.equalsIgnoreCase("MC|AutoCmd")) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren