1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Add something to config

Discussion in 'Development' started by Harviy11, Dec 23, 2016.

  1. Harviy11

    Harviy11 Baby Zombie

    Messages:
    100
    how i add something to config MY CODE dont work
    PHP:
    public
    function 
    onBreak(BlockBreakEvent $e)
    {
        
    $p $e->getPlayer();
        
    $world $p->getLevel()->getFolderName();
        
    $cfg = new Config($this->getDataFolder()."config.yml"Config::YAML, array());
        if (
    in_array($p->getLevel()->getFolderName(), $this->getArenas())) {
            
    $e->setCancelled();
            
    $p->sendMessage(C::GREEN "You can not break blocks!");
            
    $cfg->set("Number"1);
            
    $cfg->save();
            return;
        }
    }
     
    Last edited: Dec 23, 2016
  2. VentroxStudio

    VentroxStudio Witch

    Messages:
    71
    PHP:
    $conf = new Config($this->getDataFolder() . "config.yml"Config::YAML);
    $conf->set("Number"1);
     
    $conf->save();
     
  3. VentroxStudio

    VentroxStudio Witch

    Messages:
    71
    Without the array at the end of $cfg
     
  4. VentroxStudio

    VentroxStudio Witch

    Messages:
    71
    If you want to add something at the end of an array use this:
    PHP:
     $array $this->array;
      
    array_push($array"This is what you want to add");
     
    $this->array $array;
     
    $conf->set("Numbers"$array);
     
  5. VentroxStudio

    VentroxStudio Witch

    Messages:
    71
    If this don't work send the error
     
  6. Primus

    Primus Zombie Pigman

    Messages:
    749
    4 posts in row? Please use edit button.
    That doesn't change anything because an empty array is used anyways. Check out for yourself in Config.yml
     
    xBeastMode likes this.
  7. VentroxStudio

    VentroxStudio Witch

    Messages:
    71
    Ok. There are not much informations. And that works in my plugins.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.