Class DatPermissions

java.lang.Object
com.datdeveloper.datmoddingapi.permissions.DatPermissions

public class DatPermissions extends Object
A utility class for checking permissions
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<net.minecraft.network.chat.Component>
    Empty Component literal
    static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Integer>
    Integer literal 0
    static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean>
    Player has permission level Admin
    static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean>
    Player has permission level All
    static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean>
    Player has permission level Mod
    static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean>
    Player has permission level Op
    static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean>
    Player has permission level Owner
    static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<String>
    Empty String literal
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>
    booleanNodeBuilder(String modId, String node, net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean> resolver)
    A shortcut to build a boolean node
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<net.minecraft.network.chat.Component>
    componentNodeBuilder(String modId, String node, net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<net.minecraft.network.chat.Component> resolver)
    A shortcut to build a component node
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>
    Create a boolean node that defaults to being available for admins
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>
    Create a boolean node that defaults to being available for all players
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<net.minecraft.network.chat.Component>
    Create a component node that defaults to the given value
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<net.minecraft.network.chat.Component>
    createComponentLiteralNode(String modId, String node, net.minecraft.network.chat.Component literal)
    Create a component node that defaults to the given value
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<net.minecraft.network.chat.Component>
    Create a component node that defaults to empty
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<String>
    Create a string node that defaults to empty
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Integer>
    createIntegerLiteralNode(String modId, String node, int literal)
    Create an integer node that defaults to the given value
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>
    createModNode(String modId, String node)
    Create a boolean node that defaults to being available for moderators
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>
    createOpNode(String modId, String node)
    Create a boolean node that defaults to being available for ops
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>
    Create a boolean node that defaults to being available for owners
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<String>
    createStringLiteralNode(String modId, String node, String literal)
    Create a string node that defaults to the given value
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Integer>
    Create an integer node that defaults to 0
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<net.minecraft.network.chat.Component>
    Build a component resolver that returns a literal component
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<net.minecraft.network.chat.Component>
    getComponentLiteralResolver(net.minecraft.network.chat.Component literal)
    Build a component resolver that returns a literal component
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Integer>
    Build an integer resolver that returns a constant number
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<String>
    Build a string resolver that returns a constant string
    static boolean
    hasAllPermissions(net.minecraft.commands.CommandSource source, net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>... permissionNodes)
    Checks if the given CommandSource has all the given permission
    static Predicate<net.minecraft.commands.CommandSourceStack>
    hasAllPermissions(net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>... nodes)
    Generate a predicate that checks the CommandSourceStack has all the given permissions
    static boolean
    hasAnyPermissions(net.minecraft.commands.CommandSource source, net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>... permissionNodes)
    Checks if the given CommandSource has any of the given permission
    static Predicate<net.minecraft.commands.CommandSourceStack>
    hasAnyPermissions(net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>... nodes)
    Generate a predicate that checks the CommandSourceStack has any of the given permissions
    static boolean
    hasPermission(net.minecraft.commands.CommandSource source, net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean> permissionNode)
    Checks if the given CommandSource has the given permission
    static Predicate<net.minecraft.commands.CommandSourceStack>
    hasPermission(net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean> node)
    Generate a predicate that checks the CommandSourceStack has the given permission
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Integer>
    integerNodeBuilder(String modId, String node, net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Integer> resolver)
    A shortcut to build an integer node
    static net.neoforged.neoforge.server.permission.nodes.PermissionNode<String>
    stringNodeBuilder(String modId, String node, net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<String> resolver)
    A shortcut to build a string node

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PLAYER_OWNER_RESOLVER

      public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean> PLAYER_OWNER_RESOLVER
      Player has permission level Owner
    • PLAYER_ADMIN_RESOLVER

      public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean> PLAYER_ADMIN_RESOLVER
      Player has permission level Admin
    • PLAYER_OP_RESOLVER

      public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean> PLAYER_OP_RESOLVER
      Player has permission level Op
    • PLAYER_MOD_RESOLVER

      public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean> PLAYER_MOD_RESOLVER
      Player has permission level Mod
    • PLAYER_ALL_RESOLVER

      public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean> PLAYER_ALL_RESOLVER
      Player has permission level All
    • INTEGER_ZERO_RESOLVER

      public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Integer> INTEGER_ZERO_RESOLVER
      Integer literal 0
    • STRING_EMPTY_RESOLVER

      public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<String> STRING_EMPTY_RESOLVER
      Empty String literal
    • COMPONENT_EMPTY_RESOLVER

      public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<net.minecraft.network.chat.Component> COMPONENT_EMPTY_RESOLVER
      Empty Component literal
  • Method Details

    • getIntegerLiteralResolver

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Integer> getIntegerLiteralResolver(int literal)
      Build an integer resolver that returns a constant number
      Parameters:
      literal - The constant for the resolver
      Returns:
      A permission resolver that returns the given constant
    • getStringLiteralResolver

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<String> getStringLiteralResolver(String literal)
      Build a string resolver that returns a constant string
      Parameters:
      literal - The constant for the resolver
      Returns:
      A permission resolver that returns the given constant
    • getComponentLiteralResolver

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<net.minecraft.network.chat.Component> getComponentLiteralResolver(net.minecraft.network.chat.Component literal)
      Build a component resolver that returns a literal component
      Parameters:
      literal - The component for the resolver to return
      Returns:
      A permission resolver that returns the given component
    • getComponentLiteralResolver

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<net.minecraft.network.chat.Component> getComponentLiteralResolver(String literal)
      Build a component resolver that returns a literal component
      Parameters:
      literal - The constant for the resolver
      Returns:
      A permission resolver that returns the given string as a component
    • booleanNodeBuilder

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean> booleanNodeBuilder(String modId, String node, net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean> resolver)
      A shortcut to build a boolean node
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      resolver - The default resolver to use for the node
      Returns:
      A new boolean permission node
    • createBasicNode

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean> createBasicNode(String modId, String node)
      Create a boolean node that defaults to being available for all players
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      Returns:
      A boolean node for players
    • createModNode

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean> createModNode(String modId, String node)
      Create a boolean node that defaults to being available for moderators
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      Returns:
      A boolean node for moderators
    • createOpNode

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean> createOpNode(String modId, String node)
      Create a boolean node that defaults to being available for ops
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      Returns:
      A boolean node for ops
    • createAdminNode

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean> createAdminNode(String modId, String node)
      Create a boolean node that defaults to being available for admins
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      Returns:
      A boolean node for admins
    • createOwnerNode

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean> createOwnerNode(String modId, String node)
      Create a boolean node that defaults to being available for owners
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      Returns:
      A boolean node for owners
    • integerNodeBuilder

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Integer> integerNodeBuilder(String modId, String node, net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Integer> resolver)
      A shortcut to build an integer node
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      resolver - The default resolver to use for the node
      Returns:
      A new integer permission node
    • createZeroNode

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Integer> createZeroNode(String modId, String node)
      Create an integer node that defaults to 0
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      Returns:
      An integer node that defaults to 0
    • createIntegerLiteralNode

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<Integer> createIntegerLiteralNode(String modId, String node, int literal)
      Create an integer node that defaults to the given value
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      literal - the default value of the node
      Returns:
      An integer node that defaults to the given value
    • stringNodeBuilder

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<String> stringNodeBuilder(String modId, String node, net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<String> resolver)
      A shortcut to build a string node
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      resolver - The default resolver to use for the node
      Returns:
      A new integer permission node
    • createEmptyStringNode

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<String> createEmptyStringNode(String modId, String node)
      Create a string node that defaults to empty
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      Returns:
      A string node that defaults to empty
    • createStringLiteralNode

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<String> createStringLiteralNode(String modId, String node, String literal)
      Create a string node that defaults to the given value
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      literal - the default value of the node
      Returns:
      A component node that defaults to the given value
    • componentNodeBuilder

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<net.minecraft.network.chat.Component> componentNodeBuilder(String modId, String node, net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<net.minecraft.network.chat.Component> resolver)
      A shortcut to build a component node
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      resolver - The default resolver to use for the node
      Returns:
      A new integer permission node
    • createEmptyComponentNode

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<net.minecraft.network.chat.Component> createEmptyComponentNode(String modId, String node)
      Create a component node that defaults to empty
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      Returns:
      A string node that defaults to empty
    • createComponentLiteralNode

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<net.minecraft.network.chat.Component> createComponentLiteralNode(String modId, String node, net.minecraft.network.chat.Component literal)
      Create a component node that defaults to the given value
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      literal - the default value of the node
      Returns:
      A component node that defaults to the given value
    • createComponentLiteralNode

      public static net.neoforged.neoforge.server.permission.nodes.PermissionNode<net.minecraft.network.chat.Component> createComponentLiteralNode(String modId, String node, String literal)
      Create a component node that defaults to the given value
      Parameters:
      modId - The modId of the mod the node belongs to
      node - The identifier of the node
      literal - the default value of the node
      Returns:
      A component node that defaults to the given value
    • hasPermission

      public static boolean hasPermission(net.minecraft.commands.CommandSource source, net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean> permissionNode)
      Checks if the given CommandSource has the given permission
      Parameters:
      source - The CommandSource being tested
      permissionNode - The permission node to test
      Returns:
      true if the CommandSource has permission
    • hasAnyPermissions

      @SafeVarargs public static boolean hasAnyPermissions(net.minecraft.commands.CommandSource source, net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>... permissionNodes)
      Checks if the given CommandSource has any of the given permission
      Parameters:
      source - The CommandSource being tested
      permissionNodes - The permission nodes to test
      Returns:
      true if the CommandSource has any of the given permissions
    • hasAllPermissions

      @SafeVarargs public static boolean hasAllPermissions(net.minecraft.commands.CommandSource source, net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>... permissionNodes)
      Checks if the given CommandSource has all the given permission
      Parameters:
      source - The CommandSource being tested
      permissionNodes - The permission nodes to test
      Returns:
      true if the CommandSource has all the given permissions
    • hasPermission

      public static Predicate<net.minecraft.commands.CommandSourceStack> hasPermission(net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean> node)
      Generate a predicate that checks the CommandSourceStack has the given permission
      Parameters:
      node - The permission node to check
      Returns:
      A predicate that checks for the given permission node
    • hasAnyPermissions

      @SafeVarargs public static Predicate<net.minecraft.commands.CommandSourceStack> hasAnyPermissions(net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>... nodes)
      Generate a predicate that checks the CommandSourceStack has any of the given permissions
      Parameters:
      nodes - The permission nodes to check
      Returns:
      A predicate that checks for any of the given permission nodes
    • hasAllPermissions

      @SafeVarargs public static Predicate<net.minecraft.commands.CommandSourceStack> hasAllPermissions(net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean>... nodes)
      Generate a predicate that checks the CommandSourceStack has all the given permissions
      Parameters:
      nodes - The permission nodes to check
      Returns:
      A predicate that checks for all the given permission nodes