Hello, guys. Im still newbie on coding, and I'm develop PvP plugin now... My question is, I want to make it with multi world support, and I want my config.yml looks like this Code: worlds: pvp, parkour, survival How can I make that in array? Sorry for my bad English
Your config would have to look like this: Code: worlds: "world1, world2, etc" PHP: //$worlds is the Configs worlds key (do this yourself :P)$parts = explode(" ", str_replace(",", "", $worlds));foreach($parts as $wName) { array_push($this->worlds, $server->getLevelByName($wName));} This should add all the worlds to a variable called $this->worlds.
Use Code: worlds: - pvp - parkour - survival and in the code: Code: $worlds = $this->getConfig()->get("worlds"); $worlds will be an array with ["pvp", "parkour", "survival"] in it.
array_push will save them on an array. To save on config `$this->getConfig()->set("Worlds", $world);`
Will this work? PHP: $worlds = $this->getConfig()->get("worlds");if(in_array($level, $worlds)){ //code} Of course I was define $level
??? Unless you have an object serialized and saved into the config, a string would not be equal to a object.
If you have already got the level name, why do you try to get the level object and get the level name from the search again?