Previous game mode resets spuriously
Sometimes on Creative, your previous game mode gets set to your current game mode. This is especially annoying when using the game mode switcher afterwards.
Apparently the client decides what the player's previous game mode is. But the logic there seems correct and I don't see anything that would randomly clear it. Maybe some plugin is messing it up. Though it seems Paper ignores it if a plugin sets a player's game mode to their current game mode.
It does seem the game mode changing logic on the server is flawed. In ServerPlayerGameMode
it seems to do this
this.setGameModeForPlayer(gameMode, this.previousGameModeForPlayer);
where gameMode
is the new game mode. Thus the new previous game mode is set to the current previous game mode. I believe the new previous game mode should be the current game mode instead?
Possibly related to: https://bugs.mojang.com/browse/MC-257531.