SpongePowered / SpongeAPI

A Minecraft plugin API
http://www.spongepowered.org/
MIT License
1.14k stars 342 forks source link

Add Keys#PREVIOUS_GAME_MODE #2442

Closed Lignium closed 1 year ago

Lignium commented 2 years ago

[SpongeAPI | Sponge]

Zidane commented 2 years ago

@Lignium

I wonder if we should allow this key to be set? I only bring this up because setting it effectively feels like breaking the contract of what it is?

Lignium commented 2 years ago

@Zidane My authorization plugin manipulates game mode, adventure is set for the duration of authorization. And there was a problem, the key combination F3 + N broke, the previous game mode turned out to be the mode that temporarily set the authorization plugin, not at all what was expected. Instead of switching back and forth between creative and spectator, I get thrown into adventure mode and falling from a height.

Zidane commented 2 years ago

My point is I'd expect setting of GAME_MODE via key would change PREVIOUS_GAME_MODE but no one can rely on PREVIOUS_GAME_MODE actually being truthful if anyone can simply go set it via API contract.

Lignium commented 2 years ago

One option is to make it read-only, and with two Keys#GAME_MODE set in a row, I can set both values.

gabizou commented 1 year ago

The way I see it is that while game modes can change, we easily provide the DataTransaction including the Keys.PREVIOUS_GAME_MODE, since it can very well be changing.