Package de.Keyle.MyPet.api.util
Class YamlScalar
java.lang.Object
de.Keyle.MyPet.api.util.YamlScalar
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 Summary
Modifier and TypeMethodDescriptionstatic StringsingleQuote(String value) Wrapsvalueas a YAML single-quoted scalar.static StringReversessingleQuote(String)whenvalueis wrapped in a matching pair of single quotes; otherwise returnsvalueunchanged.
-
Method Details
-
singleQuote
Wrapsvalueas a YAML single-quoted scalar. The only escape in that style is doubling a single quote.- Parameters:
value- the raw string- Returns:
valuewrapped in single quotes, embedded quotes doubled
-
unquote
ReversessingleQuote(String)whenvalueis wrapped in a matching pair of single quotes; otherwise returnsvalueunchanged. 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
valueif it was not quoted
-