diff --git a/.gitignore b/.gitignore index a84f67b76a..7b8cce5904 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -data/players/* -data/maps/* -data/plugins/* +players/* +worlds/* +plugins/* *.log server.properties white-list.txt diff --git a/data/How To Import Maps.txt b/data/How To Import Maps.txt deleted file mode 100644 index 1f6370c781..0000000000 --- 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/server.php b/server.php index e9fc7bd529..853f902ae7 100644 --- a/server.php +++ b/server.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/classes/API/BlockAPI.php b/src/API/BlockAPI.php similarity index 100% rename from classes/API/BlockAPI.php rename to src/API/BlockAPI.php 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 100% rename from classes/API/ConsoleAPI.php rename to src/API/ConsoleAPI.php 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 db01cc4ad3..e42908fae6 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 020bd6294f..e9e600e2a3 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 92% rename from classes/API/ServerAPI.php rename to src/API/ServerAPI.php index 67873e84fd..5bff0f626b 100644 --- a/classes/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -79,13 +79,13 @@ 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); + @mkdir(FILE_PATH."players/", 0777, true); + @mkdir(FILE_PATH."worlds/", 0777); + @mkdir(FILE_PATH."plugins/", 0777); console("[DEBUG] Loading server.properties...", true, true, 2); $this->parseProperties(); @@ -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 100% rename from classes/Entity.class.php rename to src/classes/Entity.class.php 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 100% rename from classes/PocketMinecraftServer.class.php rename to src/classes/PocketMinecraftServer.class.php 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 82248598fb..f6d71707e6 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 98% rename from common/dependencies.php rename to src/common/dependencies.php index 32c7fb53a8..886c9ce81b 100644 --- a/common/dependencies.php +++ b/src/common/dependencies.php @@ -90,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 100% rename from common/functions.php rename to src/common/functions.php 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