Class Permission

java.lang.Object
fr.hytale.loader.permission.Permission

public class Permission extends Object
Represents a permission node in HytaleLoader.

Permissions are used to control access to commands and features. This class provides a wrapper around Hytale's native String-based permission system.

Usage Examples:

// Create a permission
Permission adminPerm = Permission.of("myplugin.admin");

// Check if player has permission
if (player.hasPermission(adminPerm)) {
    // Player has admin permission
}

// Create from native Hytale permission
Permission cmdPerm = Permission.fromNative(HytalePermissions.fromCommand("gamemode"));

// Convert to native
String nativePerm = adminPerm.toNative();
Since:
1.0.3
Version:
1.0.4
Author:
HytaleLoader
  • Method Details

    • of

      @Nonnull public static Permission of(@Nonnull String node)
      Creates a permission from a permission node string.
      Parameters:
      node - the permission node
      Returns:
      a new Permission instance
    • fromNative

      @Nonnull public static Permission fromNative(@Nonnull String nativePermission)
      Creates a permission from a native Hytale permission string.
      Parameters:
      nativePermission - the native Hytale permission
      Returns:
      a new Permission instance
    • forCommand

      @Nonnull public static Permission forCommand(@Nonnull String namespace, @Nonnull String commandName)
      Creates a command permission.

      This follows the Hytale convention of "namespace.command.commandname".

      Parameters:
      namespace - the plugin namespace (e.g., "myplugin")
      commandName - the command name
      Returns:
      a new Permission instance
    • forCommand

      @Nonnull public static Permission forCommand(@Nonnull String namespace, @Nonnull String commandName, @Nonnull String subCommand)
      Creates a command permission with a sub-command.
      Parameters:
      namespace - the plugin namespace
      commandName - the command name
      subCommand - the sub-command name
      Returns:
      a new Permission instance
    • hytaleCommand

      @Nonnull public static Permission hytaleCommand(@Nonnull String commandName)
      Creates a Hytale native command permission.

      Uses the "hytale.command.*" namespace.

      Parameters:
      commandName - the command name
      Returns:
      a new Permission instance
    • toNative

      @Nonnull public String toNative()
      Converts this permission to a native Hytale permission string.
      Returns:
      the permission node as a string
    • getNode

      @Nonnull public String getNode()
      Gets the permission node.
      Returns:
      the permission node string
    • isChildOf

      public boolean isChildOf(@Nonnull Permission parent)
      Checks if this permission is a child of another permission.

      For example, "myplugin.admin.edit" is a child of "myplugin.admin".

      Parameters:
      parent - the potential parent permission
      Returns:
      true if this permission is a child of the parent
    • isParentOf

      public boolean isParentOf(@Nonnull Permission child)
      Checks if this permission is a parent of another permission.
      Parameters:
      child - the potential child permission
      Returns:
      true if this permission is a parent of the child
    • getParent

      public Permission getParent()
      Gets the parent permission of this permission.

      For example, the parent of "myplugin.admin.edit" is "myplugin.admin". Returns null if this permission has no parent (only one segment).

      Returns:
      the parent permission, or null if no parent exists
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object