Get GameMode by ID

Hello,

I know this:

BlockType type = game.getRegistry().getType(BlockType.class, blockId).get();

But i dont find a away to set a GameMode from my configuration.

On Bukkit i do this code to test if the config is valid set gamemode from configuration after validate:

... try { GameModes.valueOf(ConfigGameMode.toUpperCase()); return true; } catch (IllegalArgumentException e){ return false; } ...

It’s the same code as getting a BlockType:

GameMode gameMode = Sponge.getRegistry().getType(GameMode.class, ConfigGameode.getString()).orElse(GameModes.SURVIVAL);
1 Like

Ohh man, i used “game”(Sponge.getGame.getRegistry()…)!!

Now works, thanks!!