From 8f6ed22158649e5ee72669f4bb0fdc2b95d432d5 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Wed, 26 Dec 2012 22:30:09 +0100 Subject: [PATCH] Fixed plugins loading? --- classes/API/ServerAPI.php | 9 ++++----- classes/PocketMinecraftServer.class.php | 9 +++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/classes/API/ServerAPI.php b/classes/API/ServerAPI.php index b08449373..73b90b349 100644 --- a/classes/API/ServerAPI.php +++ b/classes/API/ServerAPI.php @@ -178,10 +178,9 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run } } } - foreach($this->apiList as $a){ - if(method_exists($a[1], "init")){ - $a[1]->init(); - usleep(1); + foreach($this->apiList as $ob){ + if(is_callable(array($ob, "init"))){ + $ob->init(); } } @@ -380,7 +379,7 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run } require_once($file); $this->$name = new $class($this->server); - $this->apiList[] = array($name, $this->$name); + $this->apiList[] = $this->$name; console("[INFO] API ".$name." [".$class."] loaded"); } diff --git a/classes/PocketMinecraftServer.class.php b/classes/PocketMinecraftServer.class.php index 255b8af41..30cdcdaa9 100644 --- a/classes/PocketMinecraftServer.class.php +++ b/classes/PocketMinecraftServer.class.php @@ -465,8 +465,13 @@ class PocketMinecraftServer extends stdClass{ return; } while(false !== ($evn = $events->fetchArray(SQLITE3_ASSOC))){ - $evid = (int) $evn["ID"]; - $this->responses[$evid] = call_user_func($this->events[$evid], $data, $event); + $ev = $this->events[(int) $evn["ID"]]; + if(is_array($ev)){ + $method = $ev[1]; + $this->responses[(int) $evn["ID"]] = $ev[0]->$method($data, $event); + }else{ + $this->responses[(int) $evn["ID"]] = $ev($data, $event); + } } $events->finalize(); return true;