Package com.viaversion.viaversion.util
Class Key
java.lang.Object
com.viaversion.viaversion.util.Key
Represents a Minecraft Identifier/ResourceLocation.
Internally split into CustomKey and MinecraftKey to reduce data held
and keep the runtime/allocation cost of original() and Object.toString() minimal.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanstatic booleanabstract booleanstatic booleanabstract StringReturns the identifier in a minimized form.abstract Stringstatic Stringstatic Stringnamespaced(String identifier) static KeyCreates a new key from the given identifier string, with or without an explicit namespace.static KeyCreates a new key with the given namespace and path.static KeyCreates a new key with the given path and the default namespace "minecraft".abstract Stringoriginal()Returns the unmodified original identifier, possbily without an explicit namespace.abstract Stringpath()static StringstripMinecraftNamespace(String identifier) static StringstripNamespace(String identifier) static @Nullable KeyTries to create a new key from the given identifier string, with or without an explicit namespace.withNamespace(String namespace)
-
Constructor Details
-
Key
public Key()
-
-
Method Details
-
of
Creates a new key with the given namespace and path.- Parameters:
namespace- the namespace of the identifierpath- the path of the identifier- Returns:
- a new key with the given namespace and path
-
ofPath
Creates a new key with the given path and the default namespace "minecraft".- Parameters:
path- the path of the identifier- Returns:
- a new key with the given path and the default namespace
-
of
Creates a new key from the given identifier string, with or without an explicit namespace.- Parameters:
identifier- the identifier string- Returns:
- a new key with the given identifier
-
tryParse
Tries to create a new key from the given identifier string, with or without an explicit namespace.- Parameters:
identifier- the identifier string- Returns:
- a new key with the given identifier, or null if the identifier is invalid
-
namespace
-
path
-
original
Returns the unmodified original identifier, possbily without an explicit namespace.- Returns:
- the original identifier, possibly without an explicit namespace
-
minimized
Returns the identifier in a minimized form. If the namespace is "minecraft", it will return just the path.- Returns:
- the identifier in a minimized form
-
hasMinecraftNamespace
public abstract boolean hasMinecraftNamespace() -
withNamespace
-
withPath
-
equals
-
stripNamespace
-
namespace
-
stripMinecraftNamespace
-
equals
-
namespaced
-
isValid
-