Math In Config.yml

Discussion in 'Plugin Development' started by KoolzSkillz, Oct 24, 2014.

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

    KoolzSkillz

    How Would i get It to work here is the Coding i am using to set it their then take away one but it doesn't remove it

    Code:
            if (!settings.getConfig().contains("Blocks." + p.getUniqueId())) {
                settings.getConfig().set("Blocks." + p.getUniqueId(), 100);
                p.sendMessage("§2100 Blocks Left");
                settings.saveConfig();
                return;
            }
            settings.getConfig().set("Blocks." + p.getUniqueId(), (settings.getConfig().getLong("Blocks." + p.getUniqueId(), -1)));
            settings.saveConfig();
     
  2. Offline

    fireblast709

    KoolzSkillz subtract 1 from the value you get from the config. You currently set the default value (which won't be used since you know it exists at that point) to -1
     
  3. Offline

    KoolzSkillz

  4. Offline

    fireblast709

    KoolzSkillz after getLong(), just add "-1" (without quotes, obviously)
     
  5. Offline

    KoolzSkillz

    fireblast709
    Cool thx

    fireblast709
    im using this and it isn't doing anything to the config, (not subtracting)
    Code:
        @EventHandler
          public void bbe (BlockBreakEvent e) {
            Player p = e.getPlayer();
            if (!settings.getConfig().contains("Blocks." + p.getUniqueId())) {
                settings.getConfig().set("Blocks." + p.getUniqueId(), 100);
                p.sendMessage("§2100 Blocks Left");
                settings.saveConfig();
                return;
            } if (settings.getConfig().contains("Blocks." + p.getUniqueId())) {
                settings.getConfig().getLong("Blocks." + p.getUniqueId(), -1);
                settings.saveConfig();
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  6. Offline

    fireblast709

    KoolzSkillz after getLong(), not inside getLong ;3
     
  7. Offline

    KoolzSkillz

    fireblast709


    oooooooo
    Now I get it :)

    Thx

    fireblast709
    Can you post an example it still isnt working for me

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  8. Offline

    fireblast709

    KoolzSkillz post your code. You should set() the path to getLong(path) - 1.
     
  9. Offline

    KoolzSkillz

    fireblast709
    ok i found the problem i added an extra )

    XD
     
Thread Status:
Not open for further replies.

Share This Page