Class Permission
java.lang.Object
fr.hytale.loader.permission.Permission
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 Summary
Modifier and TypeMethodDescriptionbooleanstatic PermissionforCommand(String namespace, String commandName) Creates a command permission.static PermissionforCommand(String namespace, String commandName, String subCommand) Creates a command permission with a sub-command.static PermissionfromNative(String nativePermission) Creates a permission from a native Hytale permission string.getNode()Gets the permission node.Gets the parent permission of this permission.inthashCode()static PermissionhytaleCommand(String commandName) Creates a Hytale native command permission.booleanisChildOf(Permission parent) Checks if this permission is a child of another permission.booleanisParentOf(Permission child) Checks if this permission is a parent of another permission.static PermissionCreates a permission from a permission node string.toNative()Converts this permission to a native Hytale permission string.toString()
-
Method Details
-
of
Creates a permission from a permission node string.- Parameters:
node- the permission node- Returns:
- a new Permission instance
-
fromNative
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 namespacecommandName- the command namesubCommand- the sub-command name- Returns:
- a new Permission instance
-
hytaleCommand
Creates a Hytale native command permission.Uses the "hytale.command.*" namespace.
- Parameters:
commandName- the command name- Returns:
- a new Permission instance
-
toNative
Converts this permission to a native Hytale permission string.- Returns:
- the permission node as a string
-
getNode
-
isChildOf
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
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
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
-
hashCode
-
toString
-