Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Set a config value

Comments in 'Plugin Development' started by Legoboy0215, Aug 7, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I tried this:
    PHP:
    $d $this->plugin->stats->get($name)["deaths"];
                
    var_dump($d);
                
    $d1 $d 1;
                
    $this->plugin->stats->set($name["deaths"], $d1);
    But there is an error on the last line. How would I properly set it?
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I do this:
    PHP:
    public function onEnable(){
    $this->players = (new Config($this->getDataFolder()."players.yml"Config::YAML))->getAll(); // Load config in array
    }

    public function 
    onDisable(){
    $this->players = new Config($this->getDataFolder()."players.yml"Config::YAML// Save array in config.
    }

    public function 
    addDeath($player){
    $name = ($player instanceof Player $player->getName() : $player);
    if(isset(
    $this->players[$name]['deaths'])){
    $this->players[$name]['deaths']++;
    return 
    true;
    }
    return 
    false
    }

Share This Page

Advertisement