Why is the Contextual Service not implemented?


#1

I was playing around with the permission service (implemented my own, mainly to see if it’s difficult). When I read the docs it also talked about the contextual Service and what it does. I sounded pretty useful, so I wanted to try out the Sponge implementation first, to see how it works. It didn’t do anything.

After some digging in SpongeCommon I found, that Sponge does provide their own context calculator (which creates Contexts for the world, dimension, etc.), they even try to register it with the permission service, but the method registerContextCalculator (in the SpongePermissionService) seems to be empty, also the getActiveContexts method only returns the global_context.
As far as I could see it it’s also not added via mixin.

Now, why is most of the service implemented, yet the crucial part is left out?

Thanks in advance!


#2

Look at the LP code https://github.com/lucko/LuckPerms/blob/f6c440c172f57f83ae11ec0e312214d002b985c4/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/PermissionServiceProxy.java#L157


#3

Tanks, but I’m not looking for a way to implement this (that should be relatively straight forward), I’m just wandering if anyone knows why this is build into the sponge permission system, but disabled.


#4

The sponge implementation of PermissionService doesn’t support contexts, because they’re not needed for normal “vanilla” behaviour to function.

Therefore, the impl in SpongeCommon doesn’t do anything with ContextCalculator registrations, and simply returns an empty context set in all cases.

If you want to make use of contexts in your plugin, you need to make sure a “supported” permissions plugin is installed.

e.g.


#5

Ok, I was just wandering, since they explain the functionality in the docs without mentioning that it isn’t supported (but maybe I just missed that) and they aren’t giving a hint to that in the log (or throwing an UnsupportedOperationException or similar).
Just leaving the method empty makes it look a little unprofessional/lazy and harder to debug for someone who is not going through the source files.

But thanks for the answer (: