static @Nullable TextColor fromCSSHexString(final @NotNull String string) {
    if (string.startsWith(HEX_PREFIX)) {
      final String hexString = string.substring(1);
      if (hexString.length() != 3 && hexString.length() != 6) {
        return null;
      }
      final int hex;
      try {
        hex = Integer.parseInt(hexString, 16);
      } catch (final NumberFormatException e) {
        return null;
      }

      if (hexString.length() == 6) {
        return color(hex);
      } else {
        final int red = (hex & 0xf00) >> 8 | (hex & 0xf00) >> 4;
        final int green = (hex & 0x0f0) >> 4 | (hex & 0x0f0);
        final int blue = (hex & 0x00f) << 4 | (hex & 0x00f);
        return color(red, green, blue);
      }
    }
    return null;
  }
Create a color from a CSS hex string ({@code #rrggbb} or {@code #rgb}).

@param string the hex string
@return a new text colour
@since 4.0.0
api/src/main/java/net/kyori/adventure/text/format/TextColor.java