Write scoreboard objects using standard JSON serialization (#196)

This commit is contained in:
Kezz 2021-03-27 15:52:35 +00:00 committed by GitHub
parent 36813c6858
commit 156c6a31df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 14 deletions

View File

@ -38,7 +38,7 @@ public class ScoreboardObjectivePacket implements ComponentHoldingServerPacket {
writer.writeByte(mode);
if (mode == 0 || mode == 2) {
writer.writeComponentAsLegacy(objectiveValue);
writer.writeComponent(objectiveValue);
writer.writeVarInt(type.ordinal());
}
}

View File

@ -3,7 +3,6 @@ package net.minestom.server.utils.binary;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.minestom.server.MinecraftServer;
import net.minestom.server.adventure.AdventureSerializer;
import net.minestom.server.item.ItemStack;
@ -18,7 +17,6 @@ import org.jglrxavpok.hephaistos.nbt.NBTWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.UUID;
import java.util.function.Consumer;
@ -74,17 +72,6 @@ public class BinaryWriter extends OutputStream {
this.writeSizedString(AdventureSerializer.serialize(component));
}
/**
* Writes a component to the buffer as a sized string. This method uses
* {@link LegacyComponentSerializer} to convert the component into a string
* containing the legacy section signs.
*
* @param component the component
*/
public void writeComponentAsLegacy(@NotNull Component component) {
this.writeSizedString(LegacyComponentSerializer.legacySection().serialize(component));
}
/**
* Writes a single boolean to the buffer.
*