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

Setting a array in YAML.

Comments in 'Plugin Development' started by Legoboy0215, Oct 6, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Title says it all. Is there any way to do that?
    PHP:
    $config->set("example""hi");
    Would work, but an array would throw an error at me.
    Any suggestions?
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Show me how you did it. You might have done it wrong, for all I know.
    PHP:
    $config->set("key", array(123));
    AppPhil likes this.
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    and how can i add array without key?
    (code from pocketjobs, but i need another way like $config->set())
    PHP:
    $this->joblist = new Config($this->getDataFolder() . "joblist.yml"Config::YAML,
    array(
    'woodcutter' => array(
    'break' => array(
    array(
    'ID' => Block::WOOD,
    'meta' => 0,
    'amount' => 25
    ),
    array(
    'ID' => Block::WOOD,
    'meta' => 1,
    'amount' => 25
    ),
    array(
    'ID' => Block::WOOD,
    'meta' => 2,
    'amount' => 25
    ),
    array(
    'ID' => Block::WOOD,
    'meta' => 3,
    'amount' => 25
    ),
    ),
    'place' => array(
    array(
    'ID' => Block::SAPLING,
    'meta' => 0,
    'amount' => 1
    ),
    array(
    'ID' => Block::SAPLING,
    'meta' => 1,
    'amount' => 1
    ),
    array(
    'ID' => Block::SAPLING,
    'meta' => 2,
    'amount' => 1
    ),
    array(
    'ID' => Block::SAPLING,
    'meta' => 3,
    'amount' => 1
    )
    )
    ),
    'miner' => array(
    'break' => array(
    array(
    'ID' => Block::STONE,
    'meta' => 0,
    'amount' => 3
    ),
    array(
    'ID' => Block::GOLD_ORE,
    'meta' => 0,
    'amount' => 25
    ),
    array(
    'ID' => Block::IRON_ORE,
    'meta' => 0,
    'amount' => 20
    ),
    array(
    'ID' => Block::LAPIS_ORE,
    'meta' => 0,
    'amount' => 17
    ),
    array(
    'ID' => Block::OBSIDIAN,
    'meta' => 0,
    'amount' => 9
    ),
    array(
    'ID' => Block::DIAMOND_ORE,
    'meta' => 0,
    'amount' => 80
    ),
    array(
    'ID' => Block::REDSTONE_ORE,
    'meta' => 0,
    'amount' => 10
    )
    )
    )
    ));
  4. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    hm keys are 0, 1, 2, 3, 4 but in config i only see:
    - I:eek: 3
    meta: 0
    amount: 1
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Can you please indent things properly?
  6. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    I think i found a solution :D
  7. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    He doesn't want to make a new Config, he only wants to set a value of a key to an array. Please read it thoroughly next time. :)
    I doubt he'll keep this in mind. #OCD
    Legoboy0215 likes this.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is not OCD. Indenting solves 90% of the problems actually.

Share This Page

Advertisement