Package org.bukkit

Class NamespacedKey


  • public final class NamespacedKey
    extends Object
    Represents a String based key which consists of two components - a namespace and a key. Namespaces may only contain lowercase alphanumeric characters, periods, underscores, and hyphens.

    Keys may only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.

    • Field Detail

      • BUKKIT

        public static final String BUKKIT
        The namespace representing all keys generated by Bukkit for backwards compatibility measures.
        See Also:
        Constant Field Values
    • Constructor Detail

      • NamespacedKey

        @Deprecated
        public NamespacedKey​(@NotNull
                             String namespace,
                             @NotNull
                             String key)
        Deprecated.
        should never be used by plugins, for internal use only!!
        Create a key in a specific namespace.
        Parameters:
        namespace - namespace
        key - key
      • NamespacedKey

        public NamespacedKey​(@NotNull
                             Plugin plugin,
                             @NotNull
                             String key)
        Create a key in the plugin's namespace.

        Namespaces may only contain lowercase alphanumeric characters, periods, underscores, and hyphens.

        Keys may only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.

        Parameters:
        plugin - the plugin to use for the namespace
        key - the key to create
    • Method Detail

      • getNamespace

        @NotNull
        public String getNamespace()
      • getKey

        @NotNull
        public String getKey()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • randomKey

        @Deprecated
        @NotNull
        public static NamespacedKey randomKey()
        Deprecated.
        should never be used by plugins, for internal use only!!
        Return a new random key in the BUKKIT namespace.
        Returns:
        new key
      • minecraft

        @NotNull
        public static NamespacedKey minecraft​(@NotNull
                                              String key)
        Get a key in the Minecraft namespace.
        Parameters:
        key - the key to use
        Returns:
        new key in the Minecraft namespace