CachedData does not support transient lookups
Closed this issue ยท 5 comments
LP LuckPerms-Bukkit-4.3.90
Paper 1.13.2
There doesn't seem to be a way to grab transient permissions from CachedData.
If I attempt to simply grab all cached data with contexts, I have no way of knowing if the results I am getting back are from transient or persisted.
All of the lookups from within CachedData take account of both enduring (non-transient) and transient permissions.
If you only want to query transient, or only enduring, you can't use CachedData.
If I can't use CachedData nor PermissionHolder, I would have to construct all these methods myself to handle permissions/contexts like Sponge proxies do.
These proxies contain all the required functionality that I will need for Bukkit. If this proxy could be moved to a common interface where I could make the same permission calls as Sponge then I would have no issues.
Which methods in particular? I'm happy to port some of them to the API, but I don't really want to expose the whole PermissionService implementation to all platforms.
I would need the following methods in a common interface to function the same
SubjectProxy
SubjectData getSubjectData()
SubjectData getTransientSubjectData()
Tristate getPermissionValue(@NonNull Set<Context> contexts, @NonNull String permission)
Optional<String> getOption(@NonNull Set<Context> contexts, @NonNull String key)
Set<Context> getActiveContexts()
boolean hasPermission(@NonNull String permission)
boolean hasPermission(@NonNull Set<Context> contexts, @NonNull String permission)
SubjectDataProxy
Map<String, String> getOptions(@NonNull Set<Context> contexts)
Map<String, Boolean> getPermissions(@NonNull Set<Context> contexts)
Map<Set<Context>, Map<String, String>> getAllOptions()
Map<Set<Context>, Map<String, Boolean>> getAllPermissions()
CompletableFuture<Boolean> setOption(@NonNull Set<Context> contexts, @NonNull String key, @Nullable String value)
CompletableFuture<Boolean> setPermission(@NonNull Set<Context> contexts, @NonNull String permission, @NonNull Tristate value)
CompletableFuture<Boolean> clearPermissions(@NonNull Set<Context> contexts)
CompletableFuture<Boolean> clearOptions(@NonNull Set<Context> contexts)
Here are a few of my use cases
All of the data you need to implement those methods is already exposed in the API - it's just in a slightly different format.
You can see how the Sponge implementations are made here:
https://github.com/lucko/LuckPerms/blob/master/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/permissionholder/PermissionHolderSubject.java
https://github.com/lucko/LuckPerms/blob/master/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/permissionholder/PermissionHolderSubjectData.java
All of the methods in your "SubjectProxy" list above have equivalents in the CachedData
API interface, and the methods in "SubjectDataProxy" can be implemented using the methods in the PermissionHolder
interface.