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

How to save, get info from config.yml?

Comments in 'Plugin Development' started by minebuilder0110, Sep 20, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Wow... To solve this issue, save your value to an array.
    $this->getConfig()->set($name, array(
    "position" => array(
    "x" => 20,
    "y" => 20,
    "z" => 20)
    )
  2. Taki21
    Offline

    Taki21 New Member

    Joined:
    Sep 24, 2015
    Posts:
    11
    Minecraft User:
    Taki21
    Will it work on other events ex: PlayerJoinevnt or onCommand?
  3. Taki21
    Offline

    Taki21 New Member

    Joined:
    Sep 24, 2015
    Posts:
    11
    Minecraft User:
    Taki21
    @PEMapModder You're right
    This should be correct:
    PHP:
    $pos $this->config->get("Position");
    $this->config->get("$pos["x"]");
    or
    PHP:
    $this->config->get("Position["x"]");
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    learn php. https://php.net/string
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    He already knew that.
    And actually to retrieve this
    Code:
    - something
     - of
     - yaml
     - syntax
    
    is impossible!
    To retrieve things like array or string with key of player's name:
    Code:
    Steve: string
    Shoghicp:
     - is # 0
     - tired # 1
     of: this # 3, and this is Associative arrays
    # This is comment if you didn't know
    
    PHP:
    $config// Contains Config object connect with file's content above
    $config->get('Creeper'); // Null as the key not exist
    $string $config->get('Steve');
    echo 
    $string// string
    $array $config->get('Shoghicp');
    var_dump($array); // array(1) { ["Shoghicp"]=> array(3) { [0]=> string(2) "is" [1]=> string(5) "tired" ["of"]=> string(4) "this" } }
  6. Taki21
    Offline

    Taki21 New Member

    Joined:
    Sep 24, 2015
    Posts:
    11
    Minecraft User:
    Taki21
    I saw this somewhere + I know PHP :p

    -Thing
    - inside thing1
    - inside thing2 *this*
    - inside thing3

    It is Possible to get*this*
    That piece of code was used in a SG Plugin
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then why you
    PHP:
    "$array["key"]"
    ?
  8. Taki21
    Offline

    Taki21 New Member

    Joined:
    Sep 24, 2015
    Posts:
    11
    Minecraft User:
    Taki21
    Here is where if found



    PHP:
    if($this->PlayerIsInGame($event->getPlayer()->getName()) || ($block->getX()==$sign["x"] && $block->getY()==$sign["y"] && $block->getZ()==$sign["z"] && $block->getLevel()->getFolderName()==$sign["level"]) || $block->getLevel()==$this->signlevel)
  9. Taki21
    Offline

    Taki21 New Member

    Joined:
    Sep 24, 2015
    Posts:
    11
    Minecraft User:
    Taki21
    He put $sign = $this->config->get("sign");

Share This Page

Advertisement