SpongeAPI icon indicating copy to clipboard operation
SpongeAPI copied to clipboard

Provide an ordering for permission contexts

Open zml2008 opened this issue 9 years ago • 3 comments
trafficstars

@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>

zml2008 avatar Dec 21 '15 04:12 zml2008

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.

ryantheleach avatar Dec 21 '15 10:12 ryantheleach

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:

  1. Get active/current contexts
  2. send them to the permission service
  3. let the permission service order them (it knows best how to do this)
  4. get permission value from the permission service using the properly ordered contexts
  5. use permission value

ST-DDT avatar Dec 21 '15 12:12 ST-DDT

@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.

zml2008 avatar Dec 27 '15 17:12 zml2008