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

Use code to generate config

Comments in 'Plugin Development' started by Legoboy0215, Jul 7, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I use this to generate configs:
    PHP:
    new Config($this->getDataFolder()."prefences.yml"Config::YAML, array....
    In the array, I have this:
    PHP:
                    "items" => array(
                        array(
    102),
                        array(
    102)
                    ),
    But this generates this:
    items:
    - - 1
    - 0
    - 2
    I want it to be like this:
    items:
    - "295:0:1"
    - "458:0:1"
    How do I do that?
  2. InusualZ
    Offline

    InusualZ Active Member Plugin Developer

    Joined:
    Aug 23, 2013
    Posts:
    218
    Plugins:
    1
    Minecraft User:
    Inusu4lZ
    Instead of creating a array enclose does values into a string. Then if you want to split them just use explode
    Legoboy0215 likes this.
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    How? Example please?
  4. iiDeathStrokeii
    Offline

    iiDeathStrokeii Active Member

    Joined:
    Mar 30, 2015
    Posts:
    111
    Minecraft User:
    iiDeathstrokeii
    Associative arrays :)
  5. iiDeathStrokeii
    Offline

    iiDeathStrokeii Active Member

    Joined:
    Mar 30, 2015
    Posts:
    111
    Minecraft User:
    iiDeathstrokeii
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    ??? IDK how I can use it here...
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    To convert "a:b" into [a, b] :
    PHP:
    $array explode(":"$string);
    The opposite:
    PHP:
    $string implode(":"$array);
    Xenturio and Legoboy0215 like this.

Share This Page

Advertisement