Adding in configuration section

Discussion in 'Plugin Development' started by gummianka, Aug 13, 2017.

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

    gummianka

    Hello, I trying to put in section "used keys" player's name, his pin and usages. But when player using another pin he replacing with old pin. I need to add another pin but not replace it with old.

    Here is my code:
    Code:
    void add(Player p, String[] args) {
       int usages = Main.p.getConfig().getInt("used keys." + p.getName() + "." + args[0]);
       if (usages == 0) {
          Main.p.getConfig().set("used keys." + p.getName(), args[0]);
          Main.p.getConfig().set("used keys." + p.getName() + "." + args[0], 1);
       } else {
          Main.p.getConfig().set("used keys." + p.getName() + "." + args[0], usages + 1);
       }
       Main.p.saveConfig();
    }
    
    And my section:
    Code:
    used keys:
      gummi_anka2:
        AdsaSD: 3
      gummi_anka:
        sAsaaA: 1
    
    When player typing another pin, he replacing with "AdsaSD: 3" to like "fSaAD: 1".

    I tried to use hashmap, list with split and create another sections, but it wouldn't work.
     
  2. @gummianka
    Code:
    Main.p.getConfig().set("used keys." + p.getName(), args[0]);
    Main.p.getConfig().set("used keys." + p.getName() + "." + args[0], 1);
    I think the first line is not doing anything, but I'm not exactly sure what you are trying to tell us..
     
  3. Offline

    PenguinOwl

    Pretty sure that yml doesn't like people placing spaces in their config paths like "used keys"
     
Thread Status:
Not open for further replies.

Share This Page