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

Solved Add a string to a config array?

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

  1. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Replace if not exist
    Legoboy0215 likes this.
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    But how would this help me? setNested("legoboy.???");
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    For example you want to save player's home coordinates and then recieve them.
    PHP:
    $config->setNested($player->getName(), array(
        
    'x' => $player->getFloorX(),
        
    'y' => $player->getFloorY(),
        
    'z' => $player->getFloorZ()
    ));
    // Now this information is only on your RAM (cached)
    // Doing $config->get();
    // Will try to find it on hard drive. *more time*
    // But you can get it by doing ->
    $coordinates $config->getNested($player->getName());
    // will return array of coordinates set above this line
    // Now you've stopped playing around, in case you want to use
    // This data later you must save it on hard drive
    $config->save();
    // And taddaaa cour cached data is now written into file
    // and is accessable by ->get() method.
    Legoboy0215 likes this.
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    @Primus thanks! That was some totally new information to me :)
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    @Primus, setNested() combined with @PEMapModder's $array[] = "legoboy" actually did the trick!!! Solved :)
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    BTW, be aware that getNested() may not work well if you combine it with set().
  7. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Hm... Is it because it is cached? Btw, I only use setNested now :p
    PEMapModder likes this.

Share This Page

Advertisement