Skip to content

Instantly share code, notes, and snippets.

@zhuowei
Created May 17, 2013 00:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zhuowei/5596202 to your computer and use it in GitHub Desktop.
Save zhuowei/5596202 to your computer and use it in GitHub Desktop.
Multiworld loader for PocketMine
<?php
/*
__PocketMine Plugin__
name=MultiWorld
description=Quick and dirty multiworld loader for PocketMine
version=1.0
author=zhuowei
class=MultiWorldPlugin
apiversion=7
*/
/*
Small Changelog
===============
1.0: Initial release
*/
class MultiWorldPlugin implements Plugin{
private $api;
public function __construct(ServerAPI $api, $server = false){
$this->api = $api;
}
public function init(){
$this->loadAllWorlds();
}
public function loadAllWorlds() {
$path = DATA_PATH."worlds/";
$files = scandir($path);
foreach($files as $f) {
if ($f !== "." && $f !== ".." && is_dir($path.$f)) {
$this->api->level->generateLevel($f);
$this->api->level->loadLevel($f);
}
}
}
public function __destruct(){
}
}
@shoghicp
Copy link

Also, a fix has been released to PocketMine-MP so already loaded worlds return true on LevelAPI::loadLevel()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment