Solved Path is not generated config file Small tweak needed

Discussion in 'Plugin Development' started by dbaum102, Dec 20, 2015.

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

    dbaum102

    Defaults:
    Code:
    this.getConfig().addDefault("default", "A");
            this.getConfig().addDefault("rankNumbers", 1);
            this.getConfig().addDefault("1", "A");
            this.getConfig().addDefault("A", "1");
            this.getConfig().addDefault("1Price", 100);
            this.getConfig().addDefault("2", "B");
            this.getConfig().addDefault("B", "2");
            this.getConfig().addDefault("2Price", 200);
            this.getConfig().addDefault("EndNum", 2);

    Code bit:
    Code:
    @EventHandler
        public void onJoin(PlayerJoinEvent e) {
            Player p = e.getPlayer();
            if (this.getConfig().getString(p.getName()) == null) {
                this.getConfig().set(p.getName(), this.getConfig().getString("default"));
                String nextNum = "" + this.getConfig().getInt(this.getConfig().getString("default")) + 1;
                this.getConfig().set(p.getName() + "NextRank", this.getConfig().getString(nextNum));
                this.saveConfig();
             
            }
        }
    Does not generate: dbaumNextRank: B
    Code:
    # add one to rank numbers for every rank you add to make the code read all of the ranks with no erros
    default: A
    rankNumbers: 1
    '1': A
    A: '1'
    1Price: 100
    '2': B
    B: '2'
    2Price: 200
    EndNum: 2
    dbaum: A
    
    Small tweak needed please help thanks
     
  2. Offline

    Zombie_Striker

    @dbaum102
    Are you sure "nextNum" is not null? If you try to save a null to the config, the path will be deleted and as such will not show in the config.
     
  3. Offline

    dbaum102

    I think i fixed this but forgot to change forum status
     
Thread Status:
Not open for further replies.

Share This Page