diff --git a/api/src/main/java/com/xism4/sternalboard/SternalBoard.java b/api/src/main/java/com/xism4/sternalboard/SternalBoard.java index ee78cba..4447c3f 100644 --- a/api/src/main/java/com/xism4/sternalboard/SternalBoard.java +++ b/api/src/main/java/com/xism4/sternalboard/SternalBoard.java @@ -117,6 +117,11 @@ protected Object toMinecraftComponent(String line) throws Throwable { return Array.get(MESSAGE_FROM_STRING.invoke(line), 0); } + @Override + protected String serializeLine(String value) { + return value; + } + @Override protected String emptyLine() { return ""; diff --git a/api/src/main/java/com/xism4/sternalboard/SternalBoardHandler.java b/api/src/main/java/com/xism4/sternalboard/SternalBoardHandler.java index e73d1c5..407c3b8 100644 --- a/api/src/main/java/com/xism4/sternalboard/SternalBoardHandler.java +++ b/api/src/main/java/com/xism4/sternalboard/SternalBoardHandler.java @@ -432,6 +432,8 @@ public void delete() { protected abstract void sendLineChange(int score) throws Throwable; + protected abstract String serializeLine(T value); + protected abstract Object toMinecraftComponent(T value) throws Throwable; protected abstract T emptyLine(); @@ -584,7 +586,8 @@ private void setField(Object packet, Class fieldType, Object value, int count private void setComponentField(Object packet, T value, int count) throws Throwable { if (!VersionType.V1_13.isHigherOrEqual()) { - setField(packet, String.class, value != null ? value : "", count); + String line = value != null ? serializeLine(value) : ""; + setField(packet, String.class, line, count); return; } diff --git a/api/src/main/java/com/xism4/sternalboard/adventure/SternalBoard.java b/api/src/main/java/com/xism4/sternalboard/adventure/SternalBoard.java index ecb4f07..9d15632 100644 --- a/api/src/main/java/com/xism4/sternalboard/adventure/SternalBoard.java +++ b/api/src/main/java/com/xism4/sternalboard/adventure/SternalBoard.java @@ -65,8 +65,10 @@ protected Object toMinecraftComponent(Component component) throws Throwable { return EMPTY_COMPONENT; } + // If the server isn't running adventure natively, we convert the component to legacy text + // and then to a Minecraft chat component if (!ADVENTURE_SUPPORT) { - String legacy = LegacyComponentSerializer.legacySection().serialize(component); + String legacy = serializeLine(component); return Array.get(COMPONENT_METHOD.invoke(legacy), 0); } @@ -74,6 +76,11 @@ protected Object toMinecraftComponent(Component component) throws Throwable { return COMPONENT_METHOD.invoke(component); } + @Override + protected String serializeLine(Component value) { + return LegacyComponentSerializer.legacySection().serialize(value); + } + @Override protected Component emptyLine() { return Component.empty();