
Support Permission APIs
BlayTheNinth opened this issue ยท 0 comments
Neo/Forge fires PermissionGatherEvent.Nodes
event where mods register their PermissionNode
, which is checked through PermissionAPI.getPermission(player, node, ...context)
and PermissionAPI.getOfflinePermission(uuid, node, ...context)
. PermissionNode optionally allows setting node.setInformation(title, description)
for human readable metadata and requires a default PermissionResolver(nullable player, uuid, ...context) that returns T of PermissionType (bool/int/string/component).
Fabric Permissions API (third-party):
Permissions.check(player, "mymod.mypermission", fallbackBoolean)
Permissions.require("mymod.mypermission")
for use in command registrations- offline checks with uuid are async and are supposed to only be awaited outside of the server thread, probably just not going to care about offline checks in this first implementation
Plan for Balm:
- we ignore PermissionTypes other than boolean for now (Neo/Forge overcooked?)
- we ignore human-friendly metadata for now (not used by default impl)
- we ignore context dynamics for now (not supported on Fabric and hard to see how they would be used by a generic permission handler)
- we ignore offline checks for now (limited use cases and don't want an async API for Fabric support)
interface PermissionContext
withOptional<Player>
,UUID playerId
BalmPermissions.registerPermission(ResourceLocation id, Function<PermissionContext, Boolean> defaultResolver
)BalmPermissions.hasPermission(Player player, ResourceLocation id)
(we implicitly run defaultResolver for Fabric to pass in fallbackBoolean)