Class YamlScalar

java.lang.Object
de.Keyle.MyPet.api.util.YamlScalar

public final class YamlScalar extends Object
Helpers for item strings that travel through YAML as a single-quoted scalar.

A modern component string such as . minecraft:lead[minecraft:custom_name={extra: [{bold: 1b}]}] contains ": ", "#" and other characters that SnakeYAML refuses inside a plain (unquoted) scalar. /petadmin info item therefore hands out the string already wrapped by singleQuote(String), so it pastes into config.yml / pet-config.yml as-is. ConfigItem calls unquote(String) first, so the same string also works where YAML is not involved (the Configurator's item fields, skilltree drop pools).

  • Method Details

    • singleQuote

      public static String singleQuote(String value)
      Wraps value as a YAML single-quoted scalar. The only escape in that style is doubling a single quote.
      Parameters:
      value - the raw string
      Returns:
      value wrapped in single quotes, embedded quotes doubled
    • unquote

      public static String unquote(String value)
      Reverses singleQuote(String) when value is wrapped in a matching pair of single quotes; otherwise returns value unchanged. Surrounding whitespace is not trimmed, so a plain material name or an already-unquoted string passes straight through.
      Parameters:
      value - the string as read from a config or editor field
      Returns:
      the unwrapped string, or value if it was not quoted