Class HytalePermissionsProvider

java.lang.Object
com.hypixel.hytale.server.core.util.io.BlockingDiskFile
com.hypixel.hytale.server.core.permissions.provider.HytalePermissionsProvider
All Implemented Interfaces:
PermissionProvider

public final class HytalePermissionsProvider extends BlockingDiskFile implements PermissionProvider
The basic vanilla handling of permissions using permissions.json.

This is never exposed anywhere - it's withheld and internal.

  • Field Details

  • Constructor Details

    • HytalePermissionsProvider

      public HytalePermissionsProvider()
      Default Constructor for a HytalePermissionsProvider instance.
    • HytalePermissionsProvider

      public HytalePermissionsProvider(@Nonnull Path path)
  • Method Details

    • resolveGroupName

      @Nonnull public static String resolveGroupName(@Nonnull String group)
      Resolves a group name, mapping legacy names to the new namespaced equivalents.
    • getName

      @Nonnull public String getName()
      Specified by:
      getName in interface PermissionProvider
      Returns:
      the name of the permission provider.
    • addUserPermissions

      public void addUserPermissions(@Nonnull UUID uuid, @Nonnull Set<String> permissions)
      Description copied from interface: PermissionProvider
      Called to add a set of permissions to a user.
      Specified by:
      addUserPermissions in interface PermissionProvider
      Parameters:
      uuid - The UUID of the user.
      permissions - The set of permissions to add.
    • removeUserPermissions

      public void removeUserPermissions(@Nonnull UUID uuid, @Nonnull Set<String> permissions)
      Description copied from interface: PermissionProvider
      Called to remove a set of permissions from a user.
      Specified by:
      removeUserPermissions in interface PermissionProvider
      Parameters:
      uuid - The UUID of the user.
      permissions - The set of permissions to remove.
    • getUserPermissions

      @Nonnull public Set<String> getUserPermissions(@Nonnull UUID uuid)
      Description copied from interface: PermissionProvider
      Called to get the set of permissions for a user.
      Specified by:
      getUserPermissions in interface PermissionProvider
      Parameters:
      uuid - The UUID of the user.
      Returns:
      the set of permissions for the user.
    • getUsersWithPermission

      @Nonnull public Set<UUID> getUsersWithPermission(@Nonnull String permission)
      Description copied from interface: PermissionProvider
      Finds the users that hold the permission as a grant of their own. A user who holds it through a group is not one of them, and neither is a user who holds it through a wildcard.

      This carries no default, because a provider that answers "nobody" when it means "I cannot tell" makes PermissionProvider.removeUserPermissionFromAll(String) report that it revoked a permission that the user still holds.

      Specified by:
      getUsersWithPermission in interface PermissionProvider
      Parameters:
      permission - The permission node.
      Returns:
      the users that were granted the permission.
    • addUserPermissions

      @Nonnull public Set<UUID> addUserPermissions(@Nonnull Collection<UUID> uuids, @Nonnull Set<String> permissions)
      Description copied from interface: PermissionProvider
      Adds the permissions to every user named. Override this to store the change once rather than once for each user. The default adds them one user at a time, so a failure part way through leaves the users before it changed and reports none of them.
      Specified by:
      addUserPermissions in interface PermissionProvider
      Parameters:
      uuids - The UUID of each user.
      permissions - The set of permissions to add.
      Returns:
      the users the permissions were added to, which leaves out the users that held them.
    • removeUserPermissionFromAll

      @Nonnull public Set<UUID> removeUserPermissionFromAll(@Nonnull String permission)
      Description copied from interface: PermissionProvider
      Takes 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.
      Specified by:
      removeUserPermissionFromAll in interface PermissionProvider
      Parameters:
      permission - The permission node.
      Returns:
      the users the permission was taken from.
    • addGroupPermissions

      public void addGroupPermissions(@Nonnull String group, @Nonnull Set<String> permissions)
      Description copied from interface: PermissionProvider
      Called to add a set of permissions to a group.
      Specified by:
      addGroupPermissions in interface PermissionProvider
      Parameters:
      group - The name of the group.
      permissions - The set of permissions to add.
    • removeGroupPermissions

      public void removeGroupPermissions(@Nonnull String group, @Nonnull Set<String> permissions)
      Description copied from interface: PermissionProvider
      Called to remove a set of permissions from a group.
      Specified by:
      removeGroupPermissions in interface PermissionProvider
      Parameters:
      group - The name of the group.
      permissions - The set of permissions to remove.
    • getGroupPermissions

      @Nonnull public Set<String> getGroupPermissions(@Nonnull String group)
      Description copied from interface: PermissionProvider
      Called to get the direct (non-inherited) set of permissions for a group.
      Specified by:
      getGroupPermissions in interface PermissionProvider
      Parameters:
      group - The name of the group.
      Returns:
      the set of permissions for the group.
    • getGroupParent

      @Nullable public String getGroupParent(@Nonnull String group)
      Specified by:
      getGroupParent in interface PermissionProvider
      Parameters:
      group - The name of the group.
      Returns:
      the parent group name, or null if this group has no parent.
    • getAllRegisteredGroups

      @Nonnull public Set<String> getAllRegisteredGroups()
      Specified by:
      getAllRegisteredGroups in interface PermissionProvider
      Returns:
      all group names known to this provider.
    • getEffectiveGroupPermissions

      @Nonnull public Set<String> getEffectiveGroupPermissions(@Nonnull String group)
      Description copied from interface: PermissionProvider
      Resolves the full set of permissions for a group, including inherited permissions from the parent chain. Implementations must protect against cycles.
      Specified by:
      getEffectiveGroupPermissions in interface PermissionProvider
      Parameters:
      group - The name of the group.
      Returns:
      the effective permission set (direct + inherited).
    • addUserToGroup

      public void addUserToGroup(@Nonnull UUID uuid, @Nonnull String group)
      Description copied from interface: PermissionProvider
      Called to add a user to a group.
      Specified by:
      addUserToGroup in interface PermissionProvider
      Parameters:
      uuid - The UUID of the user.
      group - The name of the group.
    • removeUserFromGroup

      public void removeUserFromGroup(@Nonnull UUID uuid, @Nonnull String group)
      Description copied from interface: PermissionProvider
      Called to remove a user from a group.
      Specified by:
      removeUserFromGroup in interface PermissionProvider
      Parameters:
      uuid - The UUID of the user.
      group - The name of the group.
    • getGroupsForUser

      @Nonnull public Set<String> getGroupsForUser(@Nonnull UUID uuid)
      Description copied from interface: PermissionProvider
      Called to get the set of groups a user is in.
      Specified by:
      getGroupsForUser in interface PermissionProvider
      Parameters:
      uuid - The UUID of the user.
      Returns:
      the set of groups the user is in.
    • setUserGroup

      public void setUserGroup(@Nonnull UUID uuid, @Nonnull String group)
      Description copied from interface: PermissionProvider
      Atomically replaces all groups for a user with the given single group.
      Specified by:
      setUserGroup in interface PermissionProvider
      Parameters:
      uuid - The UUID of the user.
      group - The group to set as the user's sole group.