public function check() { for ($n = 0; $n < $this->threads; ++$n) { if ($this->workers[$n]->isTerminated() === true) { $this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread); } elseif ($this->workers[$n]->isWaiting()) { if ($this->workers[$n]->response !== "") { $this->server->getLogger()->info($this->workers[$n]->response); $this->workers[$n]->synchronized(function (RCONInstance $thread) { $thread->notify(); }, $this->workers[$n]); } else { $response = new RemoteConsoleCommandSender(); $command = $this->workers[$n]->cmd; $this->server->getPluginManager()->callEvent($ev = new RemoteServerCommandEvent($response, $command)); if (!$ev->isCancelled()) { $this->server->dispatchCommand($ev->getSender(), $ev->getCommand()); } $this->workers[$n]->response = TextFormat::clean($response->getMessage()); $this->workers[$n]->synchronized(function (RCONInstance $thread) { $thread->notify(); }, $this->workers[$n]); } } } }
/** * @priority HIGHEST */ public function onRconCmd(RemoteServerCommandEvent $ev) { if ($ev instanceof RemoteServerCommandEvent_sub) { return; } $res = $this->processCmd($ev->getCommand(), $ev->getSender()); if ($res === false) { return; } $ev->setCancelled(); foreach ($res as $c) { $this->owner->getServer()->getPluginManager()->callEvent($ne = new RemoteServerCommandEvent_sub($ev->getSender(), $c)); if ($ne->isCancelled()) { continue; } $this->owner->getServer()->dispatchCommand($ne->getSender(), $ne->getCommand()); } }
/** * @priority HIGHEST */ public function onRemoteServerCommand(RemoteServerCommandEvent $event) { if (!$event->isCancelled() && stripos("save-all", $command = $event->getCommand()) === 0) { $this->checkSaveAll($event->getSender()); } }
/** * @priority MONITOR */ public function onRconCmd(RemoteServerCommandEvent $ev) { $this->logEvent(self::RCON, $ev->getMessage()); }
/** * @priority MONITOR */ public function onRconCmd(RemoteServerCommandEvent $ev) { $this->owner->logMsg($ev->getSender(), $ev->getCommand()); }
/** * @priority LOWEST */ public function onRconCmd(RemoteServerCommandEvent $ev) { $res = $this->processCmd($ev->getCommand(), $ev->getSender()); if ($res === false) { return; } $ev->setCommand($res); }
public function onRemoteServerCommand(RemoteServerCommandEvent $event) { $this->log($event->getCommand(), $event->getSender()); }
/** * @param RemoteServerCommandEvent $event * @priority HIGHEST * @ignoreCancelled true */ public function onRCONCmd(RemoteServerCommandEvent $event) { if ($event instanceof RemoteServerCommandEvent_sub) { return; } /** @var string|array $cmd */ $cmd = $event->getCommand(); if ($this->proceedCommand($event->getSender(), $cmd)) { if (count($cmd) > 0) { //$event->setCommand(array_shift($cmd)); $event->setCancelled(); foreach ($cmd as $c) { $this->getServer()->getPluginManager()->callEvent($ev = new RemoteServerCommandEvent_sub($event->getSender(), $c)); if (!$ev->isCancelled()) { $this->getServer()->dispatchCommand($ev->getSender(), $ev->getCommand()); } } } } else { $event->setCommand($cmd); } }
public function check() { $d = Utils::getRealMemoryUsage(); $u = Utils::getMemoryUsage(true); $usage = round($u[0] / 1024 / 1024, 2) . "/" . round($d[0] / 1024 / 1024, 2) . "/" . round($u[1] / 1024 / 1024, 2) . "/" . round($u[2] / 1024 / 1024, 2) . " MB @ " . Utils::getThreadCount() . " threads"; $serverStatus = serialize(["online" => count($this->server->getOnlinePlayers()), "max" => $this->server->getMaxPlayers(), "upload" => round($this->server->getNetwork()->getUpload() / 1024, 2), "download" => round($this->server->getNetwork()->getDownload() / 1024, 2), "tps" => $this->server->getTicksPerSecondAverage(), "load" => $this->server->getTickUsageAverage(), "usage" => $usage]); for ($n = 0; $n < $this->threads; ++$n) { if (!$this->workers[$n]->isTerminated()) { $this->workers[$n]->serverStatus = $serverStatus; } if ($this->workers[$n]->isTerminated() === true) { $this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread); } elseif ($this->workers[$n]->isWaiting()) { if ($this->workers[$n]->response !== "") { $this->server->getLogger()->info($this->workers[$n]->response); $this->workers[$n]->synchronized(function (RCONInstance $thread) { $thread->notify(); }, $this->workers[$n]); } else { $response = new RemoteConsoleCommandSender(); $command = $this->workers[$n]->cmd; $this->server->getPluginManager()->callEvent($ev = new RemoteServerCommandEvent($response, $command)); if (!$ev->isCancelled()) { $this->server->dispatchCommand($ev->getSender(), $ev->getCommand()); } $this->workers[$n]->response = $response->getMessage(); $this->workers[$n]->synchronized(function (RCONInstance $thread) { $thread->notify(); }, $this->workers[$n]); } } } }