From 4c9574f583480f708a5ecbfa7d6f3c30406793fd Mon Sep 17 00:00:00 2001 From: xpyctum Date: Sat, 22 Aug 2015 16:07:53 +0500 Subject: [PATCH] Multiple signs! --- src/SignStatus/SignStatus.php | 2 +- src/SignStatus/Task.php | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/SignStatus/SignStatus.php b/src/SignStatus/SignStatus.php index 2687ebd..a359513 100644 --- a/src/SignStatus/SignStatus.php +++ b/src/SignStatus/SignStatus.php @@ -23,7 +23,7 @@ ─███──█──────█───█──█──█──█─█─█───█ ██─██─█──────█───████──█──███─█───█ */ -//TODO: Make multisigns and configurable format of sign +//TODO: Make configurable format of sign class SignStatus extends PluginBase implements Listener{ /** @var Config sign */ diff --git a/src/SignStatus/Task.php b/src/SignStatus/Task.php index 0d377a7..524479e 100644 --- a/src/SignStatus/Task.php +++ b/src/SignStatus/Task.php @@ -21,19 +21,16 @@ public function __construct(SignStatus $plugin){ public function onRun($currentTick){ $val = $this->plugin->sign->get("sign")["enabled"]; if($val == "true" || $val == true){ - $x = $this->plugin->sign->get("sign")["x"]; - $y = $this->plugin->sign->get("sign")["y"]; - $z = $this->plugin->sign->get("sign")["z"]; - $lvz = $this->plugin->sign->get("sign")["level"]; - $tps = Server::getInstance()->getTicksPerSecond(); - $p = count(Server::getInstance()->getOnlinePlayers()); - $full = Server::getInstance()->getMaxPlayers(); - $level = Server::getInstance()->getLevelByName($lvz); - if($level instanceof Level) { - $sign = $level->getTile(new Vector3($x, $y, $z)); - $count = $this->countable++; //For debug - if ($sign instanceof Sign) { - $sign->setText(F::GREEN."[STATUS]", F::YELLOW."TPS: [".$tps."]", F::AQUA."ONLINE: ".F::GREEN.$p.F::WHITE."/".F::RED.$full."", F::GOLD.$count); + foreach($this->plugin->getServer()->getDefaultLevel()->getTiles() as $tile){ + if($tile instanceof Sign){ + if($tile->getText()[0] == F::GREEN."[STATUS]"){ + $tps = Server::getInstance()->getTicksPerSecond(); + $p = count(Server::getInstance()->getOnlinePlayers()); + $full = Server::getInstance()->getMaxPlayers(); + $count = $this->countable++; //For debug + $load = $this->plugin->getServer()->getTickUsage(); + $tile->setText(F::GREEN."[STATUS]", F::YELLOW."TPS: [".$tps."]", F::AQUA."ONLINE: ".F::GREEN.$p.F::WHITE."/".F::RED.$full."", F::GOLD."LOAD: ".F::DARK_BLUE.$load. " %"); + } } } }