Config Updating

Discussion in 'Plugin Development' started by Captain Dory, Apr 19, 2014.

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

    Captain Dory

    Hi there,

    I'm using config now and need help with making it update;

    PHP:
    if (args[0].equalsIgnoreCase("sethill")) {
                   
                    if (
    Integer.parseInt(args[1]) < && Integer.parseInt(args[1]) > 0) {
                       
                        
    String s Main.locationToString(player.getLocation());
                        
    plugin.config.set("Hill Location " Integer.parseInt(args[1]), s);
                        
    plugin.saveConfig();
                        
    plugin.reloadConfig();
                       
                        
    player.sendMessage(Main.prefix "Successfully set hill " args[1] + " to your current location!");
                       
                    } else {
                       
                        
    player.sendMessage(Main.prefix "Hills can only go up to 4!");
                       
                    }
                   
                }
    Pay attention to this:
    PHP:
    plugin.config.set("Hill Location " Integer.parseInt(args[1]), s);
                        
    plugin.saveConfig();
                        
    plugin.reloadConfig();
    My config:
    HTML:
    Hill Location 1: world,0,0,0
    Hill Location 2: world,0,0,0
    Hill Location 3: world,0,0,0
    Hill Location 4: world,0,0,0
    My onEnable method:
    PHP:
    public void onEnable() {
           
            
    Scoreboard s = new Scoreboard();
           
            for (
    Player p Bukkit.getOnlinePlayers()) {
               
                
    p.setScoreboard(s.getScoreboard());
               
            }
           
            
    registerEvents(new Scoreboard(), new Hill(this));
            
    getCommand("koth").setExecutor(new Commands(this));
           
            
    saveDefaultConfig();
           
        }
    I do the command
    Code:
    /koth sethill 1
    and it sends me the message, but it does not write to the config.


    Any help please? :3
     
  2. try this:
    Code:java
    1. getConfig().set(...);
     
  3. Offline

    clmcd42

    I'm not positive, but I've never seen anybody put a space in the key of the YAML. Try changing "Hill Location 1" to "hill-location-1" and likewise with the rest. Also if that doesn't work, please post the error message
     
  4. Offline

    coasterman10

    If FileConfiguration saves config keys correctly (and I'm sure it does), then it will save it with quotations around it.
     
  5. Offline

    Captain Dory

    This is what I'm doing but with a FileConfiguration variable, this is in the main class:
    PHP:
    FileConfiguration config getConfig();
    And I access the main class with plugin.
    I'll try this.

    Nope, it still does not write to config.

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

    clmcd42

    Captain Dory Ok, I think I see the problem. It's the config variable. Remove it and just use getConfig() everytime. I think it should work if you do that.
     
  7. Offline

    Captain Dory

    Ok, I'll try that.

    EDIT: Still not working properly.
     
Thread Status:
Not open for further replies.

Share This Page