public TagStringWriter writeTag(final BinaryTag tag) throws IOException {
    final BinaryTagType<?> type = tag.type();
    if (type == BinaryTagTypes.COMPOUND) {
      return this.writeCompound((CompoundBinaryTag) tag);
    } else if (type == BinaryTagTypes.LIST) {
      return this.writeList((ListBinaryTag) tag);
    } else if (type == BinaryTagTypes.BYTE_ARRAY) {
      return this.writeByteArray((ByteArrayBinaryTag) tag);
    } else if (type == BinaryTagTypes.INT_ARRAY) {
      return this.writeIntArray((IntArrayBinaryTag) tag);
    } else if (type == BinaryTagTypes.LONG_ARRAY) {
      return this.writeLongArray((LongArrayBinaryTag) tag);
    } else if (type == BinaryTagTypes.STRING) {
      return this.value(((StringBinaryTag) tag).value(), Tokens.EOF);
    } else if (type == BinaryTagTypes.BYTE) {
      return this.value(Byte.toString(((ByteBinaryTag) tag).value()), Tokens.TYPE_BYTE);
    } else if (type == BinaryTagTypes.SHORT) {
      return this.value(Short.toString(((ShortBinaryTag) tag).value()), Tokens.TYPE_SHORT);
    } else if (type == BinaryTagTypes.INT) {
      return this.value(Integer.toString(((IntBinaryTag) tag).value()), Tokens.TYPE_INT);
    } else if (type == BinaryTagTypes.LONG) {
      return this.value(Long.toString(((LongBinaryTag) tag).value()), Character.toUpperCase(Tokens.TYPE_LONG)); // special-case
    } else if (type == BinaryTagTypes.FLOAT) {
      return this.value(Float.toString(((FloatBinaryTag) tag).value()), Tokens.TYPE_FLOAT);
    } else if (type == BinaryTagTypes.DOUBLE) {
      return this.value(Double.toString(((DoubleBinaryTag) tag).value()), Tokens.TYPE_DOUBLE);
    } else {
      throw new IOException("Unknown tag type: " + type);
      // unknown!
    }
  }
Whether a {@link Tokens#VALUE_SEPARATOR} needs to be printed before the beginning of the next object.
nbt/src/main/java/net/kyori/adventure/nbt/TagStringWriter.java