Need Some Help With Configs

Discussion in 'Plugin Development' started by OhYes, Oct 21, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    OhYes

    Hi there!
    So I've been coding with Bukkit for a couple of years now but I stopped a while ago, and now I'm restarting. Only thing is, I've forgotten quite a lot of the stuff I've learnt. So I'm trying to make a plugin called "ELO" where you can fight other players in ranked duels and gain/lose elo. I want the elo to be kept in a config file which will kinda look like this -

    ############
    Default ELO: 1000
    Players:
    Oh_Yes: 1000
    Notch: 1400
    OriginalName: 950
    ############

    When a user logs into the server, a OnJoinEvent will proccess and check if their name isn't in the "Players:" then it will add them to it and give them the default elo. I need to know how to check if the player is under the Players: category, and if they're not, then add them to it. I'm kinda a noob when it comes to configs, so some help would be apprieciated! Here's a link to a pastebin for my code too: http://pastebin.com/b0FLEWtT

    Thanks!
    - OhYes
     
  2. @OhYes Why do you have getConfig() in the onEnable? I think you mean saveDefaultConfig()
     
  3. Offline

    OhYes

    As I said I'm a big noob when it comes to configs x) Yeah, I probably did mean saveDefaultConfig(); Thanks. Obviously I don't want the elo to go back to the default every time, will saveDefaultConfig() in onEnable() reset it?
     
  4. @OhYes
    In recent versions of minecraft, we started using UUIDs. Essentially every player has a unique UUID, and it cannot be changed. This is extremely important to use in plugins due to the fact that people can now change their username in 1.8. If someone changes their name, they will have a completely different "ELO" if you use that config format.

    Instead, I suggest you set player UUIDs, and if you want, assign names to them whenever someone joins with the uuid.

    Example:

    #############
    Default ELO: 1000
    Players:
    3ek21-akww-5566bb:
    name: Classic_Wood
    ELO: 1100

    saveDefaultConfig() does not reset it. It simply loads it (updates everything in getConfig()), or copies the default config into the folder if it doesn't already exist.
     
  5. Offline

    OhYes

    Ah okay thanks, so now I just need to know how to do it xP
     
Thread Status:
Not open for further replies.

Share This Page