/** * @param CommandSender $sender * @param Player $player */ public function sendPlayerInfo(CommandSender $sender, IPlayer $player) { $sender->sendMessage("Name: " . $player->getName()); $sender->sendMessage("Display-name: " . $player->getDisplayName()); $sender->sendMessage("Nametag: " . $player->getNameTag()); $sender->sendMessage("Address: " . $player->getAddress() . ":" . $player->getPort()); $sender->sendMessage("Client-id: " . $player->getClientId()); $sender->sendMessage("Entity-id: " . $player->getId()); $sender->sendMessage("Unique-id: " . $player->getUniqueId()); $sender->sendMessage("Health: " . $player->getHealth() . "/" . $player->getMaxHealth()); $sender->sendMessage("XYZ: " . $player->getFloorX() . ":" . $player->getFloorY() . ":" . $player->getFloorZ()); $sender->sendMessage("Level: " . $player->getLevel()->getName()); $sender->sendMessage("Yaw: " . $player->getYaw()); $sender->sendMessage("Pitch: " . $player->getPitch()); $sender->sendMessage("Gamemode: " . $player->getGamemode()); $sender->sendMessage("Is-sleeping: " . ($player->isSleeping() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-inside-water: " . ($player->isInsideOfWater() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-inside-solid: " . ($player->isInsideOfSolid() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-on-ground: " . ($player->isOnGround() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-on-fire: " . ($player->isOnFire() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); //$sender->sendMessage("Is-sneaking: ".($player->isSneaking() ? TextFormat::GREEN."yes" : TextFormat::RED."no")); //$sender->sendMessage("Is-sprinting: ".($player->isSprinting() ? TextFormat::GREEN."yes" : TextFormat::RED."no")); $sender->sendMessage("Is-skin-slim: " . ($player->isSkinSlim() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-nametag-visible: " . ($player->isNameTagVisible() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-online: " . ($player->isOnline() ? TextFormat::GREEN . "yes" : "no")); $sender->sendMessage("Is-connected: " . ($player->isConnected() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-valid: " . ($player->isValid() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-alive: " . ($player->isAlive() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-op: " . ($player->isOp() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-banned: " . ($player->isBanned() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-exempt: " . ($this->plugin->isExempted($player) ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-name-whitelisted: " . ($player->isWhitelisted() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $sender->sendMessage("Is-ip-whitelisted: " . ($this->plugin->isAddressWhitelisted($player->getAddress()) ? TextFormat::GREEN . "yes" : TextFormat::RED . "no")); $effectCount = 0; $effectNames = ""; foreach ($player->getEffects() as $effect) { $effectNames .= $effect->getName() . ", "; $effectCount++; } $sender->sendMessage("Effects (" . $effectCount . "): " . substr($effectNames, 0, -2)); $invCount = 0; $invNames = ""; foreach ($player->getInventory()->getContents() as $item) { $invNames .= $item->getName() . ", "; $invCount++; } $sender->sendMessage("Items (" . $invCount . "): " . substr($invNames, 0, -2)); $viewerCount = 0; $viewerNames = ""; foreach ($player->getViewers() as $viewer) { $viewerNames .= $viewer->getName() . ", "; $viewerCount++; } $sender->sendMessage("Viewers (" . $viewerCount . "): " . substr($viewerNames, 0, -2)); }
/** * @param CommandSender $sender * @param string $label * @param string[] $args * @return bool */ public function execute(CommandSender $sender, $label, array $args) { if (!$this->testPermission($sender)) { return false; } if (isset($args[0])) { switch (strtolower($args[0])) { case "help": $this->sendCommandHelp($sender); return true; case "level": if (isset($args[1])) { if ($level = $sender->getServer()->getLevelByName($args[1])) { $this->plugin->getInfoFetcher()->sendLevelInfo($sender, $level); } else { $sender->sendMessage(TextFormat::RED . "Failed to get information due to invalid level name."); } } else { $sender->sendMessage(TextFormat::RED . "Please specify a level name."); } return true; case "player": if (isset($args[1])) { if ($player = $sender->getServer()->getPlayer($args[1])) { $this->plugin->getInfoFetcher()->sendPlayerInfo($sender, $player); } else { $sender->sendMessage(TextFormat::RED . "Failed to get information due to invalid recipient."); } } else { $sender->sendMessage(TextFormat::RED . "Please specify a recipient."); } return true; default: $sender->sendMessage("Usage: /imanager <sub-command> [parameters]"); return false; } } else { $this->sendCommandHelp($sender); return false; } }
/** * @param PlayerPreLoginEvent $event * @priority HIGHEST * @ignoreCancelled true */ public function onPlayerPreLogin(PlayerPreLoginEvent $event) { if (!$this->plugin->isAddressWhitelisted($event->getPlayer()->getAddress()) and $this->plugin->getConfig()->getNested("plugin.ipWhitelist")) { $event->setCancelled(true); } }