Get Int From Config

Discussion in 'Spigot Plugin Development' started by eli.musgrove9, May 1, 2015.

  1. I need to get an int from a config, and send it as a message to a player. However, it isn't getting it correctly, and is always returning 0.

    Code to set the int:
    Code (Text):
    getConfig().set("Player_Data." + player.getName() + ".Level", 1);
    Code to get the int:
    Code (Text):
    player.sendMessage(ChatColor.DARK_RED + "You're level is " + getConfig().getInt(player.getName() + ".Level"));
    Config Path:
    Code (Text):
        Level: 1
  2. Code (Java):
    getConfig().getInt("Player_Data." + player.getName() + ".Level")
    Silly little mistake, I know i've made it before. Above should work fine :)
  3. Also I'd recommend you use player#getUniqueId().toString() instead of name. What if they change their username and lose all their points :eek: :eek: :eek:
    • Agree Agree x 2
  4. Also if you have many players on your server I recommend making a config for each of them.