-
-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Description
Having minecraft as the default namespace in Key.key(String) is sometimes annoying to work with, especially when the Key is used outside of Minecraft concepts. While there are workarounds (e.g., parsing the string manually), it would be appreciated if the API provided a possibility to handle this more cleanly.
A Key factory/format utility would also be useful in some cases, particularly since Key.key(String, char) allows for some more custom formatting. Something like that:
KeyFormat MC_KEYS = keyFormat().fallbackNamespace("minecraft").separator(':').build(); // Practically providing the default static `Key` methods in instance form
KeyFormat MY_KEYS = keyFormat("fallback", '>');
boolean isFineKey = MY_KEYS.parseable("minecraft:cat"); // false
Key mcCat = MY_KEYS.key("minecraft>cat"); // Key.key("cat")
Key fbDog = MY_KEYS.key("dog"); // Key.key("fallback:dog")
Key castleKey = Key.key("fallback:castle"); // MY_KEY.key("castle")
String castleMyStr = MY_KEYS.asString(castleKey); // "fallback>castle"
String castleMyMinStr = MY_KEYS.asMinimalString(castleKey); // "castle"Key#parseable is also missing an alternative with char as separator.
masmc05 and davidmayr