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

How get many config data

Comments in 'Plugin Development' started by korado531m7, Dec 12, 2015.

  1. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    hi. I'm creating plugin. but i don't know how to get many config data.
    for ex,
    Config below:

    data1:
    item-id: 10
    item-damage: 0
    data2:
    item-id: 19
    item-damage: 0
    data3:
    item-id: 42
    item-damage: 0

    #and more...

    Thank you for reading, and answering.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    That depends on how you want to get them (what should be the format of output). If you just want an array for all of them, simply getAll(). Otherwise, tell us how you are going to use it.

    Next time enclose your code/YAML with [code][/code]
  3. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    How do you save your config?
  4. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    i'll use resources
  5. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    I'll try it.
  6. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    How do i get many item id,damage?
    Code:
    data1:
    item-id: 10
    item-damage: 0
    data2:
    item-id: 19
    item-damage: 0
    data3:
    item-id: 42
    item-damage: 0
    
    PHP:
    Item::get(["item-id"],["item-damage"])
    please tell me
  7. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    $config->getNested("data1.item-id");
    Will return the item-id of data1. Important:
    Code:
    data1:
     item-id: 10
     item-damage: 0
    data2:
     item-id: 19
     item-damage: 0
    data3:
     item-id: 42
     item-damage: 0
    Your config has to be like this, otherwise item-id etc isn't a data of data1, data2 etc
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is easier if your config is like this:
    Code:
    - item-id: 1
      item-damage: 0
    - item-id: 2
      item-damage: 0
    
    PHP:
     $items array_map(function($i){
      return 
    Item::get($i["item-id"], $i["item-damage"]);
    }, 
    $config->getAll());

Share This Page

Advertisement