Updated directory structure

This commit is contained in:
Shoghi Cervantes Pueyo 2012-12-28 15:09:35 +01:00
parent 0c498e96a3
commit 0b683c6b0e
41 changed files with 30 additions and 32 deletions

6
.gitignore vendored
View File

@ -1,6 +1,6 @@
data/players/*
data/maps/*
data/plugins/*
players/*
worlds/*
plugins/*
*.log
server.properties
white-list.txt

View File

@ -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.

View File

@ -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();

View File

@ -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));
}
}

View File

@ -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);
}
}
}

View File

@ -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)){

View File

@ -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);

View File

@ -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/");
?>