예제 #1
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (!MPMU::inGame($sender)) {
         return true;
     }
     switch ($cmd->getName()) {
         case "gmc":
             $mode = 1;
             break;
         case "gms":
             $mode = 0;
             break;
         case "gma":
             $mode = 2;
             break;
         case "gmspc":
             $mode = 3;
             break;
         default:
             return false;
     }
     if ($mode !== $sender->getGamemode()) {
         $sender->setGamemode($mode);
         if ($mode !== $sender->getGamemode()) {
             $sender->sendMessage(TextFormat::RED . mc::_("Unable to change gamemode"));
         } else {
             $this->owner->getServer()->broadcastMessage(mc::_("%1% changed gamemode to %2% mode", $sender->getName(), MPMU::gamemodeStr($mode)));
         }
     } else {
         $sender->sendMessage(mc::_("You are already in %1% mode", MPMU::gamemodeStr($mode)));
     }
     return true;
 }
예제 #2
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "players") {
         return false;
     }
     $tab = [[mc::_("Player"), mc::_("World"), mc::_("Pos"), mc::_("Health"), mc::_("Mode")]];
     $cnt = 0;
     foreach ($this->owner->getServer()->getOnlinePlayers() as $player) {
         if (!$player->isOnline() || $sender instanceof Player && !$sender->canSee($player)) {
             continue;
         }
         $pos = $player->getPosition();
         $j = count($tab);
         $mode = substr(MPMU::gamemodeStr($player->getGamemode()), 0, 4);
         $tab[] = [$player->getName(), $player->getLevel()->getName(), $pos->getFloorX() . "," . $pos->getFloorY() . "," . $pos->getFloorZ(), intval($player->getHealth()) . '/' . intval($player->getMaxHealth()), $mode];
         ++$cnt;
     }
     if (!$cnt) {
         $sender->sendMessage(TextFormat::RED . mc::_("Nobody is on-line at the moment"));
         return true;
     }
     $tab[0][0] = mc::_("Players: %1%", $cnt);
     $pageNumber = $this->getPageNumber($args);
     return $this->paginateTable($sender, $pageNumber, $tab);
 }
