public String key() throws StringTagParseException {
    this.buffer.skipWhitespace();
    final char starChar = this.buffer.peek();
    try {
      if (starChar == Tokens.SINGLE_QUOTE || starChar == Tokens.DOUBLE_QUOTE) {
        return unescape(this.buffer.takeUntil(this.buffer.take()).toString());
      }

      final StringBuilder builder = new StringBuilder();
      while (this.buffer.hasMore()) {
        final char peek = this.buffer.peek();
        if (!Tokens.id(peek)) {
          if (this.acceptLegacy) {
            // In legacy format, a key is any non-colon character, with escapes allowed
            if (peek == Tokens.ESCAPE_MARKER) {
              this.buffer.take(); // skip
              continue;
            } else if (peek != Tokens.COMPOUND_KEY_TERMINATOR) {
              builder.append(this.buffer.take());
              continue;
            }
          }
          break;
        }
        builder.append(this.buffer.take());
      }
      return builder.toString();
    } finally {
      this.buffer.expect(Tokens.COMPOUND_KEY_TERMINATOR);
    }
  }
Similar to a list tag in syntax, but returning a single array tag rather than a list of tags.

@param elementType the indicator character for element type
@return array-typed tag
@throws StringTagParseException if the array was not properly terminated
nbt/src/main/java/net/kyori/adventure/nbt/TagStringReader.java