Class DatPermissions
java.lang.Object
com.datdeveloper.datmoddingapi.permissions.DatPermissions
A utility class for checking permissions
-
Field Summary
Modifier and TypeFieldDescriptionstatic final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver
<net.minecraft.network.chat.Component> Empty Component literalstatic final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver
<Integer> Integer literal 0static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver
<Boolean> Player has permission level Adminstatic final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver
<Boolean> Player has permission level Allstatic final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver
<Boolean> Player has permission level Modstatic final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver
<Boolean> Player has permission level Opstatic final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver
<Boolean> Player has permission level Ownerstatic final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver
<String> Empty String literal -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 nodestatic 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 nodestatic net.neoforged.neoforge.server.permission.nodes.PermissionNode
<Boolean> createAdminNode
(String modId, String node) Create a boolean node that defaults to being available for adminsstatic net.neoforged.neoforge.server.permission.nodes.PermissionNode
<Boolean> createBasicNode
(String modId, String node) Create a boolean node that defaults to being available for all playersstatic 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 valuestatic 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 valuestatic net.neoforged.neoforge.server.permission.nodes.PermissionNode
<net.minecraft.network.chat.Component> createEmptyComponentNode
(String modId, String node) Create a component node that defaults to emptystatic net.neoforged.neoforge.server.permission.nodes.PermissionNode
<String> createEmptyStringNode
(String modId, String node) Create a string node that defaults to emptystatic net.neoforged.neoforge.server.permission.nodes.PermissionNode
<Integer> createIntegerLiteralNode
(String modId, String node, int literal) Create an integer node that defaults to the given valuestatic net.neoforged.neoforge.server.permission.nodes.PermissionNode
<Boolean> createModNode
(String modId, String node) Create a boolean node that defaults to being available for moderatorsstatic net.neoforged.neoforge.server.permission.nodes.PermissionNode
<Boolean> createOpNode
(String modId, String node) Create a boolean node that defaults to being available for opsstatic net.neoforged.neoforge.server.permission.nodes.PermissionNode
<Boolean> createOwnerNode
(String modId, String node) Create a boolean node that defaults to being available for ownersstatic net.neoforged.neoforge.server.permission.nodes.PermissionNode
<String> createStringLiteralNode
(String modId, String node, String literal) Create a string node that defaults to the given valuestatic net.neoforged.neoforge.server.permission.nodes.PermissionNode
<Integer> createZeroNode
(String modId, String node) Create an integer node that defaults to 0static net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver
<net.minecraft.network.chat.Component> getComponentLiteralResolver
(String literal) Build a component resolver that returns a literal componentstatic 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 componentstatic net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver
<Integer> getIntegerLiteralResolver
(int literal) Build an integer resolver that returns a constant numberstatic net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver
<String> getStringLiteralResolver
(String literal) Build a string resolver that returns a constant stringstatic 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 permissionstatic 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 permissionsstatic 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 permissionstatic 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 permissionsstatic boolean
hasPermission
(net.minecraft.commands.CommandSource source, net.neoforged.neoforge.server.permission.nodes.PermissionNode<Boolean> permissionNode) Checks if the given CommandSource has the given permissionstatic 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 permissionstatic 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 nodestatic 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
-
Field Details
-
PLAYER_OWNER_RESOLVER
public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean> PLAYER_OWNER_RESOLVERPlayer has permission level Owner -
PLAYER_ADMIN_RESOLVER
public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean> PLAYER_ADMIN_RESOLVERPlayer has permission level Admin -
PLAYER_OP_RESOLVER
public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean> PLAYER_OP_RESOLVERPlayer has permission level Op -
PLAYER_MOD_RESOLVER
public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean> PLAYER_MOD_RESOLVERPlayer has permission level Mod -
PLAYER_ALL_RESOLVER
public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Boolean> PLAYER_ALL_RESOLVERPlayer has permission level All -
INTEGER_ZERO_RESOLVER
public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<Integer> INTEGER_ZERO_RESOLVERInteger literal 0 -
STRING_EMPTY_RESOLVER
public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<String> STRING_EMPTY_RESOLVEREmpty String literal -
COMPONENT_EMPTY_RESOLVER
public static final net.neoforged.neoforge.server.permission.nodes.PermissionNode.PermissionResolver<net.minecraft.network.chat.Component> COMPONENT_EMPTY_RESOLVEREmpty 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 tonode
- The identifier of the noderesolver
- 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 tonode
- 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 tonode
- 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 tonode
- 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 tonode
- 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 tonode
- 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 tonode
- The identifier of the noderesolver
- 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 tonode
- 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 tonode
- The identifier of the nodeliteral
- 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 tonode
- The identifier of the noderesolver
- 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 tonode
- 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 tonode
- The identifier of the nodeliteral
- 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 tonode
- The identifier of the noderesolver
- 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 tonode
- 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 tonode
- The identifier of the nodeliteral
- 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 tonode
- The identifier of the nodeliteral
- 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 testedpermissionNode
- 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 testedpermissionNodes
- 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 testedpermissionNodes
- 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
-