Class PermissionAPI

java.lang.Object
net.minecraftforge.server.permission.PermissionAPI

public final class PermissionAPI extends Object
  • Field Details

    • LOGGER

      private static final org.apache.logging.log4j.Logger LOGGER
    • activeHandler

      private static IPermissionHandler activeHandler
  • Constructor Details

    • PermissionAPI

      private PermissionAPI()
  • Method Details

    • getRegisteredNodes

      public static Collection<PermissionNode<?>> getRegisteredNodes()
    • getActivePermissionHandler

      @Nullable public static ResourceLocation getActivePermissionHandler()
      Returns:
      the Identifier of the currently active permission handler
    • getPermission

      public static <T> T getPermission(ServerPlayer player, PermissionNode<T> node, PermissionDynamicContext<?>... context)

      Queries a player's permission for a given node and contexts

      Warning: PermissionNodes must be registered using the PermissionGatherEvent.Nodes event before querying.

      Type Parameters:
      T - type of the queried PermissionNode
      Parameters:
      player - player for which you want to check permissions
      node - the PermissionNode for which you want to query
      context - optional array of PermissionDynamicContext, single entries will be ignored if they weren't registered to the node
      Returns:
      a value of type <T>, that the combination of Player and PermissionNode map to, defaults to the PermissionNodes default handler.
      Throws:
      UnregisteredPermissionException - when the PermissionNode wasn't registered properly
    • getOfflinePermission

      public static <T> T getOfflinePermission(UUID player, PermissionNode<T> node, PermissionDynamicContext<?>... context)
      Type Parameters:
      T - type of the queried PermissionNode
      Parameters:
      player - offline player for which you want to check permissions
      node - the PermissionNode for which you want to query
      context - optional array of PermissionDynamicContext, single entries will be ignored if they weren't registered to the node
      Returns:
      a value of type <T>, that the combination of Player and PermissionNode map to, defaults to the PermissionNodes default handler.
      Throws:
      UnregisteredPermissionException - when the PermissionNode wasn't registered properly
    • initializePermissionAPI

      public static void initializePermissionAPI()

      Helper method for internal use only!

      Initializes the active permission handler based on the users config.