LuckPerms

LuckPerms

41.4k Downloads

World context ignored after server change

fgardt opened this issue ยท 4 comments

commented

Description

I run a couple of servers behind Velocity and want to use the RememberMe plugin to auto connect to the last connected server. But that also causes players to get connected into the lobby on a reconnect if they got sent there due to the actual game server going down.
I wanted to fix this by introducing a new permission to RememberMe rememberme.notracking which would be true for the lobby server.

Without any contexts set on the permission my modification of RememberMe works as expected: it doesn't track any server changes at all.
With a context for world=lobby however it would still track players in the lobby. I also adding the permission for every server with the corresponding context to check if that would disable the tracking again but it didn't.

When checking for the permission ingame it showed correctly.

Reproduction steps

  1. Velocity server setup with 2 backend servers
  2. LuckPerms installed on the Velocity server
  3. Compile the modified RememberMe from here and install it on Velocity
  4. Set the permission rememberme.notracking to true with corresponding contexts to test
  5. Use /lpv user USERNAME meta info to check the last-server info

Expected behaviour

Respect the permissions context even immediately after a server change.

Environment details

  • Server type/version: Velocity version 3.0.0
  • LuckPerms version: v5.3.57

Any other relevant details

The server context is not ignored (but is not useful since its only 1 "server" aka proxy)

Code responsible for the behaviour in RememberMe:

@Subscribe
public void onServerChange(ServerConnectedEvent serverConnectedEvent) {
    if (!serverConnectedEvent.getPlayer().hasPermission("rememberme.notracking")) {
        handler.setLastServerName(serverConnectedEvent.getPlayer().getUniqueId(), serverConnectedEvent.getServer().getServerInfo().getName());
    }
}
commented

It should be invalidating when that event fires.

https://github.com/lucko/LuckPerms/blob/master/velocity/src/main/java/me/lucko/luckperms/velocity/context/VelocityPlayerCalculator.java#L74

Does serverConnectedEvent.getPlayer().getCurrentServer().getServerInfo() return the expected value during that event?

commented

Ah, I see - we should both (I think) be using ServerPostConnectEvent.

commented

Can confirm that this fixed it.
(I also changed the event on the rememberme plugin to ServerPostConnectEvent)

https://luckperms.net/verbose/FoyJGysUqw

commented

Using verbose to further inspect this issue indeed confirms that at the time when the permission gets checked neither the old nor the new world context are set.
https://luckperms.net/verbose/bwjkR0UD8f

When running verbose on a different permission for a command to test for the contexts the correct world context is set.
https://luckperms.net/verbose/DstqjFTcDn

note: I changed the onServerChange eventlistener to @Subscribe(order = PostOrder.LAST) but this didn't change anything.

Is there some way I can properly wait for LuckPerms to update contexts after a server change?