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

I have two questions

Comments in 'Plugin Development' started by BlubberBoy333, Aug 11, 2015.

  1. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I have two things i need help with.
    The first question is how can i spawn a tree? Is it something like this:
    PHP:
    Tree::growTree($x$y$z$level)
    Or is it something else

    The second question is how can i make multiple config files?
    I know i can do this:
    PHP:
    $newConfig = new Config($this->getDataFolder()."newConfig.yml" Config::YAML)
    but then how can i get the data from that config?
    Last edited: Aug 11, 2015
  2. TigerHix
    Offline

    TigerHix Active Member

    Joined:
    May 11, 2015
    Posts:
    61
    Minecraft User:
    TigerHix
    1. Yes. More accurately,

    PHP:
    Tree::growTree($level$x$y$z, new Random(mt_rand()), Sapling::OAK);
    Of course you can easily change the tree type by adjusting the last parameter to something else.

    2. Just like what you'll normally get data from a config.

    PHP:
    $duration $newConfig->get("speed-boost-duration"40); // Get configuration value of key "speed-boost-duration" from config, if it does not exist, return default value 40
  3. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    The reason i'm asking this is because on my SkyBlock plugin I want to have a file for every island.
    So when a player makes an island it makes a config for that island
    PHP:
    $islandConfig = new Config($this->getDataFolder()."Islands/".$player->getName().".yml"Config::YAML)
    In the config it sets the coordinates and the world that it is in.
    When a player wants to teleport back to their island I need to get the world, and the position from that config. That would be easy if there was only one config file, but I need to find one file out of hundreds.
    I have this function later in my plugin:
    PHP:
    public function getIsland($island){
            
    $file = new Config($this->getDataFolder()."Islands/".$island.".yml"Config::YAML);
            return 
    $file->getAll();
        }
    But when i call that function it crashes the server and says i can't use the get() function on an array
  4. Gamecrafter
    Offline

    Gamecrafter Notable Member Plugin Developer

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Of course you can't use get() on an array! You have to use $file[$string_here] to get it from the file. Mind if I take a look at the code?
  5. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    Sure, i'll PM it to you
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    If you have so many configs, I think better use ENUM or if you can, MySQL or SQLlite
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Actually, you could just use yaml_parse_file().
  8. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    So right now i have the files set up to where the island coordinates are.
    (You can see an example file below)
    When i do file_get_contents or yaml_parse_file it only returns 163, which is the X coordinate
    How can i fix this?

    Attached Files:

    Last edited: Aug 12, 2015
  9. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    It used to work fine, but i changed it a bit and now it won't work (i'm using the same way i did before i changed it)

Share This Page

Advertisement