As the title says I’m trying to grant the player a temporary permission, the general idea is that I would grant them the permission, execute a command from the player that requires that permission, and then unset said permission what I’ve tried so far is something like the code below:
It is being tested, but when the command is executed it’s still undefined, even though the permission is in the player’s subjectData (verified with Intellij Debugger).
Just did, so it seems the issue is that there is a delay between the permission being added to the SubjectData and it being reflected by the permission service and the delay is large enough that it interferes with the command being executed by the subsequent line of code, not really sure if there’s a way to get around this.
Similar weird behavior also occurs in pex, I’d rather not depend on the implementation of the permissions service to dictate whether or not my code will work, I suppose I’ll have to keep searching for another way.
I thought about that, I’ve already provided functionally to my users to execute the command from the console. The idea is that for my CommandBooks plugin, there might be cases where the command cannot be executed by the console on the player’s behalf, i.e. the command doesn’t take a player as an argument, and so command books would be used as a way to allow players to execute commands on themselves that they otherwise wouldn’t have permission to, but to do that I would need to temporarily grant the player the appropriate permissions to execute the commands in the book and then revoke them one the execution completes.
@zml is working on some improvements to the permissions API. You could suggest that setting a permission returns a CompletableFuture so you can do actions once the action is completed