main = $main; $this->server = $main->getServer(); } public function onRun($tick) { foreach($this->server->getLevels() as $lvl) { foreach($lvl->getTiles() as $t) { if($t instanceof Sign) { if(isset($t->namedtag->hideAndSeekSignData)) { if(!isset($t->namedtag->hideAndSeekSignData->model)) { $this->getOwner()->getLogger()->debug("SettingModel l44"); $t->namedtag->hideAndSeekSignData->setValue([ "model" => new ListTag("model", [ 1 => $t->namedtag->Text1, 2 => $t->namedtag->Text2, 3 => $t->namedtag->Text3, 4 => $t->namedtag->Text4 ]), "levelName" => $t->namedtag->hideAndSeekSignData->level ?? $t->namedtag->hideAndSeekSignData->levelName, "level" => $t->namedtag->hideAndSeekSignData->level ?? $t->namedtag->hideAndSeekSignData->levelName // Sometimes, there is no way to know why things like that works... ]); } $line1 = $this->parse((string) $t->namedtag->hideAndSeekSignData->model[1], $t); $line2 = $this->parse((string) $t->namedtag->hideAndSeekSignData->model[2], $t); $line3 = $this->parse((string) $t->namedtag->hideAndSeekSignData->model[3], $t); $line4 = $this->parse((string) $t->namedtag->hideAndSeekSignData->model[4], $t); $t->setText($line1, $line2, $line3, $line4); } } } } } /* Parses the text of the sign @param $string string @param $sign \pocketmine\tile\Sign @return string */ public function parse(string $string, Sign $sign) : string { safe_var_dump($sign->namedtag->hideAndSeekSignData->getValue()); $game = $this->main->getGameManager()->getGameByName($sign->namedtag->hideAndSeekSignData->levelName ?? $sign->namedtag->hideAndSeekSignData->level); $str = str_ireplace("{world}", $sign->namedtag->hideAndSeekSignData->offsetGet("levelName"), $string); $str = str_ireplace("{maxp}", $game->getMaxPlayers(), $str); $str = str_ireplace("{pls}", count($game->getPlayers()), $str); $str = str_ireplace("{step}", $game->step, $str); $str = str_ireplace("{playing}", ($game->step == Game::STEP_WAIT || $game->step == Game::STEP_START) ? "Waiting" : "Starting", $str); return $str; } }