Config Help

Discussion in 'Plugin Development' started by FuZioN720, May 22, 2013.

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

    FuZioN720

    How can i set a config value with the key having ' in it.

    Here is a example, I have it checking if the player is in the config then if not set it:
    Code:java
    1.  
    2. if (!getConfig().isSet("Players." + player.getName())){
    3. upd("Players." + player.getName() + ".on", true);
    4.  


    my upd method:
    Code:java
    1.  
    2. public void upd(String loc, Object value) {
    3. getConfig().set(loc, value);
    4. saveConfig();
    5. }
    6.  


    Here is my config that it sets
    Code:
    Players:
      xXFuZioN360Xx:
        'on': false
    but i dont want the '' on the on. I want on not 'on'
     
  2. Offline

    JWhy

    You'll simply have to live with it, whilst you use the Bukkit Configuration API. Better use another API (like that from pyraeos) for your configuration if you place value on those things. Beside that 'on' and on are the same in YAML
     
  3. Offline

    FuZioN720

  4. I don't know what you're doing, but lets say its a command:
    Config:
    Code:
    Players:
      test:
        on: false
    
    Command:
    Code:
    if(cmd.getName().equalsIgnoreCase("turn")){
    if(args.length == 3){
    if(args[0].equalsIgnoreCase("player"){
    if(args[2].equalsIgnoreCase("on"){
    if(getConfig().getString("Players."args[1]".on").equals("false"){
    getConfig.set("Players."args[1]".on", "true");
    sender.sendMessage("Player "+ args[1] +" is now enabled!");
    }
    else{
    sender.sendMessage("Player "+ args[1] +" is already enabled!");
    } 
    }
    }
    
    }
     
    }
    
    What this does:
    If someone types in /turn player test on and on is set to false, it sets it to true. If on is set to true, it says "Player is already on!"
     
Thread Status:
Not open for further replies.

Share This Page