类 PermissionNode<T>
A permission indicates the ability for an actor to perform an action,
in its most general sense. In the permission system, all permissions are encoded as instances of this class,
optionally integrated by a PermissionDynamicContext
.
A node is uniquely identified by its `nodeName`,
which is a dot-separated string providing meaning to the node itself.
The suggested structure of the name is `modid.name`, where `modid` is the ID of the owner of the node.
This API does not require any implicit hierarchy,
so `modid.name` is not considered a parent of `modid.name.sub`. Such decisions are left to the IPermissionHandler
.
Each node also has an associated PermissionType
, detailing its exact type,
along with a PermissionNode.PermissionResolver
that is used to obtain the default value of the permission.
More information can be found on their documentation.
A node can also be bound to additional PermissionDynamicContextKey
s,
which are used when querying the availability of the permission.
There are no restrictions on their amount. It is also not mandatory to provide a value for all dynamics in a permission query.
See the above link for more information.
Each node should be registered via the PermissionGatherEvent.Nodes
and stored statically in a field.
That instance should then be reused every-time a permission check needs to be performed via PermissionAPI.getPermission(ServerPlayer, PermissionNode, PermissionDynamicContext[])
.
-
嵌套类概要
嵌套类修饰符和类型类说明static interface
Utility Interface used for resolving the default value of PermissionNodes -
字段概要
字段修饰符和类型字段说明private final PermissionNode.PermissionResolver
<T> private @Nullable Component
private final PermissionDynamicContextKey<?>[]
private final String
private @Nullable Component
private final PermissionType
<T> -
构造器概要
构造器限定符构造器说明PermissionNode
(String modID, String nodeName, PermissionType<T> type, PermissionNode.PermissionResolver<T> defaultResolver, PermissionDynamicContextKey<?>... dynamics) CallsPermissionNode(String, PermissionType, PermissionResolver, PermissionDynamicContextKey[])
with "modid.nodename" as the first parameterprivate
PermissionNode
(String nodeName, PermissionType<T> type, PermissionNode.PermissionResolver<T> defaultResolver, PermissionDynamicContextKey<?>... dynamics) PermissionNode
(ResourceLocation nodeName, PermissionType<T> type, PermissionNode.PermissionResolver<T> defaultResolver, PermissionDynamicContextKey<?>... dynamics) CallsPermissionNode(String, PermissionType, PermissionResolver, PermissionDynamicContextKey[])
with "namespace.path" as the first parameter -
方法概要
-
字段详细资料
-
nodeName
-
type
-
defaultResolver
-
dynamics
-
readableName
-
description
-
-
构造器详细资料
-
PermissionNode
public PermissionNode(ResourceLocation nodeName, PermissionType<T> type, PermissionNode.PermissionResolver<T> defaultResolver, PermissionDynamicContextKey<?>... dynamics) CallsPermissionNode(String, PermissionType, PermissionResolver, PermissionDynamicContextKey[])
with "namespace.path" as the first parameter -
PermissionNode
public PermissionNode(String modID, String nodeName, PermissionType<T> type, PermissionNode.PermissionResolver<T> defaultResolver, PermissionDynamicContextKey<?>... dynamics) CallsPermissionNode(String, PermissionType, PermissionResolver, PermissionDynamicContextKey[])
with "modid.nodename" as the first parameter -
PermissionNode
private PermissionNode(String nodeName, PermissionType<T> type, PermissionNode.PermissionResolver<T> defaultResolver, PermissionDynamicContextKey<?>... dynamics) - 参数:
nodeName
- The identifier of a node, recommended identifier structure: "modid.path.for.node"type
- type object for the PermissionNode, only use types inPermissionTypes
defaultResolver
- Default resolver for the permission, can but doesn't have to be used to by PermissionHandlersdynamics
- PermissionDynamicContextKey is a dynamic component for permission nodes, similar to BlockState Properties. They must be passed into the constructor if you want to use them.
-
-
方法详细资料
-
setInformation
public PermissionNode<T> setInformation(@NotNull @NotNull Component readableName, @NotNull @NotNull Component description) Allows you to set a human-readable name and description for your Permission.Note: Even though not used by Default, PermissionHandlers may display this information in game, or provide it to the user by other means.
You may usetranslatable components
, but you'll need 2 language files. One inside the data directory for the server and one inside assets for the client.- 参数:
readableName
- an easier to read name for the PermissionNode, when using TranslatableComponent, key should be of format"permission.name.<nodename>"
description
- description for the PermissionNode when using TranslatableComponent, key should be of format"permission.desc.<nodename>"
- 返回:
- itself with the new information set.
-
getNodeName
-
getType
-
getDynamics
-
getDefaultResolver
-
getReadableName
-
getDescription
-
equals
-
hashCode
public int hashCode()
-