diff --git a/.gitignore b/.gitignore
index a84f67b7..fd7fa6ba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,11 @@
-data/players/*
-data/maps/*
-data/plugins/*
+players/*
+worlds/*
+plugins/*
+logs/*
*.log
server.properties
white-list.txt
banned-ips.txt
-console.in
#################
## Eclipse
diff --git a/server.php b/PocketMine-MP.php
similarity index 91%
rename from server.php
rename to PocketMine-MP.php
index e9fc7bd5..853f902a 100644
--- a/server.php
+++ b/PocketMine-MP.php
@@ -12,9 +12,9 @@ the Free Software Foundation, either version 3 of the License, or
*/
-require_once("common/dependencies.php");
+require_once("src/common/dependencies.php");
require_once("classes/PocketMinecraftServer.class.php");
-require_once("classes/API/ServerAPI.php");
+require_once("API/ServerAPI.php");
while(true){
$server = new ServerAPI();
diff --git a/README.md b/README.md
index 44dfba37..a12a4202 100644
--- a/README.md
+++ b/README.md
@@ -32,12 +32,13 @@ along with this program. If not, see .
# PocketMine-MP
-Github repo: https://github.com/shoghicp/PocketMine-MP
+PocketMine-MP is a Server for Minecraft Pocket Edition done in PHP. It has a Plugin API that enables a developer to extend it and add new features, or change default ones.
-Server (and client) Minecraft Pocket Edition library written in PHP.
-Currently a work in progress, and used to document http://www.wiki.vg/Pocket_Minecraft_Protocol
+The entire server is done in PHP, and has been tested, profiled and optimized to run smoothly.
-Check the wiki! https://github.com/shoghicp/PocketMine-MP/wiki
+[Go to Wiki for more information](https://github.com/shoghicp/PocketMine-MP/wiki)
+
+[FAQ: Frequently Asked Questions](https://github.com/shoghicp/PocketMine-MP/wiki/Frequently-Asked-Questions)
**Project Status: `ALPHA`**
@@ -61,7 +62,10 @@ Check the wiki! https://github.com/shoghicp/PocketMine-MP/wiki
## Third-party Libraries Used
-
-* __[PHP NBT](https://github.com/TheFrozenFire/PHP-NBT-Decoder-Encoder/blob/master/nbt.class.php)__ by _[TheFrozenFire](https://github.com/TheFrozenFire)_: Class for reading in NBT-format files
+* __[PHP cURL](http://php.net/manual/en/book.curl.php)__
+* __[PHP Sockets](http://php.net/manual/en/book.sockets.php)__
+* __[PHP SQLite3](http://php.net/manual/en/book.sqlite3.php)__
+* __[PHP pthreads](https://github.com/krakjoe/pthreads)__ by _[krakjoe](https://github.com/krakjoe)_: Threading for PHP - Share Nothing, Do Everything
+* __[PHP NBT](https://github.com/TheFrozenFire/PHP-NBT-Decoder-Encoder/blob/master/nbt.class.php)__ by _[TheFrozenFire](https://github.com/TheFrozenFire)_: Class for reading in NBT-format files (modified to handle Little-Endian files)
* __[Math_BigInteger](http://phpseclib.sourceforge.net/math/intro.html)__ by _[phpseclib](http://phpseclib.sourceforge.net/)_: Pure-PHP arbitrary precission integer arithmetic library
* __[Spyc](https://github.com/mustangostang/spyc/blob/master/Spyc.php)__ by _[Vlad Andersen](https://github.com/mustangostang)_: A simple YAML loader/dumper class for PHP
\ No newline at end of file
diff --git a/data/How To Import Maps.txt b/data/How To Import Maps.txt
deleted file mode 100644
index 1f6370c7..00000000
--- a/data/How To Import Maps.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-To import a Pocket Edition Map, drop to the folder "maps"
-the chunk.dat, level.dat and entities.dat from the savegame file.
\ No newline at end of file
diff --git a/example/ExamplePlugin.php b/example/ExamplePlugin.php
deleted file mode 100644
index 7a32f155..00000000
--- a/example/ExamplePlugin.php
+++ /dev/null
@@ -1,34 +0,0 @@
-api = $api;
- }
-
- public function init(){
- $this->api->console->register("example", "Example command", array($this, "handleCommand"));
- }
-
- public function __destruct(){
-
- }
-
- public function handleCommand($cmd, $arg){
- switch($cmd){
- case "example":
- console("EXAMPLE!!!");
- break;
- }
- }
-
-}
\ No newline at end of file
diff --git a/example/ReactorAsWater.php b/example/ReactorAsWater.php
deleted file mode 100644
index 3315b038..00000000
--- a/example/ReactorAsWater.php
+++ /dev/null
@@ -1,46 +0,0 @@
-api = $api;
- }
-
- public function init(){
- $this->api->addHandler("player.block.action", array($this, "handle"), 15); //Priority higher that API
- $this->api->addHandler("player.equipment.change", array($this, "handle"), 15);
- }
-
- public function __destruct(){
-
- }
-
- public function handle(&$data, $event){
- switch($event){
- case "player.equipment.change":
- if($data["block"] === 247){
- $this->api->player->getByEID($data["eid"])->eventHandler("[ReactorAsWater] Placing water", "server.chat");
- $data["block"] = 9;
- $data["meta"] = 0;
- }
- break;
- case "player.block.action":
- if($data["block"] === 247){ //nether reactor
- $data["block"] = 9; //water source
- $data["meta"] = 0;
- }
- break;
- }
- }
-
-}
\ No newline at end of file
diff --git a/example/SpawnChanger.php b/example/SpawnChanger.php
deleted file mode 100644
index 37b41670..00000000
--- a/example/SpawnChanger.php
+++ /dev/null
@@ -1,105 +0,0 @@
-api = $api;
- }
-
- public function init(){
- $spawn = $this->api->level->getSpawn();
- $this->path = $this->api->plugin->createConfig($this, array(
- "spawnX" => $spawn["x"],
- "spawnY" => $spawn["y"],
- "spawnZ" => $spawn["z"],
- "custom-spawn" => false,
- "force-spawn" => false,
- ));
- $this->config = $this->api->plugin->readYAML($this->path."config.yml");
- if($this->config["custom-spawn"] === false){
- $this->config["spawnX"] = $spawn["x"];
- $this->config["spawnY"] = $spawn["y"];
- $this->config["spawnZ"] = $spawn["z"];
- $this->api->plugin->writeYAML($this->path."config.yml", $this->config);
- }
- $this->api->addHandler("api.player.offline.get", array($this, "handle"), 15);
- $this->api->console->register("spawnchanger", "SpawnChanger init point managing", array($this, "command"));
- $this->api->console->register("spawn", "Teleports to spawn", array($this, "command"));
- }
-
- public function __destruct(){
-
- }
-
- public function command($cmd, $args){
- switch($cmd){
- case "spawnchanger":
- switch(strtolower(array_shift($args))){
- case "force":
- $l = array_shift($args);
- if($l != "0" and $l != "1"){
- console("[SpawnChanger] Usage: /spawnchanger force <1 | 0>");
- }else{
- $this->config["force-spawn"] = $l == "0" ? false:true;
- if($this->config["force-spawn"] === true){
- console("[SpawnChanger] Forced spawn point");
- }else{
- console("[SpawnChanger] Freed pawn point");
- }
- $this->api->plugin->writeYAML($this->path."config.yml", $this->config);
- }
- break;
- case "set":
- $z = array_pop($args);
- $y = array_pop($args);
- $x = array_pop($args);
- if($x === null or $y === null or $z === null){
- console("[SpawnChanger] Usage: /spawnchanger set ");
- }else{
- $this->config["custom-spawn"] = true;
- $this->config["spawnX"] = (float) $x;
- $this->config["spawnY"] = (float) $y;
- $this->config["spawnZ"] = (float) $z;
- console("[SpawnChanger] Spawn point set at X ".$this->config["spawnX"]." Y ".$this->config["spawnY"]." Z ".$this->config["spawnZ"]);
- $this->api->plugin->writeYAML($this->path."config.yml", $this->config);
- }
- break;
- default:
- console("[SpawnChanger] Always spawn player in spawn point: /spawnchanger force <1 | 0>");
- console("[SpawnChanger] Set the spawn point: /spawnchanger set ");
- break;
- }
- break;
- case "spawn":
- if($this->api->player->tppos(implode(" ", $args), $this->config["spawnX"], $this->config["spawnY"], $this->config["spawnZ"]) !== false){
- console("[SpawnChanger] Teleported to spawn!");
- }else{
- console("[SpawnChanger] Usage: /spawn ");
- }
- break;
- }
- }
-
- public function handle(&$data, $event){
- switch($event){
- case "api.player.offline.get":
- if($this->config["force-spawn"] === true){
- $data["spawn"]["x"] = $this->config["spawnX"];
- $data["spawn"]["y"] = $this->config["spawnY"];
- $data["spawn"]["z"] = $this->config["spawnZ"];
- }
- break;
- }
- }
-
-}
\ No newline at end of file
diff --git a/classes/API/BlockAPI.php b/src/API/BlockAPI.php
similarity index 97%
rename from classes/API/BlockAPI.php
rename to src/API/BlockAPI.php
index f20c5394..721c9dfe 100644
--- a/classes/API/BlockAPI.php
+++ b/src/API/BlockAPI.php
@@ -44,13 +44,24 @@ class BlockAPI{
$this->server->addHandler("player.block.action", array($this, "blockAction"), 1);
}
+ private function cancelAction($block){
+ $this->server->trigger("world.block.change", array(
+ "x" => $block[2][0],
+ "y" => $block[2][1],
+ "z" => $block[2][2],
+ "block" => $block[0],
+ "meta" => $block[1],
+ ));
+ return false;
+ }
+
public function blockBreak($data, $event){
if($event !== "player.block.break"){
return;
}
$target = $this->server->api->level->getBlock($data["x"], $data["y"], $data["z"]);
if(isset(Material::$unbreakable[$target[0]])){
- return false;
+ return $this->cancelAction($target);
}
$drop = array(
$target[0], //Block
@@ -247,7 +258,10 @@ class BlockAPI{
}
if($cancelPlace === true){
- return false;
+ $this->cancelAction($target);
+ BlockFace::setPosition($data, $data["face"]);
+ $target = $this->server->api->level->getBlock($data["x"], $data["y"], $data["z"]);
+ return $this->cancelAction($target);
}
$replace = false;
@@ -275,13 +289,13 @@ class BlockAPI{
$block = $this->server->api->level->getBlock($data["x"], $data["y"], $data["z"]);
if($replace === false and !isset(Material::$replaceable[$block[0]])){
- return false;
+ return $this->cancelAction($block);
}
if(isset(Material::$placeable[$data["block"]])){
$data["block"] = Material::$placeable[$data["block"]] === true ? $data["block"]:Material::$placeable[$data["block"]];
}else{
- return false;
+ return $this->cancelAction($block);
}
$direction = $this->server->api->entity->get($data["eid"])->getDirection();
diff --git a/classes/API/ChatAPI.php b/src/API/ChatAPI.php
similarity index 100%
rename from classes/API/ChatAPI.php
rename to src/API/ChatAPI.php
diff --git a/classes/API/ConsoleAPI.php b/src/API/ConsoleAPI.php
similarity index 99%
rename from classes/API/ConsoleAPI.php
rename to src/API/ConsoleAPI.php
index a0c2a352..866504bd 100644
--- a/classes/API/ConsoleAPI.php
+++ b/src/API/ConsoleAPI.php
@@ -30,7 +30,7 @@ class ConsoleAPI{
function __construct(PocketMinecraftServer $server){
$this->help = array();
$this->server = $server;
- $this->input = fopen(FILE_PATH."console.in", "w+b");
+ $this->input = fopen(FILE_PATH."logs/console.in", "w+b");
$this->last = microtime(true);
}
diff --git a/classes/API/EntityAPI.php b/src/API/EntityAPI.php
similarity index 100%
rename from classes/API/EntityAPI.php
rename to src/API/EntityAPI.php
diff --git a/classes/API/LevelAPI.php b/src/API/LevelAPI.php
similarity index 100%
rename from classes/API/LevelAPI.php
rename to src/API/LevelAPI.php
diff --git a/classes/API/PlayerAPI.php b/src/API/PlayerAPI.php
similarity index 96%
rename from classes/API/PlayerAPI.php
rename to src/API/PlayerAPI.php
index db01cc4a..e42908fa 100644
--- a/classes/API/PlayerAPI.php
+++ b/src/API/PlayerAPI.php
@@ -189,7 +189,7 @@ class PlayerAPI{
}
public function getOffline($name){
- if(!file_exists(FILE_PATH."data/players/".$name.".dat")){
+ if(!file_exists(FILE_PATH."players/".$name.".dat")){
console("[NOTICE] Player data not found for \"".$name."\", creating new profile");
$data = array(
"spawn" => array(
@@ -203,7 +203,7 @@ class PlayerAPI{
);
$this->saveOffline($name, $data);
}else{
- $data = unserialize(file_get_contents(FILE_PATH."data/players/".$name.".dat"));
+ $data = unserialize(file_get_contents(FILE_PATH."players/".$name.".dat"));
}
$this->server->handle("api.player.offline.get", $data);
return $data;
@@ -211,6 +211,6 @@ class PlayerAPI{
public function saveOffline($name, $data){
$this->server->handle("api.player.offline.save", $data);
- file_put_contents(FILE_PATH."data/players/".str_replace("/", "", $name).".dat", serialize($data));
+ file_put_contents(FILE_PATH."players/".str_replace("/", "", $name).".dat", serialize($data));
}
}
\ No newline at end of file
diff --git a/classes/API/PluginAPI.php b/src/API/PluginAPI.php
similarity index 96%
rename from classes/API/PluginAPI.php
rename to src/API/PluginAPI.php
index 020bd629..e9e600e2 100644
--- a/classes/API/PluginAPI.php
+++ b/src/API/PluginAPI.php
@@ -115,7 +115,7 @@ class PluginAPI extends stdClass{
if($p === false){
return false;
}
- $path = FILE_PATH."data/plugins/".$p[1]["name"]."/";
+ $path = FILE_PATH."plugins/".$p[1]["name"]."/";
$this->plugins[$p[1]["class"]][1]["path"] = $path;
if(!file_exists($path."config.yml")){
@mkdir($path, 0777);
@@ -155,11 +155,11 @@ class PluginAPI extends stdClass{
public function loadAll(){
console("[INFO] Loading Plugins...");
- $dir = dir(FILE_PATH."data/plugins/");
+ $dir = dir(FILE_PATH."plugins/");
while(false !== ($file = $dir->read())){
if($file !== "." and $file !== ".."){
if(strtolower(substr($file, -3)) === "php"){
- $this->load(FILE_PATH."data/plugins/" . $file);
+ $this->load(FILE_PATH."plugins/" . $file);
}
}
}
diff --git a/classes/API/ServerAPI.php b/src/API/ServerAPI.php
similarity index 90%
rename from classes/API/ServerAPI.php
rename to src/API/ServerAPI.php
index 67873e84..e21934ac 100644
--- a/classes/API/ServerAPI.php
+++ b/src/API/ServerAPI.php
@@ -30,9 +30,14 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run
private $server, $config, $apiList = array();
function __construct(){
console("[INFO] Starting ServerAPI server handler...");
- file_put_contents(FILE_PATH."packets.log", "");
- file_put_contents(FILE_PATH."console.in", "");
- if(!file_exists(FILE_PATH."test.bin.log") or md5_file(FILE_PATH."test.bin.log") !== TEST_MD5){
+ console("[DEBUG] Checking data folders...", true, true, 2);
+ @mkdir(FILE_PATH."logs/", 0777, true);
+ @mkdir(FILE_PATH."players/", 0777);
+ @mkdir(FILE_PATH."worlds/", 0777);
+ @mkdir(FILE_PATH."plugins/", 0777);
+ file_put_contents(FILE_PATH."logs/packets.log", "");
+ file_put_contents(FILE_PATH."logs/console.in", "");
+ if(!file_exists(FILE_PATH."logs/test.bin.log") or md5_file(FILE_PATH."logs/test.bin.log") !== TEST_MD5){
console("[NOTICE] Executing integrity tests...");
console("[INFO] OS: ".PHP_OS.", ".Utils::getOS());
console("[INFO] uname -a: ".php_uname("a"));
@@ -60,7 +65,7 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run
$test .= Utils::writeLong($str->hashCode());
$test .= Utils::writeDataArray(array("a", "b", "c", "\xff\xff\xff\xff"));
$test .= Utils::hexToStr("012334567890");
- file_put_contents(FILE_PATH."test.bin.log", $test);
+ file_put_contents(FILE_PATH."logs/test.bin.log", $test);
if(md5($test) !== TEST_MD5){
console("[ERROR] Test error, please send your console.log + test.bin.log to the Github repo");
die();
@@ -79,14 +84,9 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run
if(!file_exists(FILE_PATH."server.properties")){
console("[NOTICE] No server.properties found, using default settings");
- copy(FILE_PATH."common/default.properties", FILE_PATH."server.properties");
+ copy(FILE_PATH."src/common/default.properties", FILE_PATH."server.properties");
}
- console("[DEBUG] Checking data folders...", true, true, 2);
- @mkdir(FILE_PATH."data/players/", 0777, true);
- @mkdir(FILE_PATH."data/maps/", 0777);
- @mkdir(FILE_PATH."data/plugins/", 0777);
-
console("[DEBUG] Loading server.properties...", true, true, 2);
$this->parseProperties();
define("DEBUG", $this->config["debug"]);
@@ -138,17 +138,17 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run
}
}
- if(file_exists(FILE_PATH."data/maps/level.dat")){
+ if(file_exists(FILE_PATH."worlds/level.dat")){
console("[NOTICE] Detected unimported map data. Importing...");
- $this->importMap(FILE_PATH."data/maps/", true);
+ $this->importMap(FILE_PATH."worlds/", true);
}
$this->server->mapName = $this->getProperty("level-name");
- $this->server->mapDir = FILE_PATH."data/maps/".$this->server->mapName."/";
+ $this->server->mapDir = FILE_PATH."worlds/".$this->server->mapName."/";
if($this->server->mapName === false or trim($this->server->mapName) === "" or !file_exists($this->server->mapDir."chunks.dat")){
if($this->server->mapName === false or trim($this->server->mapName) === ""){
$this->server->mapName = "world";
}
- $this->server->mapDir = FILE_PATH."data/maps/".$this->server->mapName."/";
+ $this->server->mapDir = FILE_PATH."worlds/".$this->server->mapName."/";
$generator = "SuperflatGenerator";
if($this->getProperty("generator") !== false and class_exists($this->getProperty("generator"))){
$generator = $this->getProperty("generator");
@@ -168,7 +168,7 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run
//Autoload all default APIs
console("[INFO] Loading default APIs");
- $dir = dir(FILE_PATH."classes/API/");
+ $dir = dir(FILE_PATH."src/API/");
while(false !== ($file = $dir->read())){
if($file !== "." and $file !== ".."){
$API = basename($file, ".php");
@@ -317,24 +317,24 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run
console("[DEBUG] Importing map \"".$level["LevelName"]."\" gamemode ".$level["GameType"]." with seed ".$level["RandomSeed"], true, true, 2);
unset($level["Player"]);
$lvName = $level["LevelName"]."/";
- @mkdir(FILE_PATH."data/maps/".$lvName, 0777);
- file_put_contents(FILE_PATH."data/maps/".$lvName."level.dat", serialize($level));
+ @mkdir(FILE_PATH."worlds/".$lvName, 0777);
+ file_put_contents(FILE_PATH."worlds/".$lvName."level.dat", serialize($level));
$entities = parseNBTData($nbt->loadFile($dir."entities.dat"));
- file_put_contents(FILE_PATH."data/maps/".$lvName."entities.dat", serialize($entities["Entities"]));
+ file_put_contents(FILE_PATH."worlds/".$lvName."entities.dat", serialize($entities["Entities"]));
if(!isset($entities["TileEntities"])){
$entities["TileEntities"] = array();
}
- file_put_contents(FILE_PATH."data/maps/".$lvName."tileEntities.dat", serialize($entities["TileEntities"]));
+ file_put_contents(FILE_PATH."worlds/".$lvName."tileEntities.dat", serialize($entities["TileEntities"]));
console("[DEBUG] Imported ".count($entities["Entities"])." Entities and ".count($entities["TileEntities"])." TileEntities", true, true, 2);
if($remove === true){
- rename($dir."chunks.dat", FILE_PATH."data/maps/".$lvName."chunks.dat");
+ rename($dir."chunks.dat", FILE_PATH."worlds/".$lvName."chunks.dat");
unlink($dir."level.dat");
@unlink($dir."level.dat_old");
@unlink($dir."player.dat");
unlink($dir."entities.dat");
}else{
- copy($dir."chunks.dat", FILE_PATH."data/maps/".$lvName."chunks.dat");
+ copy($dir."chunks.dat", FILE_PATH."worlds/".$lvName."chunks.dat");
}
if($this->getProperty("level-name") === false){
console("[INFO] Setting default level to \"".$level["LevelName"]."\"");
@@ -370,7 +370,7 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run
public function loadAPI($name, $class, $dir = false){
if($dir === false){
- $dir = FILE_PATH."classes/API/";
+ $dir = FILE_PATH."src/API/";
}
$file = $dir.$class.".php";
if(!file_exists($file)){
diff --git a/classes/API/TimeAPI.php b/src/API/TimeAPI.php
similarity index 100%
rename from classes/API/TimeAPI.php
rename to src/API/TimeAPI.php
diff --git a/classes/BigInteger.class.php b/src/classes/BigInteger.class.php
similarity index 100%
rename from classes/BigInteger.class.php
rename to src/classes/BigInteger.class.php
diff --git a/classes/ChunkParser.class.php b/src/classes/ChunkParser.class.php
similarity index 100%
rename from classes/ChunkParser.class.php
rename to src/classes/ChunkParser.class.php
diff --git a/classes/CustomPacketHandler.class.php b/src/classes/CustomPacketHandler.class.php
similarity index 100%
rename from classes/CustomPacketHandler.class.php
rename to src/classes/CustomPacketHandler.class.php
diff --git a/classes/Data.class.php b/src/classes/Data.class.php
similarity index 100%
rename from classes/Data.class.php
rename to src/classes/Data.class.php
diff --git a/classes/Entity.class.php b/src/classes/Entity.class.php
similarity index 96%
rename from classes/Entity.class.php
rename to src/classes/Entity.class.php
index 8c50069a..6145a999 100644
--- a/classes/Entity.class.php
+++ b/src/classes/Entity.class.php
@@ -33,8 +33,8 @@ define("ENTITY_ITEM", 3);
define("ENTITY_PAINTING", 4);
class Entity extends stdClass{
- var $eid, $type, $name, $x, $y, $z, $yaw, $pitch, $dead, $data, $class, $attach, $metadata, $closed, $player;
-
+ var $eid, $type, $name, $x, $y, $z, $yaw, $pitch, $dead, $data, $class, $attach, $metadata, $closed, $player, $onTick;
+ private $ev, $server;
function __construct($server, $eid, $class, $type = 0, $data = array()){
$this->server = $server;
$this->eid = (int) $eid;
@@ -49,6 +49,7 @@ class Entity extends stdClass{
$this->closed = false;
$this->name = "";
$this->server->query("INSERT OR REPLACE INTO entities (EID, type, class, health) VALUES (".$this->eid.", ".$this->type.", ".$this->class.", ".$this->health.");");
+ $this->ev = $this->server->event("server.tick", array($this, "update"));
$this->metadata = array();
$this->x = isset($this->data["x"]) ? $this->data["x"]:0;
$this->y = isset($this->data["y"]) ? $this->data["y"]:0;
@@ -74,6 +75,10 @@ class Entity extends stdClass{
}
}
+ public function update(){
+
+ }
+
public function getDirection(){
$rotation = ($this->yaw - 90) % 360;
if ($rotation < 0) {
@@ -147,6 +152,7 @@ class Entity extends stdClass{
if($this->closed === false){
$this->server->query("DELETE FROM entities WHERE EID = ".$this->eid.";");
$this->server->trigger("entity.remove", $this->eid);
+ $this->server->deleteEvent($this->ev);
$this->closed = true;
}
}
diff --git a/classes/Generator.class.php b/src/classes/Generator.class.php
similarity index 100%
rename from classes/Generator.class.php
rename to src/classes/Generator.class.php
diff --git a/classes/Java.class.php b/src/classes/Java.class.php
similarity index 100%
rename from classes/Java.class.php
rename to src/classes/Java.class.php
diff --git a/classes/MinecraftInterface.class.php b/src/classes/MinecraftInterface.class.php
similarity index 100%
rename from classes/MinecraftInterface.class.php
rename to src/classes/MinecraftInterface.class.php
diff --git a/classes/NBT.class.php b/src/classes/NBT.class.php
similarity index 100%
rename from classes/NBT.class.php
rename to src/classes/NBT.class.php
diff --git a/classes/Packet.class.php b/src/classes/Packet.class.php
similarity index 100%
rename from classes/Packet.class.php
rename to src/classes/Packet.class.php
diff --git a/classes/Player.class.php b/src/classes/Player.class.php
similarity index 100%
rename from classes/Player.class.php
rename to src/classes/Player.class.php
diff --git a/classes/PocketMinecraftServer.class.php b/src/classes/PocketMinecraftServer.class.php
similarity index 99%
rename from classes/PocketMinecraftServer.class.php
rename to src/classes/PocketMinecraftServer.class.php
index 30cdcdaa..a660a737 100644
--- a/classes/PocketMinecraftServer.class.php
+++ b/src/classes/PocketMinecraftServer.class.php
@@ -30,7 +30,7 @@ class PocketMinecraftServer extends stdClass{
private $database, $interface, $evCnt, $handCnt, $events, $handlers, $version, $serverType, $lastTick;
function __construct($name, $gamemode = 1, $seed = false, $protocol = CURRENT_PROTOCOL, $port = 19132, $serverID = false, $version = CURRENT_VERSION){
$this->port = (int) $port; //19132 - 19135
- console("[INFO] PocketMine-MP ".MAJOR_VERSION." by @shoghicp, LGPL License. http://bit.ly/TbrimG", true, true, 0);
+ console("[INFO] PocketMine-MP ".MAJOR_VERSION." by @shoghicp, LGPL License", true, true, 0);
console("[INFO] Starting Minecraft PE Server at *:".$this->port);
if($this->port < 19132 or $this->port > 19135){
console("[WARNING] You've selected a not-standard port. Normal port range is from 19132 to 19135 included");
diff --git a/classes/SerializedPacketHandler.class.php b/src/classes/SerializedPacketHandler.class.php
similarity index 100%
rename from classes/SerializedPacketHandler.class.php
rename to src/classes/SerializedPacketHandler.class.php
diff --git a/classes/Spyc.class.php b/src/classes/Spyc.class.php
similarity index 100%
rename from classes/Spyc.class.php
rename to src/classes/Spyc.class.php
diff --git a/classes/SuperflatGenerator.class.php b/src/classes/SuperflatGenerator.class.php
similarity index 100%
rename from classes/SuperflatGenerator.class.php
rename to src/classes/SuperflatGenerator.class.php
diff --git a/classes/UDPSocket.class.php b/src/classes/UDPSocket.class.php
similarity index 100%
rename from classes/UDPSocket.class.php
rename to src/classes/UDPSocket.class.php
diff --git a/classes/Utils.class.php b/src/classes/Utils.class.php
similarity index 100%
rename from classes/Utils.class.php
rename to src/classes/Utils.class.php
diff --git a/common/config.php b/src/common/config.php
similarity index 89%
rename from common/config.php
rename to src/common/config.php
index 82248598..f6d71707 100644
--- a/common/config.php
+++ b/src/common/config.php
@@ -32,8 +32,8 @@ error_reporting(E_ALL ^ E_NOTICE);
ini_set("allow_url_fopen", 1);
ini_set("display_errors", 1);
ini_set('default_charset', 'utf-8');
-define("FILE_PATH", dirname(__FILE__)."/../");
-set_include_path(get_include_path() . PATH_SEPARATOR . FILE_PATH . PATH_SEPARATOR . FILE_PATH . "/classes/");
+define("FILE_PATH", dirname(__FILE__)."/../../");
+set_include_path(get_include_path() . PATH_SEPARATOR . FILE_PATH . PATH_SEPARATOR . FILE_PATH . "/src/" . PATH_SEPARATOR . FILE_PATH . "/src/classes/");
ini_set("memory_limit", "256M");
define("CURRENT_PROTOCOL", 5);
define("CURRENT_VERSION", 1);
diff --git a/common/default.properties b/src/common/default.properties
similarity index 100%
rename from common/default.properties
rename to src/common/default.properties
diff --git a/common/dependencies.php b/src/common/dependencies.php
similarity index 91%
rename from common/dependencies.php
rename to src/common/dependencies.php
index 462fcf0e..36df079d 100644
--- a/common/dependencies.php
+++ b/src/common/dependencies.php
@@ -54,6 +54,11 @@ if(!extension_loaded("sockets")){
++$errors;
}
+/*if(!extension_loaded("pthreads")){
+ console("[ERROR] Unable to find pthreads extension. [https://github.com/krakjoe/pthreads]", true, true, 0);
+ ++$errors;
+}*/
+
if(!extension_loaded("curl")){
console("[ERROR] Unable to find cURL extension", true, true, 0);
++$errors;
@@ -85,6 +90,6 @@ require_once("classes/SerializedPacketHandler.class.php");
require_once("classes/CustomPacketHandler.class.php");
require_once("classes/MinecraftInterface.class.php");
require_once("classes/BigInteger.class.php");
-require_all("misc/");
+require_all(FILE_PATH . "src/misc/");
?>
\ No newline at end of file
diff --git a/common/functions.php b/src/common/functions.php
similarity index 98%
rename from common/functions.php
rename to src/common/functions.php
index 3380213e..ce9d0563 100644
--- a/common/functions.php
+++ b/src/common/functions.php
@@ -170,7 +170,7 @@ function logg($message, $name, $EOL = true, $level = 2, $close = false){
$fpointers = array();
}
if(!isset($fpointers[$name])){
- $fpointers[$name] = fopen(FILE_PATH."/".$name.".log", "ab");
+ $fpointers[$name] = fopen(FILE_PATH."logs/".$name.".log", "ab");
}
fwrite($fpointers[$name], $message);
if($close === true){
diff --git a/input.php b/src/common/input.php
similarity index 91%
rename from input.php
rename to src/common/input.php
index 1e9107a8..9e1f2aaa 100644
--- a/input.php
+++ b/src/common/input.php
@@ -25,7 +25,7 @@ the Free Software Foundation, either version 3 of the License, or
*/
-$fp = fopen(dirname(__FILE__)."/console.in","wb");
+$fp = fopen(dirname(__FILE__)."/../../logs/console.in","wb");
while(true){
$l = fgets(STDIN);
fwrite($fp, $l);
diff --git a/misc/block/plant/Sapling.php b/src/misc/block/plant/Sapling.php
similarity index 100%
rename from misc/block/plant/Sapling.php
rename to src/misc/block/plant/Sapling.php
diff --git a/misc/world/generator/object/tree/SmallTreeObject.php b/src/misc/world/generator/object/tree/SmallTreeObject.php
similarity index 100%
rename from misc/world/generator/object/tree/SmallTreeObject.php
rename to src/misc/world/generator/object/tree/SmallTreeObject.php
diff --git a/misc/world/generator/object/tree/TreeObject.php b/src/misc/world/generator/object/tree/TreeObject.php
similarity index 100%
rename from misc/world/generator/object/tree/TreeObject.php
rename to src/misc/world/generator/object/tree/TreeObject.php
diff --git a/pstruct/4.php b/src/pstruct/4.php
similarity index 100%
rename from pstruct/4.php
rename to src/pstruct/4.php
diff --git a/pstruct/5.php b/src/pstruct/5.php
similarity index 100%
rename from pstruct/5.php
rename to src/pstruct/5.php
diff --git a/pstruct/RakNet.php b/src/pstruct/RakNet.php
similarity index 100%
rename from pstruct/RakNet.php
rename to src/pstruct/RakNet.php
diff --git a/pstruct/dataName.php b/src/pstruct/dataName.php
similarity index 100%
rename from pstruct/dataName.php
rename to src/pstruct/dataName.php
diff --git a/pstruct/packetName.php b/src/pstruct/packetName.php
similarity index 100%
rename from pstruct/packetName.php
rename to src/pstruct/packetName.php
diff --git a/start.cmd b/start.cmd
index 83a18c2e..8e15e3e2 100644
--- a/start.cmd
+++ b/start.cmd
@@ -26,7 +26,7 @@ if not "%PHPOUTPUT%"=="1" (
echo [ERROR] Couldn't find PHP binary in PATH.
ping 127.0.0.1 -n 3 -w 1000>nul
) else (
-START /B CMD /C CALL php server.php
-START /B /WAIT php input.php 1
+START /B CMD /C CALL php PocketMine-MP.php
+START /B /WAIT php src/common/input.php 1
ping 127.0.0.1 -n 5 -w 1000>nul
)
\ No newline at end of file
diff --git a/start.sh b/start.sh
index ee771133..7275fbcc 100644
--- a/start.sh
+++ b/start.sh
@@ -1,3 +1,3 @@
#!/bin/bash
-php server.php &
-cat>console.in
\ No newline at end of file
+php PocketMine-MP.php &
+cat > src/console.in
\ No newline at end of file