예제 #3
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "whois") {
         return false;
     }
     $pageNumber = $this->getPageNumber($args);
     if (count($args) != 1) {
         $sender->sendMessage(mc::_("You must specify a player's name"));
         return true;
     }
     $target = $this->owner->getServer()->getPlayer($args[0]);
     if ($target == null) {
         $target = $this->owner->getServer()->getOfflinePlayer($args[0]);
         if ($target == null || !$target->hasPlayedBefore()) {
             $sender->sendMessage(mc::_("%1% can not be found.", $args[0]));
             return true;
         }
     }
     $txt = [];
     $txt[] = TextFormat::AQUA . mc::_("About %1%", $args[0]);
     $txt[] = TextFormat::GREEN . mc::_("On-Line: ") . TextFormat::WHITE . ($target->isOnline() ? mc::_("YES") : mc::_("NO"));
     if ($target instanceof Player) {
         $txt[] = TextFormat::GREEN . mc::_("Health: ") . TextFormat::WHITE . "[" . $target->getHealth() . "/" . $target->getMaxHealth() . "]";
         $txt[] = TextFormat::GREEN . mc::_("World: ") . TextFormat::WHITE . $target->getLevel()->getName();
         $txt[] = TextFormat::GREEN . mc::_("Location: ") . TextFormat::WHITE . "X:" . floor($target->getPosition()->x) . " Y:" . floor($target->getPosition()->y) . " Z:" . floor($target->getPosition()->z);
         if ($sender->hasPermission("gb.cmd.whois.showip")) {
             $txt[] = TextFormat::GREEN . mc::_("IP Address: ") . TextFormat::WHITE . $target->getAddress();
         }
         $txt[] = TextFormat::GREEN . mc::_("Gamemode: ") . TextFormat::WHITE . MPMU::gamemodeStr($target->getGamemode());
         $txt[] = TextFormat::GREEN . mc::_("Display Name: ") . TextFormat::WHITE . $target->getDisplayName();
         $txt[] = TextFormat::GREEN . mc::_("Flying: ") . TextFormat::WHITE . ($target->isOnGround() ? mc::_("NO") : mc::_("YES"));
         //1.5
         if (MPMU::apiVersion("1.12.0")) {
             $txt[] = TextFormat::GREEN . mc::_("UUID: ") . TextFormat::WHITE . $target->getUniqueId();
             $txt[] = TextFormat::GREEN . mc::_("ClientID: ") . TextFormat::WHITE . $target->getClientId();
             $txt[] = TextFormat::GREEN . mc::_("Can Fly: ") . TextFormat::WHITE . ($target->getAllowFlight() ? mc::_("YES") : mc::_("NO"));
         }
     } else {
         $txt[] = TextFormat::GREEN . mc::_("Banned: ") . TextFormat::WHITE . ($target->isBanned() ? mc::_("YES") : mc::_("NO"));
     }
     $txt[] = TextFormat::GREEN . mc::_("Whitelisted: ") . TextFormat::WHITE . ($target->isWhitelisted() ? mc::_("YES") : mc::_("NO"));
     $txt[] = TextFormat::GREEN . mc::_("Opped: ") . TextFormat::WHITE . ($target->isOp() ? mc::_("YES") : mc::_("NO"));
     $txt[] = TextFormat::GREEN . mc::_("First Played: ") . TextFormat::WHITE . date(mc::_("d-M-Y H:i"), $target->getFirstPlayed() / 1000);
     // $target->getLastPlayed()."\n";//##DEBUG
     if ($target->getLastPlayed()) {
         $txt[] = TextFormat::GREEN . mc::_("Last Played: ") . TextFormat::WHITE . date(mc::_("d-M-Y H:i"), $target->getLastPlayed() / 1000);
     }
     $pm = $this->owner->getServer()->getPluginManager();
     if (($kr = $pm->getPlugin("KillRate")) !== null) {
         if (version_compare($kr->getDescription()->getVersion(), "1.1") >= 0) {
             if (intval($kr->getDescription()->getVersion()) == 2) {
                 echo get_class($kr->api) . "\n";
                 //##DEBUG
                 $score = $kr->api->getScore($target);
             } else {
                 $score = $kr->getScore($target);
             }
             if ($score) {
                 $txt[] = TextFormat::GREEN . mc::_("KillRate Score: ") . TextFormat::WHITE . $score;
             }
         } else {
             $txt[] = TextFormat::RED . mc::_("KillRate version is too old (%1%)", $kr->getDescription()->getVersion());
         }
     }
     if (($pp = $pm->getPlugin("PurePerms")) !== null) {
         $txt[] = TextFormat::GREEN . mc::_("PurePerms Group: ") . TextFormat::WHITE . $pp->getUser($target)->getGroup()->getName();
     }
     if (($sa = $pm->getPlugin("SimpleAuth")) !== null) {
         if ($target instanceof Player) {
             $txt[] = TextFormat::GREEN . mc::_("Authenticated: ") . TextFormat::WHITE . ($sa->isPlayerAuthenticated($target) ? mc::_("YES") : mc::_("NO"));
         }
         $txt[] = TextFormat::GREEN . mc::_("Registered: ") . TextFormat::WHITE . ($sa->isPlayerRegistered($target) ? mc::_("YES") : mc::_("NO"));
     }
     $money = MoneyAPI::moneyPlugin($this->owner);
     if ($money !== null) {
         $txt[] = TextFormat::GREEN . mc::_("Money: ") . TextFormat::WHITE . MoneyAPI::getMoney($money, $target->getName()) . TextFormat::AQUA . mc::_(" (from %1%)", $money->getFullName());
     }
     return $this->paginateText($sender, $pageNumber, $txt);
 }
예제 #4
0
 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 = 0;
     foreach ($target->getInventory()->getContents() as $slot => &$inv) {
         if ($inv->getId() != $item->getId()) {
             continue;
         }
         if ($count !== null) {
             if ($inv->getCount() > $count) {
                 $k += $count;
                 $inv->setCount($inv->getCount() - $count);
                 $target->getInventory()->setItem($slot, clone $inv);
                 break;
             }
             $count -= $inv->getCount();
         }
         $k += $inv->getCount();
         $target->getInventory()->clear($slot);
         if ($count === 0) {
             break;
         }
     }
     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;
 }