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

Config Files

Comments in 'Plugin Development' started by Samueljh1, Feb 3, 2015.

  1. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Hi guys, I need help with config files.

    I can do this:

    PHP:

            
    foreach($this->getConfig()->get('kits') as $kitName => $kitParams){

                
    $count $count+1;
                
    array_push($list$kitName);

            }

    But... i want to get the data in 'kits': 'items'.

    Here is a snippet of the yml, to help you get a better understanding! :)

    PHP:

    kits
    #FORMAT '<slot>': '<id>:<amount>:<data>'
     
    pvp:
      
    kit-msg"Kit 'PvP' Received!" #Msg To Run When a Kit is Given.

      
    items:
       
    helmet'298'
       
    chestplate'303'
       
    leggings'304'
       
    boots'301'
       '0'
    '272'
       '1'
    '260:5'
  2. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    I actually don't know. Can anyone tell me also how to use YML files in the plugins?
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $this->getConfig()->get("kits")["pvp"]["items"];
    Nobody is asking you in specific.
    hoyinm14mc, 64FF00 and iJoshuaHD like this.
  4. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Doesnt work, already tried that :p
  5. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,196
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    a var_dump would be a good solution to check your mistakes.
  6. 64FF00
    Offline

    64FF00 Active Member Plugin Developer

    Joined:
    May 11, 2014
    Posts:
    298
    Plugins:
    2
    Minecraft User:
    64FF00
    PHP:
    // Get kit-msg
    var_dump($this->getConfig()->getNested("kits.pvp.kit-msg"));
    PHP:
    $cfg_arr $this->getConfig()->getAll();
    // Get kit-msg
    var_dump($cfg_arr["kits"]["pvp"]["kit-msg"]);
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then that means somewhere else is wrong. Whole code?
  8. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    ty, ill try that! :)
  9. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Nvm, i have worked it out! Just one thing... if i have an array, that is imploded, how would i get each section of it?

    Eg:

    PHP:

    $myString 
    $implode(","$myArray);

    echo 
    "Converted Array: $myString";

    Code:
    "Convered Array: "hello,world"
    
    
    How would I get the words "hello" and "world" from a string "hello,world'?

    (Because doing [Number] from an array would for example with '0', would return the first character, not the first item in the array!

    Thanks.
  10. Angelo Vidrio
    Offline

    Angelo Vidrio Active Member Plugin Developer

    Joined:
    Jan 16, 2014
    Posts:
    123
    Plugins:
    5
    Minecraft User:
    LilCrispy45
    How did you fix the problem?
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    explode() it.
    Also function names don't start with $.
    64FF00 likes this.
  12. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    lol typo
  13. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    O yea xD #FacePalm

Share This Page

Advertisement