Code: if (DataManager.getData().contains("data")) { DataManager.getData().getConfigurationSection("data").getKeys(false).forEach(key -> { String d = (String) DataManager.getData().get("data." + key); Player target = Bukkit.getServer().getPlayer(key); plugin.playerDiscord.put(target, d); Bukkit.getConsoleSender().sendMessage("put " + key); Bukkit.getConsoleSender().sendMessage("put " + target); Bukkit.getConsoleSender().sendMessage("dis " + d); }); } Console output: Code: [20:04:29 INFO]: put CraftPlayer{name=IAmANoot} [20:04:29 INFO]: put null [20:04:29 INFO]: dis !AmANoot#0123 It doesn't save because the player is null if I use .getPlayer but I cannot use just "key" because it is not a player Any ideas?
You shouldn't be saving the player as a key, but rather their UUID (as a string) in my opinion, as you don't need anything more.
@IAmANoot Save the player's UUID, not their name. @TheEnderCrafter9 You can use UUID#fromString(String) to get a UUID object.