/** * Close inventory event * * @param InventoryCloseEvent $ev */ public function onClose(InventoryCloseEvent $ev) { $pl = $ev->getPlayer(); $xx = $this->getState(self::tag, $pl, null); if ($xx == null) { return; } // Compute shopping basket $basket = []; $total = 0; foreach ($pl->getInventory()->getContents() as $slot => $item) { if ($item->getId() == Item::AIR) { continue; } $idmeta = implode(":", [$item->getId(), $item->getDamage()]); if (!isset($xx["shop"][$idmeta])) { continue; } list($i, $price) = $xx["shop"][$idmeta]; $total += round($item->getCount() / $i->getCount()) * $price; $basket[] = [$item->getId(), $item->getDamage(), $item->getCount()]; } // Restore original inventory... $this->restoreInv($pl); // Check-out if (count($basket) == 0) { $pl->sendMessage(mc::_("No items purchased")); return; } if ($total < $this->owner->getMoney($pl)) { $this->owner->grantMoney($pl, -$total); $pl->sendMessage(mc::n(mc::_("Bought one item for %1%G", $total), mc::_("Bought %1% items for %2%G", count($basket), $total), count($basket))); foreach ($basket as $ck) { list($id, $meta, $cnt) = $ck; $pl->getInventory()->addItem(Item::get($id, $meta, $cnt)); } } else { $pl->sendMessage(mc::_("Not enough money.")); $pl->sendMessage(mc::_("You need %1%G", $total)); } }
/** * Given some defaults, this will load optional features * * @param str $ns - namespace used to search for classes to load * @param array $mods - optional module definition * @param array $defaults - default options to use for config.yml * @param str $xhlp - optional help format. * @return array */ protected function modConfig($ns, $mods, $defaults, $xhlp = "") { if (!isset($defaults["features"])) { $defaults["features"] = []; } foreach ($mods as $i => $j) { $defaults["features"][$i] = $j[1]; } $cfg = (new Config($this->getDataFolder() . "config.yml", Config::YAML, $defaults))->getAll(); $this->modules = []; foreach ($cfg["features"] as $i => $j) { if (!isset($mods[$i])) { $this->getLogger()->info(mc::_("Unknown feature \"%1%\" ignored.", $i)); continue; } if (!$j) { continue; } $class = $mods[$i][0]; if (strpos($class, "\\") === false) { $class = $ns . "\\" . $class; } if (isset($cfg[$i])) { $this->modules[$i] = new $class($this, $cfg[$i]); } else { $this->modules[$i] = new $class($this); } } $c = count($this->modules); if ($c == 0) { $this->getLogger()->info(mc::_("NO features enabled")); return; } $this->state = []; $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->info(mc::n(mc::_("Enabled one feature"), mc::_("Enabled %1% features", $c), $c)); if (count($this->scmdMap) && count($this->scmdMap["mgrs"])) { $this->modules[] = new BasicHelp($this, $xhlp); } return $cfg; }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { if ($cmd->getName() != "skin") { return false; } $pageNumber = $this->getPageNumber($args); if (isset($args[0])) { $human = $this->owner->getServer()->getPlayer($args[0]); if ($human !== null) { array_shift($args); } else { $human = $sender; } } if (count($args) == 0) { $args = ["ls"]; } switch (strtolower(array_shift($args))) { case "ls": $skins = []; foreach (glob($this->owner->getDataFolder() . "*.*") as $f) { if (SkinUtils::isSkinFile($f)) { $skins[] = $f; } } if (count($skins) == 0) { $sender->sendMessage(mc::_("No skins found")); return true; } $txt = [mc::n(mc::_("Found one skin"), mc::_("Found %1% skins", count($skins)), count($skins))]; $cols = 8; $i = 0; foreach ($skins as $n) { $n = basename($n, ".skin"); if ($i++ % $cols == 0) { $txt[] = $n; } else { $txt[count($txt) - 1] .= ", " . $n; } } return $this->paginateText($sender, $pageNumber, $txt); case "formats": case "fmt": if (count($args) != 0) { return false; } $sender->sendMessage(mc::_("Supported formats: %1%", implode(", ", SkinUtils::formats()))); return true; case "save": if (count($args) != 1) { return false; } if (!MPMU::inGame($human)) { return true; } if ($human !== $sender && !MPMU::access($sender, "gb.cmd.skin.other")) { return true; } if (SkinUtils::isPngExt($args[0])) { $fmts = SkinUtils::formats(); if (!isset($fmts[SkinUtils::PNG_FMT])) { $sender->sendMessage(mc::_("PNG format is not supported")); return true; } $fn = $this->owner->getDataFolder() . preg_replace('/\\.[pP][nN][gG]$/', '', basename($args[0])) . ".png"; } else { $fn = $this->owner->getDataFolder() . preg_replace('/\\.skin$/', '', basename($args[0])) . ".skin"; } $cnt = SkinUtils::saveSkin($human, $fn); $sender->sendMessage(mc::_("Wrote %1% bytes to %2%", $cnt, $fn)); return true; case "load": $slim = false; if (isset($args[0]) && $args[0] == "--slim") { $slim = true; array_shift($args); } if ($human !== $sender && !MPMU::access($sender, "gb.cmd.skin.other")) { return true; } if (count($args) != 1) { return false; } if (!MPMU::inGame($human)) { return true; } if (SkinUtils::isPngExt($args[0])) { $fmts = SkinUtils::formats(); if (!isset($fmts[SkinUtils::PNG_FMT])) { $sender->sendMessage(mc::_("PNG format is not supported")); return true; } $fn = $this->owner->getDataFolder() . preg_replace('/\\.[pP][nN][gG]$/', '', basename($args[0])) . ".png"; } else { $fn = $this->owner->getDataFolder() . preg_replace('/\\.skin$/', '', basename($args[0])) . ".skin"; } if (SkinUtils::loadSkin($human, $slim, $fn)) { $sender->sendMessage(mc::_("Updated skin for %1%", $human->getName())); } else { $sender->sendMessage(mc::_("Unable to read %1%", $fn)); } return true; case "slim": if ($human !== $sender && !MPMU::access($sender, "gb.cmd.skin.other")) { return true; } if (count($args) != 0) { return false; } if (!MPMU::inGame($human)) { return true; } SkinUtils::setSlim($human, true); $sender->sendMessage(mc::_("%1% is now slim", $human->getName())); return true; case "thick": if ($human !== $sender && !MPMU::access($sender, "gb.cmd.skin.other")) { return true; } if (count($args) != 0) { return false; } if (!MPMU::inGame($human)) { return true; } SkinUtils::setSlim($human, false); $sender->sendMessage(mc::_("%1% is now thick", $human->getName())); return true; } return false; }
/** * Given some defaults, this will load optional features * * @param str $ns - namespace used to search for classes to load * @param array $mods - optional module definition * @param array $defaults - default options to use for config.yml * @param str $xhlp - optional help format. * @return array */ protected function modConfig($ns, $mods, $defaults, $xhlp = "") { if (!isset($defaults["features"])) { $defaults["features"] = []; } foreach ($mods as $i => $j) { $defaults["features"][$i] = $j[1]; } $cfg = (new Config($this->getDataFolder() . "config.yml", Config::YAML, $defaults))->getAll(); $this->modules = []; foreach ($cfg["features"] as $i => $j) { if (!isset($mods[$i])) { $this->getLogger()->info(mc::_("Unknown feature \"%1%\" ignored.", $i)); continue; } if (!$j) { continue; } $class = $mods[$i][0]; if (is_array($class)) { while (count($class) > 1) { // All classes before the last one are dependencies... $classname = $dep = array_shift($class); if (strpos($classname, "\\") === false) { $classname = $ns . "\\" . $classname; } if (isset($this->modules[$dep])) { continue; } // Dependancy already loaded if (isset($cfg[strtolower($dep)])) { $this->modules[$dep] = new $classname($this, $cfg[strtolower($dep)]); } else { $this->modules[$dep] = new $classname($this); } } // The last class in the array implements the actual feature $class = array_shift($class); } if (strpos($class, "\\") === false) { $class = $ns . "\\" . $class; } if (isset($cfg[$i])) { $this->modules[$i] = new $class($this, $cfg[$i]); } else { $this->modules[$i] = new $class($this); } } $c = count($this->modules); if ($c == 0) { $this->getLogger()->info(mc::_("NO features enabled")); return; } $this->session = null; $this->getLogger()->info(mc::n(mc::_("Enabled one feature"), mc::_("Enabled %1% features", $c), $c)); if ($this->scmdMap !== null && $this->scmdMap->getCommandCount() > 0) { $this->modules[] = new BasicHelp($this, $xhlp); } return $cfg; }
public function onPlayerJoin(PlayerJoinEvent $e) { $pl = $e->getPlayer(); if ($pl == null) { return; } //echo __METHOD__.",".__LINE__."\n";//##DEBUG if (!$pl->hasPermission("gb.cmd.rpt.read")) { return; } list($id, $rpt) = $this->rpt->getAll(); if (count($rpt)) { $pl->sendMessage(mc::n(mc::_("One report on file"), mc::_("%1% reports on file", count($rpt)), count($rpt))); } }
private function rmInvItem(CommandSender $sender, array $args) { if (count($args) == 0) { return false; } if (($target = $this->owner->getServer()->getPlayer($args[0])) === null) { if (!MPMU::inGame($sender)) { return true; } $target = $sender; $other = false; } else { if (!MPMU::access($sender, "gb.cmd.rminv.others")) { return true; } array_shift($args); $other = true; } if (count($args) == 0) { return false; } if ($target->isCreative() || $target->isSpectator()) { $sender->sendMessage(mc::_("%1% is in %2% mode", $target->getDisplayName(), MPMU::gamemodeStr($target->getGamemode()))); return true; } $count = null; if (count($args) > 1 && is_numeric($args[count($args) - 1])) { $count = array_pop($args); } $args = strtolower(implode("_", $args)); if ($args == "hand") { $item = clone $target->getInventory()->getItemInHand(); if ($item->getId() == 0) { $sender->sendMessage(mc::_("Must be holding something")); return true; } } else { $item = Item::fromString($args); if ($item->getId() == 0) { $sender->sendMessage(mc::_("There is no item called %1%", $args)); return true; } } $k = InvUtils::rmInvItem($target, $item, $count); if ($k) { $sender->sendMessage(mc::n(mc::_("one item of %1% removed", ItemName::str($item)), mc::_("%2% items of %1% removed", ItemName::str($item), $k), $k)); if ($other) { $target->sendMessage(mc::n(mc::_("%2% took one item of %1% from you", ItemName::str($item), $sender->getName()), mc::_("%3% took %2% items of %1% from you", ItemName::str($item), $k, $sender->getName()), $k)); } } else { $sender->sendMessage(mc::_("No items were removed!")); } return true; }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { switch ($cmd->getName()) { case "nick": if (!MPMU::inGame($sender)) { return true; } if (count($args) == 0) { $sender->sendMessage(mc::_("Current nick is: %1%", $sender->getDisplayName())); return true; } if (count($args) !== 1) { return false; } $this->owner->getServer(mc::_("%1% is now known as %2%", $sender->getDisplayName(), $args[0])); $sender->setDisplayName($args[0]); return true; case "clearchat": if (!MPMU::inGame($sender)) { return true; } if (count($args) != 0) { return false; } for ($i = 0; $i < 32; ++$i) { $sender->sendMessage(" "); } return true; case "chat-on": case "chat-off": if (count($args) > 0) { switch ($n = strtolower(array_shift($args))) { case "--list": case "--ls": case "-l": if (!MPMU::access($sender, "gb.cmd.togglechat.others")) { return true; } $pageNumber = $this->getPageNumber($args); $txt = [""]; $cols = 8; $i = 0; foreach ($this->owner->getServer()->getOnlinePlayers() as $p) { if (!$this->getState($p, false)) { continue; } $n = $p->getDisplayName(); if ($i++ % $cols == 0) { $txt[] = $n; } else { $txt[count($txt) - 1] .= ", " . $n; } } if ($i == 0) { $sender->sendMessage(mc::_("No players with chat off")); if (!$this->chat) { $sender->sendMessage(mc::_("Chat is GLOBALLY off")); } return true; } if ($this->chat) { $txt[0] = mc::n(mc::_("One player with chat off"), mc::_("%1% players with chat off", $i), $i); } else { $txt[0] = mc::_("Chat is GLOBALLY off"); } return $this->paginateText($sender, $pageNumber, $txt); case "--server": case "--global": case "-g": if (count($args)) { return false; } if (!MPMU::access($sender, "gb.cmd.togglechat.global")) { return true; } if ($cmd->getName() == "chat-off") { $this->setGlobalChat(false); $this->owner->getServer()->broadcastMessage(mc::_("Chat disabled globally from %1%", $sender->getName())); } else { $this->setGlobalChat(true); $this->owner->getServer()->broadcastMessage(mc::_("Chat enabled globally from %1%", $sender->getName())); } return true; default: if (count($args)) { return false; } if (!MPMU::access($sender, "gb.cmd.togglechat.others")) { return true; } $player = $this->owner->getServer()->getPlayer($n); if ($player === null) { $sender->sendMessage(mc::_("Unable to find %1%", $n)); return true; } if ($cmd->getName() == "chat-off") { $this->setState($player, true); $player->sendMessage(mc::_("Chat disabled from %1%", $sender->getName())); $sender->sendMessage(mc::_("Chat disabled for %1%", $player->getDisplayName())); } else { $this->unsetState($player); $player->sendMessage(mc::_("Chat enabled from %1%", $sender->getName())); $sender->sendMessage(mc::_("Chat enabled for %1%", $player->getDisplayName())); } return true; } return false; } if (!MPMU::inGame($sender)) { return true; } if ($cmd->getName() == "chat-off") { $this->setState($sender, true); $sender->sendMessage(mc::_("Chat disabled")); } else { $this->unsetState($sender); $sender->sendMessage(mc::_("Chat enabled")); } return true; } return false; }
public function onCommand(CommandSender $c, Command $cc, $label, array $args) { if (count($args) == 1) { switch (strtolower($args[0])) { case "on": if ($this->listener !== null) { $c->sendMessage(mc::_("Trace already on")); return true; } $this->tracers = []; $this->listener = new TraceListener($this->owner, [$this, "trace"]); $this->owner->getServer()->getPluginManager()->registerEvents($this->listener, $this->owner); $this->timerTask = new PluginCallbackTask($this->owner, [$this, "expireEvents"], []); $h = $this->owner->getServer()->getScheduler()->scheduleRepeatingTask($this->timerTask, $this->timer_ticks); $this->timerTask->setHandler($h); $this->owner->getServer()->broadcastMessage(mc::_("Tracing has been started")); return true; case "off": if ($this->timerTask !== null) { $this->owner->getServer()->getScheduler()->cancelTask($this->timerTask->getTaskId()); $this->timerTask = null; } if ($this->listener === null) { $c->sendMessage(mc::_("Trace already off")); return true; } HandlerList::unregisterAll($this->listener); unset($this->listener); $this->listener = null; $this->tracers = null; $this->owner->getServer()->broadcastMessage(mc::_("Tracing has been stopped")); return true; } } if ($this->listener === null) { $c->sendMessage(mc::_("Tracing is off")); return true; } if (count($args) >= 1 && strtolower($args[0]) == "events") { if (count($args) == 1) { $lst = $this->listener->getList(); $c->sendMessage(mc::_("Types: %1%", implode(", ", $lst["types"]))); $c->sendMessage(mc::_("Classes: %1%", implode(", ", $lst["classes"]))); return true; } array_shift($args); foreach ($args as $p) { $t = $this->listener->checkEvent($p); if ($t == null) { $c->sendMessage(mc::_("Unknown event: %1%", $p)); return true; } $c->sendMessage(mc::_("Events: %1%", implode(", ", $t))); } } if ($c instanceof Player) { $n = strtolower($c->getName()); } else { $n = ""; } if (count($args) == 0) { $c->sendMessage(mc::_("Tracing is on")); $lst = []; //print_r($this->tracers);//##DEBUG foreach (array_keys($this->tracers) as $type) { if (isset($this->tracers[$type]["listeners"][$n])) { $lst[] = $type; } } if (count($lst) == 0) { return true; } $c->sendMessage(mc::n(mc::_("Tracing one event: %1%", $lst[0]), mc::_("Tracing %1% events: %2%", count($lst), implode(", ", $lst)), count($lst))); return true; } list($i, $j) = [0, 0]; foreach ($args as $k) { if ($k[0] == "-") { // Removing trace $k = substr($k, 1); $types = $this->listener->checkEvent($k); if ($types == null) { $c->sendMessage(mc::_("Unknown event %1%", $k)); continue; } $j += count($types); foreach ($types as $l) { $this->rmTrace($l, $n); } } else { // Adding traces $types = $this->listener->checkEvent($k); if ($types == null) { $c->sendMessage(mc::_("Unknown event %1%", $k)); continue; } $i += count($types); foreach ($types as $l) { if (!isset($this->tracers[$l])) { $this->tracers[$l] = ["listeners" => []]; } $this->tracers[$l]["listeners"][$n] = $n; } } } if ($i) { $c->sendMessage(mc::n(mc::_("Adding one event trace"), mc::_("Adding %1% event traces", $i), $i)); } if ($j) { $c->sendMessage(mc::n(mc::_("Removing one event trace"), mc::_("Removing %1% event traces", $j), $j)); } return true; }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { if ($cmd->getName() != "skin") { return false; } $pageNumber = $this->getPageNumber($args); if (isset($args[0])) { $human = $this->owner->getServer()->getPlayer($args[0]); if ($human !== null) { array_shift($args); } else { $human = $sender; } } if (count($args) == 0) { $args = ["ls"]; } switch (strtolower(array_shift($args))) { case "ls": $skins = $this->getSkins(); if (count($skins) == 0) { $sender->sendMessage(mc::_("No skins found")); return true; } $txt = [mc::n(mc::_("Found one skin"), mc::_("Found %1% skins", count($skins)), count($skins))]; $cols = 8; $i = 0; foreach ($skins as $n) { $n = basename($n, ".skin"); if ($i++ % $cols == 0) { $txt[] = $n; } else { $txt[count($txt) - 1] .= ", " . $n; } } return $this->paginateText($sender, $pageNumber, $txt); case "save": if (count($args) != 1) { return false; } if (!MPMU::inGame($human)) { return true; } if ($human !== $sender && !MPMU::access($sender, "gb.cmd.skin.other")) { return true; } $fn = preg_replace('/\\.skin$/', '', basename($args[0])) . ".skin"; $cnt = $this->saveSkin($human, $fn); $sender->sendMessage(mc::_("Wrote %1% bytes to %2%", $cnt, $fn)); return true; case "load": $slim = false; if (isset($args[0]) && $args[0] == "--slim") { $slim = true; array_shift($args); } if ($human !== $sender && !MPMU::access($sender, "gb.cmd.skin.other")) { return true; } if (count($args) != 1) { return false; } if (!MPMU::inGame($human)) { return true; } $fn = preg_replace('/\\.skin$/', '', basename($args[0])) . ".skin"; if ($this->loadSkin($human, $fn)) { $sender->sendMessage(mc::_("Updated skin for %1%", $human->getName())); } else { $sender->sendMessage(mc::_("Unable to read %1%", $fn)); } return true; } return false; }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { if ($cmd->getName() != "reg") { return false; } if (count($args) == 0) { $args = ["count"]; } $scmd = strtolower(array_shift($args)); switch ($scmd) { case "count": if (count($args) != 0) { return false; } $cnt = count(glob($this->owner->getServer()->getDataPath() . "players/*.dat")); $sender->sendMessage(mc::n(mc::_("One player registered"), mc::_("%1% players registered", $cnt), $cnt)); return true; case "ls": case "list": $pageNumber = $this->getPageNumber($args); if (count($args) == 0) { $pattern = "*"; } elseif (count($args) == 1) { $pattern = implode(" ", $args); } else { return false; } $f = glob($this->owner->getServer()->getDataPath() . "players/" . $pattern . ".dat"); $txt = [mc::n(mc::_("One player found"), mc::_("%1% players found", count($f)), count($f))]; $cols = 8; $i = 0; foreach ($f as $n) { $n = basename($n, ".dat"); if ($i++ % $cols == 0) { $txt[] = $n; } else { $txt[count($txt) - 1] .= ", " . $n; } } return $this->paginateText($sender, $pageNumber, $txt); case "rm": if (count($args) != 1) { return false; } $victim = strtolower(array_shift($args)); $target = $this->owner->getServer()->getPlayer($victim); if ($target !== null) { $sender->sendMessage(TextFormat::RED . mc::_("Can not delete player re-gistration while they are on-line")); return true; } $target = $this->owner->getServer()->getOfflinePlayer($victim); if ($target == null || !$target->hasPlayedBefore()) { $sender->sendMessage(mc::_("%1% can not be found.", $victim)); return true; } $f = $this->owner->getServer()->getDataPath() . "players/" . $victim . ".dat"; if (!is_file($f)) { $sender->sendMessage(TextFormat::RED . mc::_("Problem deleting %1%", $victim)); return true; } unlink($f); $sender->sendMessage(TextFormat::RED . mc::_("%1% was deleted.", $victim)); return true; case "since": $pageNumber = $this->getPageNumber($args); if (count($args) == 0) { return false; } if (($when = strtotime(implode(" ", $args))) === false) { return false; } $f = glob($this->owner->getServer()->getDataPath() . "players/*.dat"); $tab = [[mc::_("Date/Time"), "x"]]; foreach ($f as $n) { $n = basename($n, ".dat"); $target = $this->owner->getServer()->getOfflinePlayer($n); if ($target == null || !$target->hasPlayedBefore()) { continue; } if (($regdate = $target->getFirstPlayed() / 1000) > $when) { $tab[] = [date(mc::_("d-M-Y H:i"), $regdate), $n]; } } $cnt = count($tab) - 1; if ($cnt == 0) { $sender->sendMessage(mc::_("No players found")); return true; } $tab[0][1] = mc::n(mc::_("One player found"), mc::_("%1% players found", $cnt), $cnt); return $this->paginateTable($sender, $pageNumber, $tab); } return false; }
private function commonSubs(CommandSender $c, $args) { if (count($args) == 0) { return false; } switch (strtolower($args[0])) { case "list": case "ls": if (count($this->tasks) == 0) { $c->sendMessage(mc::_("No tasks currently scheduled")); return true; } $pageNumber = $this->getPageNumber($args); $tab = [[mc::_("Id"), mc::_("When"), mc::n(mc::_("One scheduled task"), mc::_("%1% scheduled tasks", count($this->tasks)), count($this->tasks))]]; foreach ($this->tasks as $tid => $cmd) { list($when, $line) = $cmd; $tab[] = [$tid, date(mc::_("d-M-Y H:i:s"), $when), $line]; } return $this->paginateTable($c, $pageNumber, $tab); case "cancel": if (count($args) != 2) { return false; } if (!isset($this->tasks[$args[1]])) { $c->sendMessage(mc::_("Task %1% not found!", $args[1])); return true; } $this->owner->getServer()->getScheduler()->cancelTask($args[1]); $c->sendMessage(mc::_("Cancelling Task %1%", $args[1])); return true; } return false; }
private function cmdPlayers(CommandSender $c, $pageNumber) { $all = []; foreach ($this->owner->getServer()->getOnlinePlayers() as $p) { $all[$p->getName()] = mc::_("*current-server*"); } foreach ($this->owner->getModule("ServerList")->getIds() as $id) { $host = $this->owner->getModule("ServerList")->getServerAttr($id, "query-host"); $port = $this->owner->getModule("ServerList")->getServerAttr($id, "port"); $Query = new MinecraftQuery(); try { $Query->Connect($host, $port, 1); } catch (MinecraftQueryException $e) { $this->owner->getLogger()->warning(mc::_("Query %1% failed: %2%", $host, $e->getMessage())); continue; } if (($players = $Query->GetPlayers()) === false) { continue; } if (count($players) == 0) { continue; } foreach ($players as $p) { if ($c->hasPermission("gb.cmd.query.players.showip")) { $all[$p] = "{$id} ({$host}:{$port})"; } else { $all[$p] = "{$id}"; } } } if (count($all) == 0) { $c->sendMessage(TextFormat::YELLOW . "Nobody is on-line at the moment"); } $txt = [mc::n(mc::_("One player found"), mc::_("%1% players found", count($all)), count($all))]; ksort($all, SORT_NATURAL); foreach ($all as $i => $j) { $txt[] = $i . " @ " . $j; } return $this->paginateText($c, $pageNumber, $txt); }
private function cmdPlayers(CommandSender $c, $pageNumber) { $all = []; foreach ($this->owner->getServer()->getOnlinePlayers() as $p) { $all[$p->getName()] = mc::_("*current-server*"); } foreach ($this->owner->getModule("ServerList")->getIds() as $id) { $cc = $this->queryServer($id); if ($cc === null) { continue; } if (!isset($cc["players"])) { continue; } if (count($cc["players"]) == 0) { continue; } if ($c->hasPermission("gb.cmd.query.players.showip")) { $host = $this->owner->getModule("ServerList")->getServerAttr($id, "query-host"); $port = $this->owner->getModule("ServerList")->getServerAttr($id, "port"); $inf = "{$id} ({$host}:{$port})"; } else { $inf = $id; } foreach ($cc["players"] as $p) { $all[$p] = $inf; } } if (count($all) == 0) { $c->sendMessage(TextFormat::YELLOW . "Nobody is on-line at the moment"); } $txt = [mc::n(mc::_("One player found"), mc::_("%1% players found", count($all)), count($all))]; ksort($all, SORT_NATURAL); foreach ($all as $i => $j) { $txt[] = $i . " @ " . $j; } return $this->paginateText($c, $pageNumber, $txt); }