Solved Config trouble?

Discussion in 'Plugin Development' started by kampai, May 27, 2016.

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

    kampai

    Hey!
    I'm currently using bukkit's built in YamlConfiguration system to make configs, however I'm having trouble with one part, how do I set default config, for exmaple I want to make player states, how would I make the path?
    (EX:
    player:
    coins: int
    banned: boolean
    rank: string)
     
  2. Offline

    Zombie_Striker

    @kampai
    Are you looking for this? This is fitted towards your example
    Code:
    Config#set("player.coins", 0);
    Config#set("player.banned", true);
    ...
    Config#save( the file location);
    //Or, if it's the default config, as in the one at /PluginName/config.yml
    saveConfig()
     
  3. Offline

    kampai

    Okay so I have a little bit of trouble understanding that a bit. So everytime you do player.coins it would make a new line under player right? so if i did player.coins.bonus it would make a new line under coins?

    EDIT: Also is it easier to save a hashmap with a UUID and INT or just save an int to the config on server on plugin disable
     
    Last edited: May 27, 2016
  4. Offline

    Zombie_Striker

    @kampai

    1# ) Not really. Because "coins" is a path that leads directly to a value instead of another path, that would not work. If 'coins' only held other paths (E.g. "Coins: values: 1" and "Coins: bonus: ect. "), then it would work.

    2# ) Yes, it would. Save the entire hashmap to a config instead of individual entries.
     
  5. Offline

    kampai

    @Zombie_Striker
    Alright so how would I get a path, last question sorry for example I want to do
    Code:
    if(!core.user.getConfigurationSection("player.coins")) {
    (core is the class I'm getting user, the .yml file, from) when i do that I get an error asking asking me to put == null. It would work if I put == null and remove the "!" right?
     
  6. Offline

    Zombie_Striker

    @kampai
    What you're doing is get the configuation section instance at that path in the config. If the path "player.coins" has an integer at that path (meaning your config looks something like "player: coins: 10"), then you should use "core.user.getInt("player.coins") == (Your test)" to test if a player has a certain amount of coins.
     
Thread Status:
Not open for further replies.

Share This Page