[SPIGOT-6899] Add Player#getPreviousGameMode() Created: 15/Jan/22  Updated: 16/Jan/22  Resolved: 16/Jan/22

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: Zhenya Zima Assignee: Doc
Resolution: Fixed Votes: 0
Labels: None

Version: 1.18.1
Guidelines Read: Yes

 Description   

You can say that there are PlayerGameModeChangeEvent... Yes, but if player joined just now, I can't get their previous game mode, but the server knows it and the game/client too (in F3+F4). I would like if method to get it would be exposed to API.

For what I'm need it: In join event, we put player in "waiting" room and changing their game mode to adventure, then after some time player will be teleported back to the world and their game mode will be restored. The problem is just inconvenience: if player press F3+F4 once, their game mode will be changed to adventure — not "real" game mode that they was used before quit. With getting previous mode method, we can set it first and then restore player game mode, so this problem will be solved.

Thanks!



 Comments   
Comment by Zhenya Zima [ 15/Jan/22 ]

It's saved in player.dat so it must be 

Comment by md_5 [ 15/Jan/22 ]

Previous game mode isn't stored after logout though?

Comment by Zhenya Zima [ 15/Jan/22 ]

getPreviousGameMode(), save it to variable, then (before restore)

  1. setGameMode(previous)
  2. setGameMode(real)

So F3+F4 will again suggest previous mode, not adventure.

Comment by md_5 [ 15/Jan/22 ]

I don't quite understand how having only a getter helps you?

Comment by Marvin Rieple [ 15/Jan/22 ]

There is a PR open which ads this: bukkit#647 and craftbukkit#904.

Generated at Sun Mar 30 02:36:46 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.