Contents
- Description
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- get()
- registerPermission(String)
- registerPermission(String, String...)
- getRegisteredPermissions()
- refreshVirtualGroups()
- reload()
- addProvider(PermissionProvider)
- removeProvider(PermissionProvider)
- getProviders()
- getFirstPermissionProvider()
- areProvidersTampered()
- addUserPermission(UUID, Set)
- addUserPermission(Collection, Set)
- removeUserPermissionFromAll(String)
- hasUserGrant(UUID, String)
- removeUserPermission(UUID, Set)
- getUsersWithPermission(String)
- addGroupPermission(String, Set)
- removeGroupPermission(String, Set)
- addUserToGroup(UUID, String)
- removeUserFromGroup(UUID, String)
- setUserGroup(UUID, String)
- setVirtualGroups(Map)
- getVirtualGroups()
- getGroupsForUser(UUID)
- getAllRegisteredGroups()
- hasPermission(UUID, String)
- hasPermission(UUID, String, boolean)
- hasPermission(UUID, PermissionQuery)
- hasPermission(UUID, PermissionQuery, boolean)
- hasPermission(Set, String)
- hasPermission(Set, PermissionQuery)
Class PermissionsModule
java.lang.Object
com.hypixel.hytale.server.core.plugin.PluginBase
com.hypixel.hytale.server.core.plugin.JavaPlugin
com.hypixel.hytale.server.core.permissions.PermissionsModule
- All Implemented Interfaces:
CommandOwner
A module responsible for managing permissions within the server.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PluginManifestThe plugin manifest for this module.static final StringThe node that grants every permission.static final StringThe node that denies every permission, which beats every grant.Fields inherited from class PluginBase
METRICS_REGISTRY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGroupPermission(String group, Set<String> permissions) Called to add the given set of permissions to the group with the given name.voidaddProvider(PermissionProvider permissionProvider) Called to add a newPermissionProviderto the list of providers.addUserPermission(Collection<UUID> uuids, Set<String> permissions) Called to add the given set of permissions to every user named, as one change.voidaddUserPermission(UUID uuid, Set<String> permissions) Called to add the given set of permissions to the user with the given UUID.voidaddUserToGroup(UUID uuid, String group) Called to add the user with the given UUID to the group with the given name.booleanstatic PermissionsModuleget()getGroupsForUser(UUID uuid) Called to get all groups for a user with the given UUID.getUsersWithPermission(String permission) Finds the users that hold the permission as a grant of their own, across every provider.static BooleanhasPermission(Set<String> nodes, PermissionQuery query) static BooleanhasPermission(Set<String> nodes, String id) "Deny wins" evaluation of a single permission set.booleanhasPermission(UUID uuid, PermissionQuery query) booleanhasPermission(UUID uuid, PermissionQuery query, boolean def) booleanhasPermission(UUID uuid, String id) Determines whether the given user has the specified permission.booleanhasPermission(UUID uuid, String id, boolean def) Full resolution order (deny-wins within each layer, first definitive result wins): User direct permissions Group direct permissions (for each group the user belongs to) Virtual group permissions (for each group the user belongs to) Parent group permissions (a bounded walk up the inheritance chain, which decides nothing past its bound) Default valuebooleanhasUserGrant(UUID uuid, String permission) Determines whether the user holds the permission as a grant of their own, on any provider.voidRebuilds virtual groups from command permissions and statically registered permissions.static voidregisterPermission(String permission) Registers a permission node without any group associations.static voidregisterPermission(String permission, String... groups) Registers a permission node and associates it with one or more virtual groups.voidreload()Reloads permissions.json from disk and rebuilds virtual groups.voidremoveGroupPermission(String group, Set<String> permissions) Called to remove the given set of permissions from the group with the given name.voidremoveProvider(PermissionProvider provider) Called to remove aPermissionProviderfrom the list of providers.voidremoveUserFromGroup(UUID uuid, String group) Called to remove the user with the given UUID from the group with the given name.voidremoveUserPermission(UUID uuid, Set<String> permissions) Called to remove the given set of permissions from the user with the given UUID.removeUserPermissionFromAll(String permission) Called to take the permission back from every user that holds it as a grant of their own, as one change.voidsetUserGroup(UUID uuid, String group) Atomically replaces all groups for a user with the given single group.voidsetVirtualGroups(Map<String, Set<String>> virtualGroups) Called to set the virtual permission groups.Methods inherited from class JavaPlugin
getClassLoader, getFile, getTypeMethods inherited from class PluginBase
getAssetRegistry, getBasePermission, getChunkStoreRegistry, getClientFeatureRegistry, getCodecRegistry, getCodecRegistry, getCodecRegistry, getCommandRegistry, getDataDirectory, getEntityRegistry, getEntityStoreRegistry, getEventRegistry, getIdentifier, getLogger, getManifest, getName, getState, getTaskRegistry, isDisabled, isEnabled, preLoad
-
Field Details
-
ROOT
-
ROOT_DENY
The node that denies every permission, which beats every grant.- See Also:
-
MANIFEST
The plugin manifest for this module.
-
-
Constructor Details
-
PermissionsModule
Default Constructor for aPermissionsModuleinstance.- Parameters:
init- The plugin initialization step for this plugin.
-
-
Method Details
-
get
- Returns:
- the singleton instance of the
PermissionsModulemodule.
-
registerPermission
Registers a permission node without any group associations. The node will appear ingetRegisteredPermissions()as a known node. -
registerPermission
-
getRegisteredPermissions
- Returns:
- all permission nodes that have been registered via
registerPermission(String).
-
refreshVirtualGroups
public void refreshVirtualGroups()Rebuilds virtual groups from command permissions and statically registered permissions. -
reload
public void reload()Reloads permissions.json from disk and rebuilds virtual groups. -
addProvider
Called to add a newPermissionProviderto the list of providers.- Parameters:
permissionProvider- The permission provider to add.
-
removeProvider
Called to remove aPermissionProviderfrom the list of providers.- Parameters:
provider- The permission provider to remove.
-
getProviders
- Returns:
- a list of all registered
PermissionProviderinstances.
-
getFirstPermissionProvider
- Returns:
- the first registered
PermissionProviderinstance.
-
areProvidersTampered
public boolean areProvidersTampered()- Returns:
- true if the providers list has been modified from its default state.
-
addUserPermission
-
addUserPermission
@Nonnull public Set<UUID> addUserPermission(@Nonnull Collection<UUID> uuids, @Nonnull Set<String> permissions) Called to add the given set of permissions to every user named, as one change.- Parameters:
uuids- TheUUIDof each user.permissions- The set of permissions to add.- Returns:
- the users the permissions were added to.
-
removeUserPermissionFromAll
Called to take the permission back from every user that holds it as a grant of their own, as one change. A user who holds it through a group keeps it.- Parameters:
permission- The permission node.- Returns:
- the users the permission was taken from.
-
hasUserGrant
Determines whether the user holds the permission as a grant of their own, on any provider. A user who holds it through a group or a wildcard does not hold it as a grant.- Parameters:
uuid- TheUUIDof the user.permission- The permission node.- Returns:
- true if the user was granted the permission.
-
removeUserPermission
-
getUsersWithPermission
Finds the users that hold the permission as a grant of their own, across every provider. A user who holds it through a group is not one of them.- Parameters:
permission- The permission node.- Returns:
- the users that were granted the permission.
-
addGroupPermission
-
removeGroupPermission
-
addUserToGroup
-
removeUserFromGroup
-
setUserGroup
-
setVirtualGroups
-
getVirtualGroups
-
getGroupsForUser
-
getAllRegisteredGroups
-
hasPermission
-
hasPermission
Full resolution order (deny-wins within each layer, first definitive result wins):- User direct permissions
- Group direct permissions (for each group the user belongs to)
- Virtual group permissions (for each group the user belongs to)
- Parent group permissions (a bounded walk up the inheritance chain, which decides nothing past its bound)
- Default value
-
hasPermission
- Parameters:
uuid- The UUID of the user.query- The lookup for the permission, fromPermissionQuery.of(String).- Returns:
- true if the user has the permission.
- See Also:
-
hasPermission
- Parameters:
uuid- The UUID of the user.query- The lookup for the permission, fromPermissionQuery.of(String).def- The default value to return if nothing decides.- Returns:
- true if the user has the permission.
- See Also:
-
hasPermission
"Deny wins" evaluation of a single permission set.-*root deny → false- exact deny
-id→ false - exact grant
id→ true - deny wildcards (most specific → least specific)
*root grant → true- grant wildcards (least specific → most specific)
- null (unset)
-
hasPermission
@Nullable public static Boolean hasPermission(@Nullable Set<String> nodes, @Nonnull PermissionQuery query) - See Also:
-