Class AdvancementKey
java.lang.Object
com.fren_gor.ultimateAdvancementAPI.util.AdvancementKey
- All Implemented Interfaces:
Comparable<AdvancementKey>
The
AdvancementKey
class represents a valid advancement namespaced key.
The namespaced keys represented by this class match the following pattern:
[a-z0-9_.-]{1,127}:[a-z0-9_.-/]{1,127}
.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a newAdvancementKey
from the specified NMSMinecraftKey
.AdvancementKey
(@NotNull String namespace, @NotNull String key) Creates a newAdvancementKey
with the provided namespace and key.Creates a newAdvancementKey
from the specifiedNamespacedKey
.AdvancementKey
(@NotNull Plugin plugin, @NotNull String key) Creates a newAdvancementKey
with the provided plugin's (lowercased) name as namespace and the specified key. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Checks whether the provided key is notnull
, not empty, and it's length is less or equals to 127.static void
checkNamespace
(String namespace) Checks whether the provided namespace is notnull
, not empty, and it's length is less or equals to 127.int
Compares thisAdvancementKey
to the provided one.boolean
static AdvancementKey
fromString
(@NotNull String string) Creates anAdvancementKey
from the provided string.getKey()
Gets the key of this namespaced key.Gets the namespace of this namespaced key.Gets the NMS wrapper of thisAdvancementKey
with the same namespace and key of this namespaced key.int
hashCode()
Gets aNamespacedKey
with the same namespace and key of this namespaced key.toString()
Returns a string representation of this namespaced key.
-
Field Details
-
VALID_ADVANCEMENT_KEY
Pattern every valid advancement key should match. -
VALID_NAMESPACE
Pattern every valid namespace should match. -
VALID_KEY
Pattern every valid key should match.
-
-
Constructor Details
-
AdvancementKey
Creates a newAdvancementKey
with the provided plugin's (lowercased) name as namespace and the specified key.- Parameters:
plugin
- The plugin.key
- The key. Must match the following pattern:[[a-z0-9_.-/]{1,127}
.
-
AdvancementKey
public AdvancementKey(@NotNull @NotNull String namespace, @NotNull @NotNull String key) throws IllegalKeyException Creates a newAdvancementKey
with the provided namespace and key.- Parameters:
namespace
- The namespace. Must match the following pattern:[[a-z0-9_.-]{1,127}
.key
- The key. Must match the following pattern:[[a-z0-9_.-/]{1,127}
.- Throws:
IllegalKeyException
- If the namespace or the key is not valid.
-
AdvancementKey
Creates a newAdvancementKey
from the specifiedNamespacedKey
.- Parameters:
key
- TheNamespacedKey
.
-
AdvancementKey
Creates a newAdvancementKey
from the specified NMSMinecraftKey
.- Parameters:
key
- TheMinecraftKey
.- Throws:
IllegalKeyException
- If the namespace or the key is not valid. SeeAdvancementKey(String, String)
.
-
-
Method Details
-
getNamespace
Gets the namespace of this namespaced key.- Returns:
- The namespace of this namespaced key.
-
getKey
Gets the key of this namespaced key.- Returns:
- The key of this namespaced key.
-
getNMSWrapper
Gets the NMS wrapper of thisAdvancementKey
with the same namespace and key of this namespaced key.- Returns:
- The NMS wrapper of this
AdvancementKey
-
toNamespacedKey
Gets aNamespacedKey
with the same namespace and key of this namespaced key.- Returns:
- This namespaced key as a
NamespacedKey
.
-
fromString
Creates anAdvancementKey
from the provided string.The provided string must be a valid namespace key, or an
IllegalKeyException
is thrown.- Parameters:
string
- The string.- Returns:
- An
AdvancementKey
from the string. - Throws:
IllegalKeyException
- If provided string is not a valid namespace key.
-
checkNamespace
public static void checkNamespace(String namespace) throws IllegalArgumentException, IllegalKeyException Checks whether the provided namespace is notnull
, not empty, and it's length is less or equals to 127.- Parameters:
namespace
- The string to validate.- Throws:
IllegalArgumentException
- If the provided string isnull
or empty.IllegalKeyException
- If the provided string is longer than 127 characters.
-
checkKey
Checks whether the provided key is notnull
, not empty, and it's length is less or equals to 127.- Parameters:
key
- The string to validate.- Throws:
IllegalArgumentException
- If the provided string isnull
or empty.IllegalKeyException
- If the provided string is longer than 127 characters.
-
compareTo
Compares thisAdvancementKey
to the provided one.- Specified by:
compareTo
in interfaceComparable<AdvancementKey>
- Parameters:
key
- The otherAdvancementKey
.- Returns:
- A negative integer, zero, or a positive integer as this key is less than, equal to, or greater than the specified one.
- Throws:
NullPointerException
- If the specified key is null
-
toString
Returns a string representation of this namespaced key. -
equals
-
hashCode
public int hashCode()
-