I'm saving the player's game mode in a hashmap. And when I go to restore the players game mode, it just doesn't set it. I've debugged it, and it returns the game mode correctly. Code (Text): p.sendMessage(gameMode.get(p.getUniqueId()) + ""); // Returns the correct gamemode name in caps ie CREATIVE p.setGameMode(gameMode.get(p.getUniqueId())); // Should work, console doesnt throw any errors or anything Edit: What I have works, I was setting their game mode in another class when debugging a long time ago, rip
That should work lol if all else fails you can always go like this Code (Text): if (gameMode.get(p.getUniqueId).equalsIgnoreCase("CREATIVE")){ p.setGameMode(Gamemode.CREATIVE); } Do it for all Its not very efficient but it works
I was wondering that. Is it because it doesn't have the "GameMode." but that wouldn't make sense as I'm storing his game mode so I should be able to just set it ;-;
have you tried Code (Text): System.out.println(); the stored value in the hashmap to see if it saves correctly? The class Gamemode may not be serializable to be stored in a hashmap. You can try storing it as a String instead and using that in a switch statement/if statements to change the gamemode so your HashMap will be Code (Text): new HashMap<UUID,String> //instead of new HashMap<UUID,GameMode> If this fails, if this is running on a command, replace this... Code (Text): Player p=(Player)sender; //with Player p=Bukkit.getPlayer(sender.getUniqueId()); Just might be an issue of casting. This is unlikely however.
If this isn't solved yet, Code (Text): p.setGameMode(GameMode.valueOf(gameMode.get(p.getUniqueId())));
Saving PlayerData before they join my arena and restoring it That's true maybe game modes can't be stored, but i can't imagine a reason why it wouldn't be able to. And I also thought of using the String which would work fine but figured using game modes would be easiest But I'm technically storing GameMode.CREATIVE so Im not sure how that'd work. I'm not on my computer right now, if all else fails, Ill probably just using a string for the game mode type and use GameMode.valueof()
Yeah i saw that you stored the gamemode after i posted that reply, but i honestly think u must use GameMode.valueOf, can't think of any other way