SpongeAPI
SpongeAPI copied to clipboard
Provide an ordering for permission contexts
@gravityfox wants to be able to have some sort of region priority system -- and it some other cases it makes sense for some contexts to be placed before others. At its simplest, this would involve ajusting all the permissions query methods to accept a List<Context> rather than a Set<Context>
I thought this would have been up to the permissionService to define? but yes, some hinting that the permissionsService is free to ignore would probably help because at the moment it has no clue as to what contexts override what.
Well instead of asking the permission service for a particular permission with a specific context order I would rather add a priority option to the PermissionService something like : setPriority(Context,int).
Reason:
- Plugin X does/should not know about Plugin Y's regions nor their priorities.
- Plugin Y does not know about the verify important context of Plugin Z (arena) and the less important context of plugin W (informative region). Only each individual plugin can say how important each of its own contexts is and share the information with the permission plugin, which itself may allow some kind of adjustment of the contexts so they can be put in a proper order.
- We use Permission calculators that do the context calculation that we could alter to provide a priority mapping
Map<Context,priority>
Workflow:
- Get active/current contexts
- send them to the permission service
- let the permission service order them (it knows best how to do this)
- get permission value from the permission service using the properly ordered contexts
- use permission value
@ryantheleach contexts and determining which contexts go before which others is more the job of the context calculators --permissionservice implementations do not know any specifics about contexts.
@ST-DDT context priorities don't mean much when not placed in relation to each other, so I don't see any reason to have them exist outside of the ContextCalculator.