diff --git a/PocketMine-MP.php b/PocketMine-MP.php index 78ca2a2ee..6a7603af8 100644 --- a/PocketMine-MP.php +++ b/PocketMine-MP.php @@ -36,7 +36,7 @@ const PHP_VERSION = "5.5"; }else{ $path = ""; } - $fPath = PATH . "src" . DIRECTORY_SEPARATOR . $path . $className . ".php"; + $fPath = \PocketMine\PATH . "src" . DIRECTORY_SEPARATOR . $path . $className . ".php"; if(file_exists($fPath)){ require_once($fPath); } @@ -47,7 +47,7 @@ const PHP_VERSION = "5.5"; }else{ $path = ""; } - $fPath = PATH . "plugins". DIRECTORY_SEPARATOR . $parent . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . $path . $className . ".php"; + $fPath = \PocketMine\PATH . "plugins". DIRECTORY_SEPARATOR . $parent . DIRECTORY_SEPARATOR . "src" . DIRECTORY_SEPARATOR . $path . $className . ".php"; if(file_exists($fPath)){ require_once($fPath); } @@ -274,7 +274,7 @@ function log($message, $name, $EOL = true, $level = 2, $close = false){ $fpointers = array(); } if(!isset($fpointers[$name]) or $fpointers[$name] === false){ - $fpointers[$name] = @fopen(DATA."/".$name.".log", "ab"); + $fpointers[$name] = @fopen(\PocketMine\DATA."/".$name.".log", "ab"); } @fwrite($fpointers[$name], $message); if($close === true){ @@ -344,17 +344,17 @@ if($errors > 0){ } $gitsha1 = false; -if(file_exists(PATH . ".git/refs/heads/master")){ //Found Git information! - define("PocketMine\GIT_COMMIT", strtolower(trim(file_get_contents(PATH .".git/refs/heads/master")))); +if(file_exists(\PocketMine\PATH . ".git/refs/heads/master")){ //Found Git information! + define("PocketMine\GIT_COMMIT", strtolower(trim(file_get_contents(\PocketMine\PATH .".git/refs/heads/master")))); }else{ //Unknown :( define("PocketMine\GIT_COMMIT", str_repeat("00", 20)); } ini_set("opcache.mmap_base", bin2hex(Utils\Utils::getRandomBytes(8, false))); //Fix OPCache address errors -require_once(PATH . "src/utils/pthreads.php"); +require_once(\PocketMine\PATH . "src/utils/pthreads.php"); -if(!file_exists(DATA . "server.properties") and !isset($opts["no-wizard"])){ +if(!file_exists(\PocketMine\DATA . "server.properties") and !isset($opts["no-wizard"])){ $installer = new Wizard\Installer(); } diff --git a/src/BanAPI.php b/src/BanAPI.php index a609543de..4c92213ac 100644 --- a/src/BanAPI.php +++ b/src/BanAPI.php @@ -40,10 +40,10 @@ class BanAPI{ } public function init(){ - $this->whitelist = new Utils\Config(DATA."white-list.txt", Utils\Config::ENUM);//Open whitelist list file - $this->bannedIPs = new Utils\Config(DATA."banned-ips.txt", Utils\Config::ENUM);//Open Banned IPs list file - $this->banned = new Utils\Config(DATA."banned.txt", Utils\Config::ENUM);//Open Banned Usernames list file - $this->ops = new Utils\Config(DATA."ops.txt", Utils\Config::ENUM);//Open list of OPs + $this->whitelist = new Utils\Config(\PocketMine\DATA."white-list.txt", Utils\Config::ENUM);//Open whitelist list file + $this->bannedIPs = new Utils\Config(\PocketMine\DATA."banned-ips.txt", Utils\Config::ENUM);//Open Banned IPs list file + $this->banned = new Utils\Config(\PocketMine\DATA."banned.txt", Utils\Config::ENUM);//Open Banned Usernames list file + $this->ops = new Utils\Config(\PocketMine\DATA."ops.txt", Utils\Config::ENUM);//Open list of OPs $this->server->api->console->register("banip", " [IP|player]", array($this, "commandHandler")); $this->server->api->console->register("ban", " [username]", array($this, "commandHandler")); $this->server->api->console->register("kick", " [reason ...]", array($this, "commandHandler")); @@ -213,7 +213,7 @@ class BanAPI{ $output .= "Player \"$user\" added to white-list\n"; break; case "reload": - $this->whitelist = new Utils\Config(DATA."white-list.txt", Utils\Config::ENUM); + $this->whitelist = new Utils\Config(\PocketMine\DATA."white-list.txt", Utils\Config::ENUM); break; case "list": $output .= "White-list: ".implode(", ", $this->whitelist->getAll(true))."\n"; @@ -258,7 +258,7 @@ class BanAPI{ $output .= "IP \"$ip\" added to ban list\n"; break; case "reload": - $this->bannedIPs = new Utils\Config(DATA."banned-ips.txt", Utils\Config::ENUM); + $this->bannedIPs = new Utils\Config(\PocketMine\DATA."banned-ips.txt", Utils\Config::ENUM); break; case "list": $output .= "IP ban list: ".implode(", ", $this->bannedIPs->getAll(true))."\n"; @@ -296,7 +296,7 @@ class BanAPI{ $output .= "Player \"$user\" added to ban list\n"; break; case "reload": - $this->banned = new Utils\Config(DATA."banned.txt", Utils\Config::ENUM); + $this->banned = new Utils\Config(\PocketMine\DATA."banned.txt", Utils\Config::ENUM); break; case "list": $output .= "Ban list: ".implode(", ", $this->banned->getAll(true))."\n"; diff --git a/src/LevelAPI.php b/src/LevelAPI.php index 6aca94846..25ce46b65 100644 --- a/src/LevelAPI.php +++ b/src/LevelAPI.php @@ -109,7 +109,7 @@ class LevelAPI{ if($name === ""){ return false; } - $path = DATA."worlds/".$name."/"; + $path = \PocketMine\DATA."worlds/".$name."/"; if($this->get($name) === false and !file_exists($path."level.pmf")){ $level = new Level\LevelImport($path); if($level->import() === false){ @@ -142,7 +142,7 @@ class LevelAPI{ console("[NOTICE] Level \"".$name."\" not found"); return false; } - $path = DATA."worlds/".$name."/"; + $path = \PocketMine\DATA."worlds/".$name."/"; console("[INFO] Preparing level \"".$name."\""); $level = new PMF\LevelFormat($path."level.pmf"); if(!$level->isLoaded){ diff --git a/src/Player.php b/src/Player.php index 79188d1c3..4b947f9e9 100644 --- a/src/Player.php +++ b/src/Player.php @@ -112,7 +112,7 @@ class Player extends Entity\RealHuman{ public static function getOffline($name){ $server = ServerAPI::request(); $iname = strtolower($name); - if(!file_exists(DATA."players/".$iname.".dat")){ + if(!file_exists(\PocketMine\DATA."players/".$iname.".dat")){ $nbt = new NBT\Tag\Compound(false, array( "Pos" => new NBT\Tag\Enum("Pos", array( 0 => new NBT\Tag\Double(0, $server->spawn->x), @@ -149,8 +149,8 @@ class Player extends Entity\RealHuman{ $nbt->Inventory->setTagType(NBT\TAG_Compound); $nbt->Motion->setTagType(NBT\TAG_Double); $nbt->Rotation->setTagType(NBT\TAG_Float); - if(file_exists(DATA."players/".$iname.".yml")){ - $data = new Utils\Config(DATA."players/".$iname.".yml", Utils\Config::YAML, array()); + if(file_exists(\PocketMine\DATA."players/".$iname.".yml")){ + $data = new Utils\Config(\PocketMine\DATA."players/".$iname.".yml", Utils\Config::YAML, array()); $nbt->playerGameType = (int) $data->get("gamemode"); $nbt->Level = $data->get("position")["level"]; $nbt->Pos[0] = $data->get("position")["x"]; @@ -197,7 +197,7 @@ class Player extends Entity\RealHuman{ foreach($data->get("achievements") as $achievement => $status){ $nbt->Achievements[$achievement] = new NBT\Tag\Byte($achievement, $status == true ? 1:0); } - unlink(DATA."players/".$iname.".yml"); + unlink(\PocketMine\DATA."players/".$iname.".yml"); }else{ console("[NOTICE] Player data not found for \"".$iname."\", creating new profile"); Player::saveOffline($name, $nbt); @@ -205,7 +205,7 @@ class Player extends Entity\RealHuman{ }else{ $nbt = new NBT(NBT\BIG_ENDIAN); - $nbt->read(file_get_contents(DATA."players/".$iname.".dat")); + $nbt->read(file_get_contents(\PocketMine\DATA."players/".$iname.".dat")); $nbt = $nbt->getData(); } @@ -218,7 +218,7 @@ class Player extends Entity\RealHuman{ ServerAPI::request()->handle("player.offline.save", $nbtTag); $nbt = new NBT(NBT\BIG_ENDIAN); $nbt->setData($nbtTag); - file_put_contents(DATA."players/".strtolower($name).".dat", $nbt->write()); + file_put_contents(\PocketMine\DATA."players/".strtolower($name).".dat", $nbt->write()); } public static function broadcastPacket(array $players, Network\Protocol\DataPacket $packet){ diff --git a/src/PluginAPI.php b/src/PluginAPI.php index 7e4b2cc8e..7b801a71f 100644 --- a/src/PluginAPI.php +++ b/src/PluginAPI.php @@ -169,7 +169,7 @@ class PluginAPI extends \stdClass{ } public function pluginsPath(){ - $path = join(DIRECTORY_SEPARATOR, array(DATA."plugins", "")); + $path = join(DIRECTORY_SEPARATOR, array(\PocketMine\DATA."plugins", "")); @mkdir($path); return $path; } diff --git a/src/ServerAPI.php b/src/ServerAPI.php index ea4ee7458..c15fce5a1 100644 --- a/src/ServerAPI.php +++ b/src/ServerAPI.php @@ -92,9 +92,9 @@ class ServerAPI{ } public function load(){ - @mkdir(DATA."players/", 0755); - @mkdir(DATA."worlds/", 0755); - @mkdir(DATA."plugins/", 0755); + @mkdir(\PocketMine\DATA."players/", 0755); + @mkdir(\PocketMine\DATA."worlds/", 0755); + @mkdir(\PocketMine\DATA."plugins/", 0755); //Init all the events foreach(get_declared_classes() as $class){ @@ -107,7 +107,7 @@ class ServerAPI{ console("[INFO] Starting Minecraft PE server version ".Utils\TextFormat::AQUA.MINECRAFT_VERSION); console("[INFO] Loading properties..."); - $this->config = new Utils\Config(DATA . "server.properties", Utils\Config::PROPERTIES, array( + $this->config = new Utils\Config(\PocketMine\DATA . "server.properties", Utils\Config::PROPERTIES, array( "server-name" => "Minecraft: PE Server", "description" => "Server made using PocketMine-MP", "motd" => "Welcome @player to this server!", diff --git a/src/entity/notimplemented/Arrow.php b/src/entity/notimplemented/Arrow.php deleted file mode 100644 index e48f3ee81..000000000 --- a/src/entity/notimplemented/Arrow.php +++ /dev/null @@ -1,27 +0,0 @@ -seed = $seed !== false ? (int) $seed:Utils\Utils::readInt(Utils\Utils::getRandomBytes(4, false)); $this->random = new Utils\Random($this->seed); $this->height = (int) $height; - $this->path = DATA."worlds/".$name."/"; + $this->path = \PocketMine\DATA."worlds/".$name."/"; $this->generator = $generator; $level = new PMF\LevelFormat($this->path."level.pmf", array( "name" => $name, diff --git a/src/pmf/Level.php b/src/pmf/LevelFormat.php similarity index 100% rename from src/pmf/Level.php rename to src/pmf/LevelFormat.php diff --git a/src/tests/ServerSuiteTest.php b/src/tests/ServerSuiteTest.php index f6ad4dc15..97a94316a 100644 --- a/src/tests/ServerSuiteTest.php +++ b/src/tests/ServerSuiteTest.php @@ -16,8 +16,8 @@ exit(0);//TODO if(!class_exists("Server", false)){ define("NO_THREADS", true); require_once(dirname(__FILE__)."/../dependencies.php"); - require_once(PATH."/src/functions.php"); - require_once(PATH."/src/dependencies.php"); + require_once(\PocketMine\PATH."/src/functions.php"); + require_once(\PocketMine\PATH."/src/dependencies.php"); console(Utils\TextFormat::GREEN . "[TEST] Starting tests"); testCase("dummy", dummy(), null); $t = new ServerSuiteTest; diff --git a/src/wizard/Installer.php b/src/wizard/Installer.php index 2492121dc..1c157a4d7 100644 --- a/src/wizard/Installer.php +++ b/src/wizard/Installer.php @@ -84,7 +84,7 @@ LICENSE; } private function generateBaseConfig(){ - $config = new Utils\Config(DATA . "server.properties", Utils\Config::PROPERTIES); + $config = new Utils\Config(\PocketMine\DATA . "server.properties", Utils\Config::PROPERTIES); echo "[?] ".$this->lang->name_your_server." (".self::DEFAULT_NAME."): "; $config->set("server-name", $this->getInput(self::DEFAULT_NAME)); echo "[*] ".$this->lang->port_warning."\n"; @@ -124,13 +124,13 @@ LICENSE; if($op === ""){ echo "[!] ".$this->lang->op_warning."\n"; }else{ - $ops = new Utils\Config(DATA."ops.txt", Utils\Config::ENUM); + $ops = new Utils\Config(\PocketMine\DATA."ops.txt", Utils\Config::ENUM); $ops->set($op, true); $ops->save(); } echo "[*] ".$this->lang->whitelist_info."\n"; echo "[?] ".$this->lang->whitelist_enable." (y/N): "; - $config = new Utils\Config(DATA . "server.properties", Utils\Config::PROPERTIES); + $config = new Utils\Config(\PocketMine\DATA . "server.properties", Utils\Config::PROPERTIES); if(strtolower($this->getInput("n")) === "y"){ echo "[!] ".$this->lang->whitelist_warning."\n"; $config->set("white-list", true); @@ -141,7 +141,7 @@ LICENSE; } private function networkFunctions(){ - $config = new Utils\Config(DATA . "server.properties", Utils\Config::PROPERTIES); + $config = new Utils\Config(\PocketMine\DATA . "server.properties", Utils\Config::PROPERTIES); echo "[!] ".$this->lang->query_warning1."\n"; echo "[!] ".$this->lang->query_warning2."\n"; echo "[?] ".$this->lang->query_disable." (y/N): "; diff --git a/src/wizard/InstallerLang.php b/src/wizard/InstallerLang.php index 689391d98..2dc5f7f66 100644 --- a/src/wizard/InstallerLang.php +++ b/src/wizard/InstallerLang.php @@ -46,11 +46,11 @@ use PocketMine; private $lang; private $langfile; public function __construct($lang = ""){ - if(file_exists(PATH."src/lang/Installer/".$lang.".ini")){ + if(file_exists(\PocketMine\PATH."src/lang/Installer/".$lang.".ini")){ $this->lang = $lang; - $this->langfile = PATH."src/lang/Installer/".$lang.".ini"; + $this->langfile = \PocketMine\PATH."src/lang/Installer/".$lang.".ini"; }else{ - $l = glob(PATH."src/lang/Installer/".$lang."_*.ini"); + $l = glob(\PocketMine\PATH."src/lang/Installer/".$lang."_*.ini"); if(count($l) > 0){ $files = array(); foreach($l as $file){ @@ -61,14 +61,14 @@ use PocketMine; $l = key($files); $l = substr($l, strrpos($l, "/") + 1, -4); $this->lang = isset(self::$languages[$l]) ? $l:$lang; - $this->langfile = PATH."src/lang/Installer/".$l.".ini"; + $this->langfile = \PocketMine\PATH."src/lang/Installer/".$l.".ini"; }else{ $this->lang = "en"; - $this->langfile = PATH."src/lang/Installer/en.ini"; + $this->langfile = \PocketMine\PATH."src/lang/Installer/en.ini"; } } - $this->loadLang(PATH."src/lang/Installer/en.ini", "en"); + $this->loadLang(\PocketMine\PATH."src/lang/Installer/en.ini", "en"); if($this->lang !== "en"){ $this->loadLang($this->langfile, $this->lang); }