From 6d39f54591d4db7db24b6fd81b56c5f511225f87 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Fri, 29 Mar 2013 19:49:33 +0100 Subject: [PATCH] Removed $server constructor arguments because of ServerAPI::request() --- src/API/BanAPI.php | 4 ++-- src/API/BlockAPI.php | 4 ++-- src/API/ChatAPI.php | 4 ++-- src/API/ConsoleAPI.php | 4 ++-- src/API/EntityAPI.php | 6 +++--- src/API/LevelAPI.php | 4 ++-- src/API/PlayerAPI.php | 4 ++-- src/API/PluginAPI.php | 4 ++-- src/API/ServerAPI.php | 2 +- src/API/TileEntityAPI.php | 6 +++--- src/API/TimeAPI.php | 4 ++-- src/Player.php | 5 +++-- src/PocketMinecraftServer.php | 2 +- src/inventory/Window.php | 4 ++-- src/utils/TickLoop.php | 4 ++-- src/world/Entity.php | 4 ++-- src/world/TileEntity.php | 4 ++-- 17 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/API/BanAPI.php b/src/API/BanAPI.php index 5c59987a4..cbe6599e0 100644 --- a/src/API/BanAPI.php +++ b/src/API/BanAPI.php @@ -32,8 +32,8 @@ class BanAPI{ private $ops; private $bannedIPs; private $cmdWL = array(); - function __construct(PocketMinecraftServer $server){ - $this->server = $server; + function __construct(){ + $this->server = ServerAPI::request(); } public function init(){ diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 3d98161a1..d67c2cdaa 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -112,8 +112,8 @@ class BlockAPI{ return $this->getBlock($block->getSide($face)); } - function __construct(PocketMinecraftServer $server){ - $this->server = $server; + function __construct(){ + $this->server = ServerAPI::request(); } public function init(){ diff --git a/src/API/ChatAPI.php b/src/API/ChatAPI.php index 673131f94..a8b19a31b 100644 --- a/src/API/ChatAPI.php +++ b/src/API/ChatAPI.php @@ -27,8 +27,8 @@ the Free Software Foundation, either version 3 of the License, or class ChatAPI{ private $server; - function __construct(PocketMinecraftServer $server){ - $this->server = $server; + function __construct(){ + $this->server = ServerAPI::request(); } public function init(){ diff --git a/src/API/ConsoleAPI.php b/src/API/ConsoleAPI.php index 15922b65f..f70ded2e2 100644 --- a/src/API/ConsoleAPI.php +++ b/src/API/ConsoleAPI.php @@ -27,11 +27,11 @@ the Free Software Foundation, either version 3 of the License, or class ConsoleAPI{ private $loop, $server, $event, $help, $cmds, $alias; - function __construct(PocketMinecraftServer $server){ + function __construct(){ $this->help = array(); $this->cmds = array(); $this->alias = array(); - $this->server = $server; + $this->server = ServerAPI::request(); $this->last = microtime(true); } diff --git a/src/API/EntityAPI.php b/src/API/EntityAPI.php index e3e11d95a..4381b5af4 100644 --- a/src/API/EntityAPI.php +++ b/src/API/EntityAPI.php @@ -27,8 +27,8 @@ the Free Software Foundation, either version 3 of the License, or class EntityAPI{ private $server; - function __construct(PocketMinecraftServer $server){ - $this->server = $server; + function __construct(){ + $this->server = ServerAPI::request(); } public function get($eid){ @@ -60,7 +60,7 @@ class EntityAPI{ public function add($class, $type = 0, $data = array()){ $eid = $this->server->eidCnt++; - $this->server->entities[$eid] = new Entity($this->server, $eid, $class, $type, $data); + $this->server->entities[$eid] = new Entity($eid, $class, $type, $data); $this->server->handle("entity.add", $this->server->entities[$eid]); return $this->server->entities[$eid]; } diff --git a/src/API/LevelAPI.php b/src/API/LevelAPI.php index 6c8f25b81..f6ab0c925 100644 --- a/src/API/LevelAPI.php +++ b/src/API/LevelAPI.php @@ -27,8 +27,8 @@ the Free Software Foundation, either version 3 of the License, or class LevelAPI{ private $server, $map; - function __construct(PocketMinecraftServer $server){ - $this->server = $server; + function __construct(){ + $this->server = ServerAPI::request(); $this->map = $this->server->map; $this->heightMap = array_fill(0, 256, array()); } diff --git a/src/API/PlayerAPI.php b/src/API/PlayerAPI.php index 8ac13817b..6cfa6bd1c 100644 --- a/src/API/PlayerAPI.php +++ b/src/API/PlayerAPI.php @@ -27,8 +27,8 @@ the Free Software Foundation, either version 3 of the License, or class PlayerAPI{ private $server; - function __construct(PocketMinecraftServer $server){ - $this->server = $server; + function __construct(){ + $this->server = ServerAPI::request(); } public function init(){ diff --git a/src/API/PluginAPI.php b/src/API/PluginAPI.php index cd2aea29f..b2ee02e0c 100644 --- a/src/API/PluginAPI.php +++ b/src/API/PluginAPI.php @@ -28,8 +28,8 @@ the Free Software Foundation, either version 3 of the License, or class PluginAPI extends stdClass{ private $server; private $plugins = array(); - public function __construct(PocketMinecraftServer $server){ - $this->server = $server; + public function __construct(){ + $this->server = ServerAPI::request(); } public function getList(){ diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 2426b66c0..e651aa4c7 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -474,7 +474,7 @@ class ServerAPI{ }else{ $internal = true; } - $this->$name = new $class($this->server); + $this->$name = new $class(); $this->apiList[] = $this->$name; console("[".($internal === true ? "DEBUG":"INFO")."] API \x1b[36m".$name."\x1b[0m [\x1b[30;1m".$class."\x1b[0m] loaded", true, true, ($internal === true ? 2:1)); } diff --git a/src/API/TileEntityAPI.php b/src/API/TileEntityAPI.php index 5b68399cf..cf74dd1db 100644 --- a/src/API/TileEntityAPI.php +++ b/src/API/TileEntityAPI.php @@ -27,8 +27,8 @@ the Free Software Foundation, either version 3 of the License, or class TileEntityAPI{ private $server; - function __construct(PocketMinecraftServer $server){ - $this->server = $server; + function __construct(){ + $this->server = ServerAPI::request(); } public function get($x, $y = false, $z = false){ @@ -77,7 +77,7 @@ class TileEntityAPI{ public function add($class, $x, $y, $z, $data = array()){ $id = $this->tCnt++; - $this->server->tileEntities[$id] = new TileEntity($this->server, $id, $class, $x, $y, $z, $data); + $this->server->tileEntities[$id] = new TileEntity($id, $class, $x, $y, $z, $data); $this->spawnToAll($id); return $this->server->tileEntities[$id]; } diff --git a/src/API/TimeAPI.php b/src/API/TimeAPI.php index 1b5023f4a..f877c56fa 100644 --- a/src/API/TimeAPI.php +++ b/src/API/TimeAPI.php @@ -33,8 +33,8 @@ class TimeAPI{ "sunrise" => 17800, ); private $server; - function __construct(PocketMinecraftServer $server){ - $this->server = $server; + function __construct(){ + $this->server = ServerAPI::request(); } public function init(){ diff --git a/src/Player.php b/src/Player.php index feb633d3b..fae9e59f5 100644 --- a/src/Player.php +++ b/src/Player.php @@ -61,9 +61,9 @@ class Player{ private $chunksLoaded = array(); private $chunksOrder = array(); - function __construct(PocketMinecraftServer $server, $clientID, $ip, $port, $MTU){ + function __construct($clientID, $ip, $port, $MTU){ $this->MTU = $MTU; - $this->server = $server; + $this->server = ServerAPI::request(); $this->lastBreak = microtime(true); $this->clientID = $clientID; $this->CID = $this->server->clientID($ip, $port); @@ -616,6 +616,7 @@ class Player{ case MC_KEEP_ALIVE: break; + case 0x01: case 0x03: break; diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index c9b97e577..2bf581045 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -619,7 +619,7 @@ class PocketMinecraftServer{ $port = $data[2]; $MTU = $data[3]; $clientID = $data[4]; - $this->clients[$CID] = new Player($this, $clientID, $packet["ip"], $packet["port"], $MTU); //New Session! + $this->clients[$CID] = new Player($clientID, $packet["ip"], $packet["port"], $MTU); //New Session! $this->clients[$CID]->handle(0x07, $data); break; } diff --git a/src/inventory/Window.php b/src/inventory/Window.php index 8bcbae77d..7ab9b92f1 100644 --- a/src/inventory/Window.php +++ b/src/inventory/Window.php @@ -31,8 +31,8 @@ define("WINDOW_FURNACE", 2); class Window{ private $server; - public function __construct(PocketMinecraftServer $server){ - + public function __construct(){ + $this->server = ServerAPI::request(); } } diff --git a/src/utils/TickLoop.php b/src/utils/TickLoop.php index efe812b86..b765450c2 100644 --- a/src/utils/TickLoop.php +++ b/src/utils/TickLoop.php @@ -28,10 +28,10 @@ the Free Software Foundation, either version 3 of the License, or class TickLoop extends Thread{ public $tick, $stop, $lastTic; private $server; - public function __construct(PocketMinecraftServer $server){ + public function __construct(){ $this->tick = false; $this->lastTick = 0; - $this->server = $server; + $this->server = ServerAPI::request(); } public function run(){ while($this->stop !== true){ diff --git a/src/world/Entity.php b/src/world/Entity.php index 7430d3904..ca43d0618 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -74,10 +74,10 @@ class Entity extends stdClass{ private $tickCounter; private $speedMeasure = array(0, 0, 0, 0, 0); private $server; - function __construct(PocketMinecraftServer $server, $eid, $class, $type = 0, $data = array()){ + function __construct($eid, $class, $type = 0, $data = array()){ $this->fallY = false; $this->fallStart = false; - $this->server = $server; + $this->server = ServerAPI::request(); $this->eid = (int) $eid; $this->type = (int) $type; $this->class = (int) $class; diff --git a/src/world/TileEntity.php b/src/world/TileEntity.php index f10bac358..4d5a314da 100644 --- a/src/world/TileEntity.php +++ b/src/world/TileEntity.php @@ -45,8 +45,8 @@ class TileEntity extends stdClass{ public $metadata; public $closed; private $server; - function __construct(PocketMinecraftServer $server, $id, $class, $x, $y, $z, $data = array()){ - $this->server = $server; + function __construct($id, $class, $x, $y, $z, $data = array()){ + $this->server = ServerAPI::request(); $this->normal = true; $this->class = $class; $this->data = $data;