public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub) { $mm = "[TeleportView] "; if ($sender->getName() == "CONSOLE") { $sender->sendMessage($mm . ($this->isKorean() ? "게임내에서만 사용가능합니다." : "Please run this command in-game")); return true; } $yaw = $sender->getYaw(); $pitch = $sender->getPitch(); $yawS = -sin($yaw / 180 * M_PI); $yawC = cos($yaw / 180 * M_PI); $pitchS = -sin($pitch / 180 * M_PI); $pitchC = cos($pitch / 180 * M_PI); $x = $sender->x; $y = $sender->y + $sender->getEyeHeight(); $z = $sender->z; $l = $sender->getLevel(); $ps = $this->getServer()->getOnlinePlayers(); for ($f = 0; $f < 50; ++$f) { $x += $yawS * $pitchC; $y += $pitchS; $z += $yawC * $pitchC; $b = $l->getBlock(new Position($x, $y, $z, $l)); if ($b->isSolid()) { break; } if ($f >= 50) { $sender->sendMessage($mm . ($this->isKorean() ? "타겟 블럭이 너무 멉니다." : "TargetBlock is too far")); return true; } } $sender->teleport(new Position($x, $y, $z, $sender->getLevel())); return true; }
public function execute(CommandSender $sender, array $args) { if (!$sender instanceof Player) { $sender->sendMessage(TextFormat::YELLOW . "Please run this command in game!"); return true; } $this->getMain()->selection[strtolower($sender->getName())]["pos2"] = ["x" => $sender->getFloorX(), "z" => $sender->getFloorZ(), "level" => $sender->getLevel()->getName()]; $sender->sendMessage(TextFormat::GREEN . "Pos 2 set to : x=" . $sender->getFloorX() . ", z=" . $sender->getFloorZ() . ", level=" . $sender->getLevel()->getName()); return true; }
public function execute(CommandSender $sender, array $args) { if (!$sender instanceof Player) { $sender->sendMessage($this->getMessage("error.in-game")); return true; } $this->getMain()->selection[strtolower($sender->getName())]["pos2"] = ["x" => $sender->getFloorX(), "z" => $sender->getFloorZ(), "level" => $sender->getLevel()->getName()]; $sender->sendMessage($this->getMessage("commands.pos2.set", ["POS" => "x=" . $sender->getFloorX() . ", z=" . $sender->getFloorZ() . ", level=" . $sender->getLevel()->getName()])); return true; }
public function onCommand(CommandSender $sender, Command $command, $label, array $args) { if (strtolower($command->{$getName}()) == "closest") { if ($sender instanceof Position) { // if the sender is a position, for example a player $closest = null; $lastSquare = -1; foreach ($sender->getLevel()->getPlayers() as $p) { // for every player in the sender's world if ($p !== $sender) { $square = $sender->distanceSquared($p); // get the square of the distance between the sender and the currently checking player // use distanceSquared() because it is faster than distance() if ($lastSquare === -1 or $lastSquare > $square) { // this is the so far closest player $closest = $p; $lastSquare = $square; } } } if ($sender instanceof Player) { $sender->sendMessage("The closest player to you is" . $closest); } } } }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub) { $mm = "[TeleportView] "; if ($sender->getName() == "CONSOLE") { $sender->sendMessage($mm . ($this->isKorean() ? "게임내에서만 사용가능합니다." : "Please run this command in-game")); return true; } $yaw = $sender->getYaw(); $ptch = $sender->getPitch(); $yawS = -sin($yaw / 180 * M_PI); $yawC = cos($yaw / 180 * M_PI); $ptchS = -sin($ptch / 180 * M_PI); $ptchC = cos($ptch / 180 * M_PI); $x = $sender->getX(); $y = $sender->getY() + $sender->getEyeHeight(); $z = $sender->getZ(); $l = $sender->getLevel(); for ($f = 0; $f < 50; ++$f) { $x += $yawS * $ptchC; $y += $ptchS; $z += $yawC * $ptchC; $b = $l->getBlock(new Position($x, $y, $z, $l)); if ($b->isSolid) { $sender->teleport(new Position($x - $yawS * $ptchC, $y - $ptchS + 0.1, $z - $yawC * $ptchC, $l)); $f = true; } } if (!isset($f)) { $sender->sendMessage($mm . ($this->isKorean() ? "타겟 블럭이 너무 멉니다." : "TargetBlock is too far")); } return true; }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { if ($cmd->getName() != "motd") { return false; } if ($sender instanceof Player) { $world = $sender->getLevel()->getName(); } else { $level = $this->owner->getServer()->getDefaultLevel(); if ($level) { $world = $level->getName(); } else { $world = null; } } if (isset($args[0]) && $this->owner->getServer()->isLevelGenerated($args[0])) { $world = array_shift($args); } if ($world === null) { $sender->sendMessage(mc::_("[WP] Must specify a world")); return false; } if (count($args) != 0) { return false; } $this->showMotd($sender, $world); return true; }
public function onCommand(CommandSender $issuer, Command $cmd, $label, array $args) { switch ($cmd->getName()) { case "setjail": if ($issuer->hasPermission("jail.command") !== true && $issuer->hasPermission("jail.command.setjail") !== true) { $issuer->sendMessage($this->plugin->colourMessage("&cYou don't have permission for this!")); return true; } if (!isset($args[0])) { return false; } $jail = $args[0]; if ($this->plugin->jailExists($jail) !== false) { $issuer->sendMessage($this->plugin->colourMessage("&cJail already exists!")); return true; } if (!$issuer instanceof Player) { $issuer->sendMessage($this->plugin->colourMessage("Command only works in-game!")); return true; } $this->plugin->setJail($jail, $issuer->x, $issuer->y, $issuer->z, $issuer->getLevel()); $issuer->sendMessage($this->plugin->colourMessage("&6You created jail: &c" . $jail . "&6!")); return true; break; } }
public function execute(CommandSender $sender, $currentAlias, array $args) { if (count($args) < 1) { $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage])); return false; } if ($sender instanceof Player) { $wea = (int) $args[0]; if ($wea >= 0 and $wea <= 3) { if (WeatherManager::isRegistered($sender->getLevel())) { $sender->getLevel()->getWeather()->setWeather($wea); $sender->sendMessage(TextFormat::GREEN . "天气设置成功!"); return true; } else { $sender->sendMessage(TextFormat::RED . "这个世界没有注册到天气管理器!"); return false; } } else { $sender->sendMessage(TextFormat::RED . "无效的天气!"); return false; } } if (count($args) < 2) { $sender->sendMessage(TextFormat::RED . "缺少参数!"); return false; } $level = $sender->getServer()->getLevelByName($args[0]); if (!$level instanceof Level) { $sender->sendMessage(TextFormat::RED . "错误的地图名!"); return false; } $wea = (int) $args[1]; if ($wea >= 0 and $wea <= 3) { if (WeatherManager::isRegistered($level)) { $level->getWeather()->setWeather($wea); $sender->sendMessage(TextFormat::GREEN . "天气设置成功!"); return true; } else { $sender->sendMessage(TextFormat::RED . "这个世界没有注册到天气管理器!"); return false; } } else { $sender->sendMessage(TextFormat::RED . "无效的天气!"); return false; } return true; }
public function parseVars($message, CommandSender $sender) : string { $level = $sender instanceof Player ? $sender->getLevel() : $this->plugin->getServer()->getDefaultLevel(); $replace = ["&", "{maxplayers}", "{playercount}", "{name}", "{playerlevel}", "{playerlevelcount}"]; $with = ["§", $this->plugin->getServer()->getMaxPlayers(), count($this->plugin->getServer()->getOnlinePlayers()), $sender instanceof Player ? $sender->getName() : "CONSOLE", $level->getName(), count($level->getPlayers())]; $message = str_replace($replace, $with, $message); return $message; }
public function format(Server $server, CommandSender $sender, $name, array $args) { if ($sender instanceof Position) { // command blocks? return $sender->getLevel()->getName(); } return false; }
public function onCommand(CommandSender $sender, Command $command, $label, array $args) { if (strtolower($command->getName()) === "spawnport") { if (!$sender instanceof Player) { $sender->sendMessage(TextFormat::AQUA . "Please run this command in game"); return true; } $worldspawn = $sender->getLevel()->getSpawnLocation(); $sender->teleport($worldspawn); $sender->sendMessage(TextFormat::AQUA . "Teleported to WorldSpawn"); } return true; }
public function execute(CommandSender $sender, $commandLabel, array $args) { if ($sender instanceof Player) { $sender->sendMessage("You are at {$sender->x},{$sender->y},{$sender->z};{$sender->yaw},{$sender->pitch}@{$sender->getLevel()->getName()}"); } else { if (!isset($args[0])) { $sender->sendMessage("Usage: /getpos <player>"); return true; } $player = $this->getPlugin()->getServer()->getPlayer($args[0]); if ($player instanceof Player) { $sender->sendMessage($player->getName() . " is at {$player->x},{$player->y},{$player->z};{$player->yaw},{$player->pitch}@{$player->getLevel()->getName()}"); } else { $sender->sendMessage("Player {$args['0']} not found"); } } return true; }
public function onCommand(CommandSender $sender, Command $command, $label, array $args) { switch ($command->getName()) { case "pos": if ($sender instanceof Player) { $playerX = $sender->getX(); $playerY = $sender->getY(); $playerZ = $sender->getZ(); $outX = round($playerX, 1); $outY = round($playerY, 1); $outZ = round($playerZ, 1); $playerLevel = $sender->getLevel()->getName(); $sender->sendMessage(TextFormat::BLUE . " x:" . TextFormat::GREEN . $outX . ", y:" . TextFormat::YELLOW . $outY . ", z:" . TextFormat::GREEN . $outZ . ". On: " . TextFormat::AQUA . $playerLevel); return true; } else { $sender->sendMessage("§cThis command only works §ein§f-§egame."); } } }
public function onCommand(CommandSender $sender, Command $command, $label, array $args) { switch ($command->getName()) { case "greenify": if (count($args) !== 0) { $sender->sendMessage(TextFormat::RED . "Usage: " . $command->getUsage()); return true; } $sender->sendMessage("Prepare for a lag spike!"); $level = $sender->getLevel(); $playerX = $sender->getFloorX(); $playerZ = $sender->getFloorZ(); for ($x = $playerX - 100; $x <= $playerX + 100; $x++) { for ($z = $playerZ - 100; $z <= $playerZ + 100; $z++) { $level->setBiomeColor($x, $z, 127, 169, 76); } } return true; } }
/** * @param CommandSender $sender * @param Command $cmd * @param $label * @param array $args * @return bool */ public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { switch (strtolower($cmd->getName())) { case 'rand': foreach ($this->getConfig()->get("Worlds") as $world) { if ($sender->hasPermission("randtp.rand")) { if ($sender instanceof Player && $sender->getLevel()->getName() !== $world) { $this->toRand($sender, self::RANDOM_TP); $sender->sendMessage(TXT::AQUA . "Teleported to X: " . TXT::YELLOW . $sender->getX() . TXT::AQUA . ", Y: " . TXT::YELLOW . $sender->getY() . TXT::AQUA . " Z: " . TXT::YELLOW . $sender->getZ()); } elseif (!$sender instanceof Player) { $sender->sendMessage(TXT::RED . "Please run this command in game."); return true; } elseif ($sender->getLevel()->getName() === $world) { $sender->sendMessage(TXT::RED . "You are not allowed to use that command in this world."); return true; } } } break; } }
public function onCommand(CommandSender $sender, Command $command, $label, array $params) { switch ($command->getName()) { case "rank": if (!$sender instanceof Player) { $sender->sendMessage(TextFormat::RED . "Please run this command in-game."); return true; } $data = $this->killDeath[0]; arsort($data); $cnt = 0; $send = "Your status : " . TextFormat::YELLOW . $this->killDeath[0][$sender->getName()] . TextFormat::WHITE . "kills/" . TextFormat::YELLOW . $this->killDeath[1][$sender->getName()] . TextFormat::WHITE . "deaths\n--------------------\n"; foreach ($data as $player => $datam) { $send .= TextFormat::GREEN . $player . TextFormat::WHITE . " " . TextFormat::YELLOW . $datam . TextFormat::WHITE . "kills/" . TextFormat::YELLOW . $this->killDeath[1][$player] . TextFormat::WHITE . "deaths\n"; if ($cnt >= 5) { break; } ++$cnt; } $sender->sendMessage($send); return true; case "spawnpos": $sub = strtolower(array_shift($params)); switch ($sub) { case "blue": case "b": if (!$sender instanceof Player) { $sender->sendMessage(TextFormat::RED . "Please run this command in-game."); return true; } $name = array_shift($params); if (trim($name) === "") { $sender->sendMessage(TextFormat::RED . "Usage: /spawnpos blue <name>"); return true; } $config = $this->getConfig()->get("spawn-pos"); if (isset($config[$name]["blue"])) { $sender->sendMessage(TextFormat::RED . "{$name} already exists."); return true; } $loc = [$sender->getX(), $sender->getY(), $sender->getZ(), $sender->getLevel()->getFolderName()]; $config[$name]["blue"] = $loc; $this->getConfig()->set("spawn-pos", $config); $this->getConfig()->save(); $sender->sendMessage("[MineCombat] Spawn position of BLUE team set."); return true; case "r": case "red": if (!$sender instanceof Player) { $sender->sendMessage(TextFormat::RED . "Please run this command in-game."); return true; } $name = array_shift($params); if (trim($name) === "") { $sender->sendMessage(TextFormat::RED . "Usage: /spawnpos red <name>"); return true; } $config = $this->getConfig()->get("spawn-pos"); if (isset($config[$name]["red"])) { $sender->sendMessage(TextFormat::RED . "{$name} already exists."); return true; } $loc = [$sender->getX(), $sender->getY(), $sender->getZ(), $sender->getLevel()->getFolderName()]; $config[$name]["red"] = $loc; $this->getConfig()->set("spawn-pos", $config); $this->getConfig()->save(); $sender->sendMessage("[MineCombat] Spawn position of RED team set."); return true; case "remove": $name = array_shift($params); if (trim($name) === "") { $sender->sendMessage(TextFormat::RED . "Usage: /spawnpos blue <name>"); return true; } $config = $this->getConfig()->get("spawn-pos"); $config[$name] = null; unset($config[$name]); $this->getConfig()->set("spawn-pos", $config); $this->getConfig()->save(); return true; case "list": $list = implode(", ", array_keys($this->getConfig()->get("spawn-pos"))); $sender->sendMessage("Positions list: \n" . $list); return true; default: $sender->sendMessage("Usage: " . $command->getUsage()); } return true; case "momap": $name = array_shift($params); if (trim($name) === "") { $sender->sendMessage(TextFormat::RED . "Usage: " . $command->getUsage()); return true; } if ($this->status === self::STAT_GAME_IN_PROGRESS) { $sender->sendMessage(TextFormat::RED . "Game is already in progress. Select map after the game is ended."); return true; } $pos = $this->getConfig()->get("spawn-pos"); if (!isset($pos[$name])) { $sender->sendMessage("Map " . TextFormat::RED . $name . TextFormat::WHITE . " exist!"); return true; } else { $selectedPos = $pos[$name]; if (($level = $this->getServer()->getLevelByName($selectedPos["blue"][3])) instanceof Level) { $this->spawnPos = [new Position($selectedPos["red"][0], $selectedPos["red"][1], $selectedPos["red"][2], $level), new Position($selectedPos["blue"][0], $selectedPos["blue"][1], $selectedPos["blue"][2], $level)]; $this->nextLevel = $name; $sender->sendMessage("Map was selected to " . TextFormat::AQUA . $name); } else { $this->getLogger()->critical("Invalid level name was given."); $this->getServer()->shutdown(); } } return true; } return true; }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $param) { switch ($cmd->getName()) { case "startp": if (!$sender instanceof Player) { $sender->sendMessage("Please run this command in-game."); return true; } $x = (int) $sender->x; $z = (int) $sender->z; $level = $sender->getLevel()->getFolderName(); $this->start[$sender->getName()] = array("x" => $x, "z" => $z, "level" => $level); $sender->sendMessage($this->getMessage("first-position-saved")); return true; case "endp": if (!$sender instanceof Player) { $sender->sendMessage("Please run this command in-game."); return true; } if (!isset($this->start[$sender->getName()])) { $sender->sendMessage($this->getMessage("set-first-position")); return true; } if ($sender->getLevel()->getFolderName() !== $this->start[$sender->getName()]["level"]) { $sender->sendMessage($this->getMessage("cant-set-position-in-different-world")); return true; } $startX = $this->start[$sender->getName()]["x"]; $startZ = $this->start[$sender->getName()]["z"]; $endX = (int) $sender->x; $endZ = (int) $sender->z; $this->end[$sender->getName()] = array("x" => $endX, "z" => $endZ); if ($startX > $endX) { $temp = $endX; $endX = $startX; $startX = $temp; } if ($startZ > $endZ) { $temp = $endZ; $endZ = $startZ; $startZ = $temp; } $startX--; $endX++; $startZ--; $endZ++; $price = ($endX - $startX - 1) * ($endZ - $startZ - 1) * $this->config->get("price-per-y-axis"); $sender->sendMessage($this->getMessage("confirm-buy-land", array($price, "%2", "%3"))); return true; case "land": $sub = array_shift($param); switch ($sub) { case "buy": if (!$sender->hasPermission("economyland.command.land.buy")) { return true; } if (!$sender instanceof Player) { $sender->sendMessage("Please run this command in-game."); return true; } if (in_array($sender->getLevel()->getFolderName(), $this->config->get("buying-disallowed-worlds"))) { $sender->sendMessage($this->getMessage("not-allowed-to-buy")); return true; } // $result = $this->land->query("SELECT * FROM land WHERE owner = '{$sender->getName()}'"); $cnt = count($this->db->getLandsByOwner($sender->getName())); if (is_numeric($this->config->get("player-land-limit"))) { if ($cnt >= $this->config->get("player-land-limit")) { $sender->sendMessage($this->getMessage("land-limit", array($cnt, $this->config->get("player-land-limit"), "%3", "%4"))); return true; } /* while($result->fetchArray(SQLITE3_ASSOC) !== false){ ++$cnt; if($cnt >= $this->config->get("player-land-limit")){ $sender->sendMessage($this->getMessage("land-limit", array($cnt, $this->config->get("player-land-limit")))); return true; } }*/ } if (!isset($this->start[$sender->getName()])) { $sender->sendMessage($this->getMessage("set-first-position")); return true; } elseif (!isset($this->end[$sender->getName()])) { $sender->sendMessage($this->getMessage("set-second-position")); return true; } $l = $this->start[$sender->getName()]; $endp = $this->end[$sender->getName()]; $startX = (int) $l["x"]; $endX = (int) $endp["x"]; $startZ = (int) $l["z"]; $endZ = (int) $endp["z"]; if ($startX > $endX) { $backup = $startX; $startX = $endX; $endX = $backup; } if ($startZ > $endZ) { $backup = $startZ; $startZ = $endZ; $endZ = $backup; } /*$result = $this->land->query("SELECT * FROM land WHERE startX <= $endX AND endX >= $endX AND startZ <= $endZ AND endZ >= $endZ AND level = '{$sender->getLevel()->getFolderName()}'")->fetchArray(SQLITE3_ASSOC); if(!is_bool($result)){ $sender->sendMessage($this->getMessage("land-around-here", array($result["owner"], "", ""))); return true; }*/ $result = $this->db->checkOverlap($startX, $endX, $startZ, $endZ, $sender->getLevel()->getFolderName()); if ($result) { $sender->sendMessage($this->getMessage("land-around-here", array($result["owner"], "%2", "%3"))); return true; } $price = ($endX + 1 - ($startX - 1) - 1) * ($endZ + 1 - ($startZ - 1) - 1) * $this->config->get("price-per-y-axis"); if (EconomyAPI::getInstance()->reduceMoney($sender, $price, true, "EconomyLand") === EconomyAPI::RET_INVALID) { $sender->sendMessage($this->getMessage("no-money-to-buy-land")); return true; } // $this->land->exec("INSERT INTO land (startX, endX, startZ, endZ, owner, level, price, invitee) VALUES ($startX, $endX, $startZ, $endZ, '{$sender->getName()}', '{$this->start[$sender->getName()]["level"]}', $price, ',')"); $this->db->addLand($startX, $endX, $startZ, $endZ, $sender->getLevel()->getFolderName(), $price, $sender->getName()); unset($this->start[$sender->getName()], $this->end[$sender->getName()]); $sender->sendMessage($this->getMessage("bought-land", array($price, "%2", "%3"))); break; case "list": if (!$sender->hasPermission("economyland.command.land.list")) { return true; } $page = isset($param[0]) ? (int) $param[0] : 1; $land = $this->db->getAll(); $output = ""; $max = ceil(count($land) / 5); $pro = 1; $page = (int) $page; $output .= $this->getMessage("land-list-top", array($page, $max, "")); $current = 1; foreach ($land as $l) { $cur = (int) ceil($current / 5); if ($cur > $page) { continue; } if ($pro == 6) { break; } if ($page === $cur) { $output .= $this->getMessage("land-list-format", array($l["ID"], ($l["endX"] - $l["startX"]) * ($l["endZ"] - $l["startZ"]), $l["owner"])); $pro++; } $current++; } $sender->sendMessage($output); break; case "whose": if (!$sender->hasPermission("economyland.command.land.whose")) { return true; } $player = array_shift($param); $alike = true; if (str_replace(" ", "", $player) === "") { $player = $sender->getName(); $alike = false; } /// $result = $this->land->query("SELECT * FROM land WHERE owner ".($alike ? "LIKE '%".$player."%'" : "= '".$player."'")); if ($alike) { $lands = $this->db->getLandsByKeyword($player); } else { $lands = $this->db->getLandsByOwner($player); } $sender->sendMessage("Results from query : {$player}\n"); // while(($info = $result->fetchArray(SQLITE3_ASSOC)) !== false){ foreach ($lands as $info) { $sender->sendMessage($this->getMessage("land-list-format", array($info["ID"], ($info["endX"] - $info["startX"]) * ($info["endZ"] - $info["startZ"]), $info["owner"]))); } //} break; case "move": if (!$sender instanceof Player) { $sender->sendMessage("Please run this command in-game."); return true; } if (!$sender->hasPermission("economyland.command.land.move")) { return true; } $num = array_shift($param); if (trim($num) == "") { $sender->sendMessage("Usage: /land move <land num>"); return true; } if (!is_numeric($num)) { $sender->sendMessage("Usage: /land move <land num>"); return true; } //$result = $this->land->query("SELECT * FROM land WHERE ID = $num"); // $info = $result->fetchArray(SQLITE3_ASSOC); $info = $this->db->getLandById($num); if ($info === false) { $sender->sendMessage($this->getMessage("no-land-found", array($num, "", ""))); return true; } if ($info["owner"] !== $sender->getName()) { if (!$sender->hasPermission("economyland.land.move.others")) { $sender->sendMessage($this->getMessage("no-permission-move", [$info["ID"], $info["owner"], "%3"])); return true; } } $level = $this->getServer()->getLevelByName($info["level"]); if (!$level instanceof Level) { $sender->sendMessage($this->getMessage("land-corrupted", array($num, "", ""))); return true; } $x = (int) $info["startX"] + ($info["endX"] - $info["startX"]) / 2; $z = (int) $info["startZ"] + ($info["endZ"] - $info["startZ"]) / 2; $cnt = 0; for ($y = 1;; $y++) { if ($level->getBlock(new Vector3($x, $y, $z))->getID() === 0) { break; } if ($cnt === 5) { break; } if ($y > 255) { ++$cnt; ++$x; --$z; $y = 1; continue; } } $sender->teleport(new Position($x, $y, $z, $level)); $sender->sendMessage($this->getMessage("success-moving", array($num, "", ""))); return true; case "give": if (!$sender instanceof Player) { $sender->sendMessage("Please run this command in-game."); return true; } if (!$sender->hasPermission("economyland.command.land.give")) { return true; } $player = array_shift($param); $landnum = array_shift($param); if (trim($player) == "" or trim($landnum) == "" or !is_numeric($landnum)) { $sender->sendMessage("Usage: /{$cmd} give <player> <land number>"); return true; } $username = $player; $player = $this->getServer()->getPlayer($username); if (!$player instanceof Player) { $sender->sendMessage($this->getMessage("player-not-connected", [$username, "%2", "%3"])); return true; } // $info = $this->land->query("SELECT * FROM land WHERE ID = $landnum")->fetchArray(SQLITE3_ASSOC); $info = $this->db->getLandById($landnum); if ($info === false) { $sender->sendMessage($this->getMessage("no-land-found", array($landnum, "%2", "%3"))); return true; } if ($sender->getName() !== $info["owner"] and !$sender->hasPermission("economyland.land.give.others")) { $sender->sendMessage($this->getMessage("not-your-land", array($landnum, "%2", "%3"))); } else { if ($sender->getName() === $player->getName()) { $sender->sendMessage($this->getMessage("cannot-give-land-myself")); } else { // $this->land->exec("UPDATE land SET owner = '{$player->getName()}' WHERE ID = {$info["ID"]}"); $this->db->setOwnerById($info["ID"], $player->getName()); $sender->sendMessage($this->getMessage("gave-land", array($landnum, $player->getName(), "%3"))); $player->sendMessage($this->getMessage("got-land", array($sender->getName(), $landnum, "%3"))); } } return true; case "invite": if (!$sender->hasPermission("economyland.command.land.invite")) { $sender->sendMessage("You don't have permissions to use this command."); return true; } $landnum = array_shift($param); $player = array_shift($param); if (trim($player) == "" or trim($landnum) == "") { $sender->sendMessage("Usage : /land <invite> <land number> <[r:]player>"); return true; } if (!is_numeric($landnum)) { $sender->sendMessage($this->getMessage("land-num-must-numeric", array($landnum, "%2", "%3"))); return true; } //$result = $this->land->query("SELECT * FROM land WHERE ID = $landnum"); //$info = $result->fetchArray(SQLITE3_ASSOC); $info = $this->db->getLandById($landnum); if ($info === false) { $sender->sendMessage($this->getMessage("no-land-found", array($landnum, "%2", "%3"))); return true; } elseif ($info["owner"] !== $sender->getName()) { $sender->sendMessage($this->getMessage("not-your-land", array($landnum, "%2", "%3"))); return true; } elseif (substr($player, 0, 2) === "r:") { if (!$sender->hasPermission("economyland.command.land.invite.remove")) { $sender->sendMessage("You don't have permissions to use this command."); return true; } $player = substr($player, 2); //$this->land->exec("UPDATE land SET invitee = '".str_replace($player.",", "", $info["invitee"])."' WHERE ID = {$info["ID"]};"); $result = $this->db->removeInviteeById($landnum, $player); if ($result === false) { $sender->sendMessage($this->getMessage("not-invitee", array($player, $landnum, "%3"))); return true; } $sender->sendMessage($this->getMessage("removed-invitee", array($player, $landnum, "%3"))); } else { /*if(strpos($info["invitee"], ",".$player.",") !== false){ $sender->sendMessage($this->getMessage("already-invitee", array($player, "", ""))); return true; } $this->land->exec("UPDATE land SET invitee = '".$info["invitee"].$player.",' WHERE ID = {$info["ID"]};");*/ if (preg_match('#^[a-zA-Z0-9_]{3,16}$#', $player) == 0) { $sender->sendMessage($this->getMessage("invalid-invitee", [$player, "%2", "%3"])); return true; } $result = $this->db->addInviteeById($landnum, $player); if ($result === false) { $sender->sendMessage($this->getMessage("already-invitee", array($player, "%2", "%3"))); return true; } $sender->sendMessage($this->getMessage("success-invite", array($player, $landnum, "%3"))); } return true; case "invitee": $landnum = array_shift($param); if (trim($landnum) == "" or !is_numeric($landnum)) { $sender->sendMessage("Usage: /land invitee <land number>"); return true; } $info = $this->db->getInviteeById($landnum); if ($info === false) { $sender->sendMessage($this->getMessage("no-land-found", array($landnum, "%2", "%3"))); return true; } $output = "Invitee of land #{$landnum} : \n"; $output .= implode(", ", $info); $sender->sendMessage($output); return true; case "here": if (!$sender instanceof Player) { $sender->sendMessage("Please run this command in-game."); return true; } $x = $sender->x; $z = $sender->z; $info = $this->db->getByCoord($x, $z, $sender->getLevel()->getFolderName()); if ($info === false) { $sender->sendMessage($this->getMessage("no-one-owned")); return true; } $sender->sendMessage($this->getMessage("here-land", array($info["ID"], $info["owner"], "%3"))); return true; default: $sender->sendMessage("Usage: " . $cmd->getUsage()); } return true; case "landsell": $id = array_shift($param); switch ($id) { case "here": if (!$sender instanceof Player) { $sender->sendMessage("Please run this command in-game."); return true; } $x = $sender->getX(); $z = $sender->getZ(); //$result = $this->land->query("SELECT * FROM land WHERE (startX < $x AND endX > $x) AND (startZ < $z AND endZ > $z) AND level = '{$sender->getLevel()->getFolderName()}'"); //$info = $result->fetchArray(SQLITE3_ASSOC); $info = $this->db->getByCoord($x, $z, $sender->getLevel()->getFolderName()); if ($info === false) { $sender->sendMessage($this->getMessage("no-one-owned")); return true; } if ($info["owner"] !== $sender->getName() and !$sender->hasPermission("economyland.landsell.others")) { $sender->sendMessage($this->getMessage("not-my-land")); } else { EconomyAPI::getInstance()->addMoney($sender, $info["price"] / 2); $sender->sendMessage($this->getMessage("sold-land", array($info["price"] / 2, "%2", "%3"))); //$this->land->exec("DELETE FROM land WHERE ID = {$info["ID"]}"); $this->db->removeLandById($info["ID"]); } return true; default: $p = $id; if (is_numeric($p)) { //$info = $this->land->query("SELECT * FROM land WHERE ID = $p")->fetchArray(SQLITE3_ASSOC); $info = $this->db->getLandById($p); if ($info === false) { $sender->sendMessage($this->getMessage("no-land-found", array($p, "%2", "%3"))); return true; } if ($info["owner"] === $sender->getName() or $sender->hasPermission("economyland.landsell.others")) { EconomyAPI::getInstance()->addMoney($sender, $info["price"] / 2, true, "EconomyLand"); $sender->sendMessage($this->getMessage("sold-land", array($info["price"] / 2, "", ""))); //$this->land->exec("DELETE FROM land WHERE ID = $p"); $this->db->removeLandById($p); } else { $sender->sendMessage($this->getMessage("not-your-land", array($p, $info["owner"], "%3"))); } } else { $sender->sendMessage("Usage: /landsell <here|land number>"); } } return true; } return false; }
/** * @param CommandSender $sender * @param string $commandLabel * @param string[] $args * * @return mixed */ public function execute(CommandSender $sender, $commandLabel, array $args) { if ($sender->hasPermission(SimpleWarpPermissions::ADD_WARP_COMMAND)) { if (isset($args[0])) { if (!isset($this->api->getWarpManager()[$args[0]])) { if (substr($args[0], 0, 4) === "ess:" && $this->api->getConfigItem("essentials-support") && $sender->hasPermission("simplewarp.essentials.notice")) { $sender->sendMessage($this->api->executeTranslationItem("addwarp-ess-prefix-warning")); } if (isset($args[4])) { $level = $this->api->getSimpleWarp()->getServer()->getLevelByName($args[4]); if ($level instanceof Level) { $dest = new Destination(new WeakPosition($args[1], $args[2], $args[3], $args[4])); $warp = new Warp($args[0], $dest); $ev = new WarpAddEvent($sender, $warp); $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev); if (!$ev->isCancelled()) { $this->api->getWarpManager()[$args[0]] = $warp; $sender->sendMessage($this->api->executeTranslationItem("warp-added-xyz", $args[0], $dest->toString())); } else { $sender->sendMessage($this->api->executeTranslationItem("addwarp-event-cancelled")); } } else { $sender->sendMessage($this->api->executeTranslationItem("level-not-loaded")); } } elseif (isset($args[2])) { $dest = new Destination($args[1], $args[2]); $warp = new Warp($args[0], $dest); $ev = new WarpAddEvent($sender, $warp); $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev); if (!$ev->isCancelled()) { $this->api->getWarpManager()[$args[0]] = $warp; $sender->sendMessage($this->api->executeTranslationItem("warp-added-server", $args[0], $dest->toString())); if (!$this->api->isFastTransferLoaded()) { $sender->sendMessage($this->api->executeTranslationItem("needs-fast-transfer")); } } else { $sender->sendMessage($this->api->executeTranslationItem("addwarp-event-cancelled")); } } elseif (isset($args[1])) { if (($player = $this->api->getSimpleWarp()->getServer()->getPlayer($args[1])) instanceof Player) { $dest = new Destination(new Position($player->getX(), $player->getY(), $player->getZ(), $player->getLevel())); $warp = new Warp($args[0], $dest); $ev = new WarpAddEvent($sender, $warp); $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev); if (!$ev->isCancelled()) { $this->api->getWarpManager()[$args[0]] = $warp; $sender->sendMessage($this->api->executeTranslationItem("warp-added-player", $args[0], $dest->toString())); } else { $sender->sendMessage($this->api->executeTranslationItem("addwarp-event-cancelled")); } } else { $sender->sendMessage($this->api->executeTranslationItem("player-not-loaded")); } } else { if ($sender instanceof Player) { $dest = new Destination(new Position($sender->getX(), $sender->getY(), $sender->getZ(), $sender->getLevel())); $warp = new Warp($args[0], $dest); $ev = new WarpAddEvent($sender, $warp); $this->getPlugin()->getServer()->getPluginManager()->callEvent($ev); if (!$ev->isCancelled()) { $this->api->getWarpManager()[$args[0]] = $warp; $sender->sendMessage($this->api->executeTranslationItem("warp-added-self", $args[0], $dest->toString())); } else { $sender->sendMessage($this->api->executeTranslationItem("addwarp-event-cancelled")); } } else { $sender->sendMessage($this->getUsage()); } } } else { $sender->sendMessage($this->api->executeTranslationItem("bad-warp-name")); } } else { $sender->sendMessage($this->getUsage()); Version::sendVersionMessage($sender); } } else { $sender->sendMessage($this->api->executeTranslationItem("addwarp-no-perm")); } }
public function onCommand(CommandSender $sender, Command $command, $label, array $args) { if (strtolower($command->getName()) == "is") { if (!isset($args[0])) { $sender->sendMessage(TextFormat::YELLOW . "No pusiste un subcomando"); $sender->sendMessage(TextFormat::GREEN . "Usa: " . TextFormat::RESET . "/is help"); return true; } elseif (isset($args[0])) { if ($args[0] == "help") { if ($sender->hasPermission("is") || $sender->hasPermission("is.help")) { if (!isset($args[1]) or $args[1] == "1") { $sender->sendMessage(TextFormat::GREEN . "[Skyblock] Enseñando lista de Ayuda"); $sender->sendMessage(TextFormat::GREEN . "/is help"); $sender->sendMessage(TextFormat::GREEN . "/is create"); $sender->sendMessage(TextFormat::GREEN . "/is home"); $sender->sendMessage(TextFormat::GREEN . "/is sethome"); $sender->sendMessage(TextFormat::GREEN . "/is find (Solo Op)"); return true; } elseif ($args[1] == "2") { $sender->sendMessage("Pronto habra mas Comandos"); return true; } } else { $sender->sendMessage(TextFormat::RED . "[SkyBlock] No puedes ver el menu de ayuda"); return true; } } elseif ($args[0] == "create") { if ($sender->hasPermission("is") || $sender->hasPermission("is.command") || $sender->hasPermission("is.command.create")) { $senderIs = $this->getDataFolder() . "Islands/" . $sender->getName() . ".txt"; if ($sender->getLevel()->getName() == $this->getConfig()->get("Lobby")) { $sender->sendMessage(TextFormat::YELLOW . "[Skyblock] No Puedes Hacer una isla en Spawn, desgraciado :L"); return true; } else { if (!file_exists($senderIs)) { $this->makeIsland($sender->getName()); return true; } else { $sender->sendMessage(TextFormat::YELLOW . "[Skyblock] Tu ya tienes una isla!"); return true; } } } else { $sender->sendMessage(TextFormat::RED . "[Skyblock] Tu No Puedes Crear una isla!"); return true; } } elseif ($args[0] == "home") { if ($sender->hasPermission("is") || $sender->hasPermission("is.command") || $sender->hasPermission("is.command.home")) { if (!file_exists($this->getDataFolder() . "Islands/" . $sender->getName() . ".txt")) { $sender->sendMessage("You don't have an island. Use /is create to make one"); return true; } else { $level = $this->getServer()->getLevelByName(yaml_parse_file($this->getDataFolder() . "Players/" . $sender->getName() . ".txt")); if ($level !== null) { $sender->sendMessage(TextFormat::GREEN . "Teleporting to your island..."); if ($sender->getLevel()->getName() !== $level->getName()) { $sender->sendMessage(TextFormat::RED . "[Skyblock] Tu no estas en el mismo mundo de tu isla. Usa " . TextFormat::YELLOW . "/mw tp " . $level->getName() . TextFormat::RESET . " E intenta de nuevo"); return true; } else { $sender->teleport(new Vector3(yaml_parse_file($this->getDataFolder() . "Islands/" . $sender->getName() . ".txt"))); $sender->sendMessage(TextFormat::GREEN . "[Skyblock] Listo!"); return true; } } else { $sender->sendMessage(TextFormat::RED . "[Skyblock] Un Error a ocurrido."); return true; } } } else { $sender->sendMessage(TextFormat::ORANGE . "[Skyblock] No Tienes permisos para hacer eso"); return true; } } elseif ($args[0] == "find") { if ($sender->hasPermission("is") || $sender->hasPermission("is.command") || $sender->hasPermission("is.command.find")) { if (isset($args[1])) { $p = $sender->getServer()->getPlayer($args[1]); if ($p instanceof Player) { $name = $p->getName(); if (file_exists($this->getDataFolder() . "Islands/" . $name . ".txt")) { $sender->sendMessage("The coords for " . $name . "'s island are"); $sender->sendMessage(file_get_contents($this->getDataFolder() . "Islands/" . $name . ".txt")); $sender->sendMessage(file_get_contents($this->getDataFolder() . "Players/" . $name . ".txt")); return true; } else { $sender->sendMessage(TextFormat::YELLOW . "[Skyblock] " . $name . " No Tiene una Isla"); return true; } } elseif (file_exists($this->getDataFolder() . "Islands/" . $args[1] . ".txt")) { $sender->sendMessage("The coords for " . $args[1] . "'s island are"); $sender->sendMessage(file_get_contents($this->getDataFolder() . "Islands/" . $args[1] . ".txt")); $sender->sendMessage("in world " . file_get_contents($this->getDataFolder() . "Players/" . $args[1] . ".txt")); return true; } } else { $sender->sendMessage(TextFormat::YELLOW . "[Skyblock] Necesitas especificar un Jugador"); return true; } } else { $sender->sendMessage(TextFormat::YELLOW . "[Skyblock] Tu no Puedes encontrar la s coordenadas de la isla de un jugador"); return true; } } elseif ($args[0] == "delete") { if ($sender->hasPermission("is") || $sender->hasPermission("is.command") || $sender->hasPermission("is.command.delete")) { if (!isset($args[1])) { $sender->sendMessage(TextFormat::RED . "[Skyblock] Estas Seguro? Usa /is delete yes para confirmar"); return true; } elseif ($args[1] == "yes") { if (file_exists($this->getDataFolder() . "Islands/" . $sender->getName() . ".txt")) { unlink($this->getDataFolder() . "Islands/" . $sender->getName() . ".txt"); $sender->sendMessage(TextFormat::BLUE . "[Skyblock] Tu Isla a sido eliminada!"); return true; } else { $sender->sendMessage(TextFormat::YELLOW . "[Skyblock] Tu no Tienes una isla!"); return true; } } elseif ($args[1] == "no") { $sender->sendMessage(TextFormat::GRAY . "[Skyblock] Ok, No eliminaremos tu isla, De todos modos nos vale queso :D"); return true; } else { return false; } } else { $sender->sendMessage(TextFormat::RED . "[Skyblock] Tu No puedes eliminar tu Isla"); return true; } } elseif ($args[0] == "sethome") { if ($sender->hasPermission("is") || $sender->hasPermission("is.command") || $sender->hasPermission("is.command.sethome")) { if (!isset($args[1])) { $sender->sendMessage(TextFormat::RED . "[Skyblock] Estas seguro? Asegurate que estas en tu isla"); $sender->sendMessage(TextFormat::RED . "[Skyblock] Tu Isla se perdera si no estas en tu isla. Pon /is sethome yes para confirmar"); return true; } elseif ($args[1] == "yes") { if (file_exists($this->getDataFolder() . "Islands/" . $sender->getName() . ".txt")) { $sender->sendMessage("[Skyblock] Setting your home..."); $file = $this->getDataFolder() . "Islands/" . $sender->getName() . ".txt"; unlink($file); $newFile = fopen($file, "w"); fwrite($newFile, $sender->x . ", " . $sender->y . ", " . $sender->z); $sender->sendMessage(TextFormat::GREEN . "[Skyblock] Pones Home en el lugar que quieres."); return true; } else { $sender->sendMessage(TextFormat::RED . "[Skyblock] TU no tienes una isla!"); return true; } } elseif ($args[1] == "no") { $sender->sendMessage(TextFormat::BLUE . "[Skyblock] Ok, no haremos eso...."); return true; } else { $sender->sendMessage(TextFormat::GRAY . "[Skyblock] Comando Desconosido: " . $args[1]); $sender->sendMessage(TextFormat::GREEN . "[Skyblock] /sethome <yes | no>"); return true; } } else { $sender->sendMessage(TextFormat::RED . "[Skyblock] No tienes permiso para Poner Home."); return true; } } } } }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { if ($cmd->getName() != "mobster") { return false; } if (isset($args[0]) && strtolower($args[0]) == "spawn") { array_shift($args); } if (!$sender->hasPermission("mobsters.cmd.spawn")) { $sender->sendMessage("You are not allowed to do that!"); return true; } if (count($args) != 2) { return false; } $mob = strtolower(array_shift($args)); if (($class = $this->mobClass($mob)) === null) { $sender->sendMessage("Unknown mob class: {$mob}"); return true; } $location = explode(":", array_shift($args), 2); if (count($location) < 2) { if ($sender instanceof Player) { $level = $sender->getLevel(); } else { $level = $this->getServer()->getDefaultLevel(); } } else { $level = $this->getServer()->getLevelByName($location[1]); if ($level === null) { $sender->sendMessage("Unknown level: " . $location[1]); return true; } } $location = array_map("floatval", explode(",", $location[0], 5)); if (count($location) < 3) { $sender->sendMessage("Invalid location specified"); return false; } $location = new Location(...$location); $location->setLevel($level); $this->spawnMob($class, $location); $sender->sendMessage("Spawned {$mob}"); return true; }
public function execute(CommandSender $sender, array $args) { if (count($args) > 1) { return false; } $name = ""; if (isset($args[0])) { $name = $args[0]; } $player = $sender->getServer()->getPlayer($sender->getName()); $plot = $this->getPlugin()->getPlotByPosition($player->getPosition()); if ($plot === null) { $sender->sendMessage(TextFormat::RED . "You are not standing on an island"); return true; } if ($plot->owner != "") { if ($plot->owner === $sender->getName()) { $sender->sendMessage(TextFormat::RED . "You already own this island"); } else { $sender->sendMessage(TextFormat::RED . "This island is already claimed by " . $plot->owner); } return true; } $plotLevel = $this->getPlugin()->getLevelSettings($plot->levelName); $maxPlotsInLevel = $plotLevel->maxPlotsPerPlayer; $maxPlots = $this->getPlugin()->getConfig()->get("MaxPlotsPerPlayer"); $plotsOfPlayer = $this->getPlugin()->getProvider()->getPlotsByOwner($player->getName()); if ($maxPlotsInLevel >= 0 and count($plotsOfPlayer) >= $maxPlotsInLevel) { $sender->sendMessage(TextFormat::RED . "You reached the limit of {$maxPlotsInLevel} islands per player in this world"); return true; } elseif ($maxPlots >= 0 and count($plotsOfPlayer) >= $maxPlots) { $sender->sendMessage(TextFormat::RED . "You reached the limit of {$maxPlots} islands per player"); return true; } $economy = $this->getPlugin()->getEconomyProvider(); if ($economy !== null and !$economy->reduceMoney($player, $plotLevel->claimPrice)) { $sender->sendMessage(TextFormat::RED . "You don't have enough money to claim this island"); return true; } $plot->owner = $sender->getName(); $plot->name = $name; if ($this->getPlugin()->getProvider()->savePlot($plot)) { if ($sender instanceof Player) { $sender->sendMessage(TextFormat::GREEN . "You are now the owner of " . TextFormat::WHITE . $plot); // chest $position = $this->getPlugin()->getPlotPosition($plot); // debug $position = $player->getPosition(); $position instanceof Position; $chest = $position->getLevel()->getBlock(new Vector3(floor($position->getX()), 30 + (69 - 64), floor($position->getZ()))); $position->getLevel()->setBlock(new Vector3(floor($position->getX()), 30 + (69 - 64), floor($position->getZ())), new Block(Block::CHEST), true, true); $nbt = new Compound("", [new Enum("Items", []), new String("id", Tile::CHEST), new Int("x", floor($position->getX())), new Int("y", floor($position->getY())), new Int("z", floor($position->getZ()))]); $nbt->Items->setTagType(NBT::TAG_Compound); $tile = Tile::createTile("Chest", $sender->getLevel()->getChunk(floor($position->getX()) >> 4, floor($position->getZ()) >> 4), $nbt); if (!$tile instanceof \pocketmine\tile\Chest) { continue; } $tile->getInventory()->addItem(new Item(Item::ICE, 0, 2), new Item(Item::BUCKET, 10, 1), new Item(Item::MELON_SLICE, 0, 1), new Item(Item::CACTUS, 0, 1), new Item(Item::RED_MUSHROOM, 0, 1), new Item(Item::BROWN_MUSHROOM, 0, 1), new Item(Item::PUMPKIN_SEEDS, 0, 1), new Item(Item::SUGAR_CANE, 0, 1), new Item(Item::SIGN, 0, 1)); $sender->sendTip(TextFormat::GREEN . TextFormat::BOLD . "A new SkyBlock\n" . TextFormat::GOLD . "by thebigsmileXD"); } } else { $sender->sendMessage(TextFormat::RED . "Something went wrong"); } return true; }
public function printInviteList(CommandSender $player) { $area = $this->db[$player->getLevel()->getFolderName()]->getArea($player->x, $player->z); if ($area == null) { $this->alert($player, $this->get("area-doesent-exist")); $this->alert($player, $this->get("need-area-to-invitelist")); return false; } if ($area["resident"][0] != $player->getName()) { $this->alert($player, $this->get("here-is-not-your-area")); return false; } else { $this->message($player, $this->get("print-invited-list") . "(" . count() . ")"); } return true; }
public function onCommand(CommandSender $sender, Command $command, $label, array $params) { switch ($command->getName()) { case "npc": switch (strtolower(array_shift($params))) { case "create": case "c": if (!$sender instanceof Player) { $sender->sendMessage(TextFormat::RED . "Please run this command in-game."); return true; } if (!$sender->hasPermission("npc.command.npc.create")) { $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission")); return true; } $name = implode(" ", $params); if (trim($name) === "") { $sender->sendMessage(TextFormat::RED . "Usage: /npc create <name>"); return true; } $location = new Location($sender->getX(), $sender->getY(), $sender->getZ(), -1, -1, $sender->getLevel()); $npc = new NPC($this, clone $location, $name, $sender->getSkinData(), $sender->getSkinId(), $sender->getInventory()->getItemInHand()); $this->npc[$npc->getId()] = $npc; foreach ($sender->getLevel()->getPlayers() as $player) { $npc->spawnTo($player); } if ($this->getConfig()->get("save-on-change")) { $this->save(); } return true; case "remove": case "r": if (!$sender->hasPermission("npc.command.npc.remove")) { $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission")); return true; } $id = array_shift($params); if (!is_numeric($id)) { $sender->sendMessage(TextFormat::RED . "Usage: /npc remove <id>"); return true; } foreach ($this->npc as $key => $npc) { if ($id == $npc->getId()) { $npc->remove(); unset($this->npc[$key]); $sender->sendMessage("Removed NPC " . TextFormat::AQUA . $npc->getName()); if ($this->getConfig()->get("save-on-change")) { $this->save(); } return true; } } $sender->sendMessage("Could not find NPC " . TextFormat::RED . $id); return true; case "list": case "ls": case "l": if (!$sender->hasPermission("npc.command.npc.list")) { $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission")); return true; } $page = array_shift($params); if (!is_numeric($page)) { $page = 1; } $max = ceil(count($this->npc) / 5); $page = (int) $page; $page = max(1, min($page, $max)); $output = "Showing NPC list (page {$page}/{$max}): \n"; $n = 0; foreach ($this->npc as $id => $npc) { $current = (int) ceil(++$n / 5); if ($current === $page) { $output .= "#" . $npc->getId() . " (" . round($npc->x, 2) . ":" . round($npc->y, 2) . ":" . round($npc->z, 2) . ":" . $npc->getLevel()->getName() . "): " . $npc->getName() . "\n"; } elseif ($current > $page) { break; } } $output = substr($output, 0, -1); $sender->sendMessage($output); return true; case "message": case "msg": case "m": if (!$sender->hasPermission("npc.command.npc.message")) { $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission")); return true; } $message = trim(implode(" ", $params)); $this->msgQueue[$sender->getName()] = $message; $sender->sendMessage("Touch NPC you want to set message."); if ($this->getConfig()->get("save-on-change")) { $this->save(); } return true; case "command": case "cmd": if (!$sender->hasPermission("npc.command.npc.command")) { $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission")); return true; } $this->cmdQueue[$sender->getName()] = trim(implode(" ", $params)); $sender->sendMessage("Touch NPC you want to set command."); return true; } } return false; }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { if ($cmd->getName() != "worldprotect") { return false; } if ($sender instanceof Player) { $world = $sender->getLevel()->getName(); } else { $level = $this->getServer()->getDefaultLevel(); if ($level) { $world = $level->getName(); } else { $world = null; } } if (isset($args[0]) && $this->getServer()->isLevelGenerated($args[0])) { $world = array_shift($args); } if ($world === null) { $sender->sendMessage(mc::_("[WP] Must specify a world")); return false; } echo __METHOD__ . "," . __LINE__ . "\n"; //##DEBUG if (!$this->isAuth($sender, $world)) { return true; } echo __METHOD__ . "," . __LINE__ . "\n"; //##DEBUG return $this->dispatchSCmd($sender, $cmd, $args, $world); }
public function onCommand(CommandSender $issuer, Command $cmd, $label, array $args) { switch ($cmd->getName()) { case "adminfun": if (isset($args[0])) { switch ($args[0]) { case "announce": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.announce")) { if (count($args) > 1) { unset($args[0]); $msg = implode(" ", $args); $this->getPlugin()->getServer()->broadcastMessage(str_replace(array("&", "%msg%"), array("§", $msg), $this->getPlugin()->getConfig()->get("announce-format"))); return true; } else { $issuer->sendMessage("Usage: /af announce <msg>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "bgod": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.bgod")) { if (count($args) > 1) { unset($args[0]); $msg = implode(" ", $args); $this->getPlugin()->getServer()->broadcastMessage(str_replace(array("&", "%msg%"), array("§", $msg), $this->getPlugin()->getConfig()->get("bgod-format"))); return true; } else { $issuer->sendMessage("Usage: /af bgod <msg>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "bherobrine": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.bherobrine")) { if (count($args) > 1) { unset($args[0]); $msg = implode(" ", $args); $this->getPlugin()->getServer()->broadcastMessage(str_replace(array("&", "%msg%"), array("§", $msg), $this->getPlugin()->getConfig()->get("bherobrine-format"))); return true; } else { $issuer->sendMessage("Usage: /af bherobrine <msg>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "broadcast": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.broadcast")) { if (count($args) > 1) { unset($args[0]); $msg = implode(" ", $args); $this->getPlugin()->getServer()->broadcastMessage(str_replace("&", "§", $msg)); return true; } else { $issuer->sendMessage("Usage: /af broadcast <msg..>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "burn": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.burn")) { if (isset($args[1]) && isset($args[2])) { $target = $this->getPlugin()->getServer()->getPlayer($args[1]); if ($target !== null) { if (is_numeric($args[2])) { $target->setOnFire($args[2]); $issuer->sendMessage("§a" . $target->getName() . " has catched on fire!"); $target->sendMessage("§eNeed an extinguisher? §m§blol"); return true; } else { $issuer->sendMessage("§cInvalid time!"); return true; } } else { $issuer->sendMessage("Invalid target!"); return true; } } else { $issuer->sendMessage("Usage: /af burn <player> <seconds>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "confuse": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.confuse")) { if (isset($args[1])) { $target = $this->getPlugin()->getServer()->getPlayer($args[1]); if ($target !== null) { if ($this->getPlugin()->isConfused($target) !== true) { $this->getPlugin()->confuse($target); $issuer->sendMessage("§aYou confused " . $target->getName() . "!"); return true; } else { $this->getPlugin()->unConfuse($target); $issuer->sendMessage("§aYou unconfused " . $target->getName() . "!"); return true; } } else { $issuer->sendMessage("§cInvalid target!"); return true; } } else { $issuer->sendMessage("Usage: /af confuse <player>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "console": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.console")) { if (count($args) > 1) { unset($args[0]); $msg = implode(" ", $args); $this->getPlugin()->getServer()->broadcastMessage("§o§7[CONSOLE: " . $msg . "§7]"); return true; } else { $issuer->sendMessage("Usage: /af console <msg>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "explode": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.explode")) { if ($issuer instanceof Player) { if (isset($args[1])) { if (is_numeric($args[1])) { if (isset($args[2])) { $target = $this->getPlugin()->getServer()->getPlayer($args[2]); if ($target !== null) { $explosion = new Explosion(new Position($target->x, $target->y, $target->z, $target->getLevel()), $args[1]); $explosion->explode(); $issuer->sendMessage("§e§lEXPLODE!!"); return true; } else { $issuer->sendMessage("§cInvalid target!"); return true; } } else { $explosion = new Explosion(new Position($issuer->x, $issuer->y, $issuer->z, $issuer->getLevel()), $args[1]); $explosion->explode(); $issuer->sendMessage("§e§lEXPLODE!!"); return true; } } else { $issuer->sendMessage("§cInvalid radius!"); return true; } } else { $issuer->sendMessage("Usage: /af explode <radius> <player>"); return true; } } else { $issuer->sendMessage("§cCommand only works in-game!"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "fakejoin": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.fakejoin")) { if (isset($args[1])) { $this->getPlugin()->getServer()->broadcastMessage(str_replace(array("&", "%name%"), array("§", $args[1]), $this->getPlugin()->getConfig()->get("fakejoin-format"))); return true; } else { $this->getPlugin()->getServer()->broadcastMessage(str_replace(array("&", "%name%"), array("§", $issuer->getName()), $this->getPlugin()->getConfig()->get("fakejoin-format"))); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "fakeop": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.fakeop")) { if (isset($args[1])) { $target = $this->getPlugin()->getServer()->getPlayer($args[1]); if ($target !== null) { $target->sendMessage("§7You are now op!"); $issuer->sendMessage("§3You fakeopped " . $target->getName() . "!"); return true; } else { $issuer->sendMessage("Invalid target!"); return true; } } else { $issuer->sendMessage("Usage: /af fakeop <player>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "fakequit": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.fakequit")) { if (isset($args[1])) { $this->getPlugin()->getServer()->broadcastMessage(str_replace(array("&", "%name%"), array("§", $args[1]), $this->getPlugin()->getConfig()->get("fakequit-format"))); return true; } else { $this->getPlugin()->getServer()->broadcastMessage(str_replace(array("&", "%name%"), array("§", $issuer->getName()), $this->getPlugin()->getConfig()->get("fakequit-format"))); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "help": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.help")) { if (!isset($args[1])) { $issuer->sendMessage("§2Showing help page §6(1/3)"); $issuer->sendMessage("§l§b- §r§f/adminfun announce <msg..>"); $issuer->sendMessage("§l§b- §r§f/adminfun bgod <msg..>"); $issuer->sendMessage("§l§b- §r§f/adminfun bherobrine <msg..>"); $issuer->sendMessage("§l§b- §r§f/adminfun broadcast <msg..>"); $issuer->sendMessage("§l§b- §r§f/adminfun burn <player> <seconds>"); $issuer->sendMessage("§l§b- §r§f/adminfun confuse <player>"); $issuer->sendMessage("§l§b- §r§f/adminfun console <msg..>"); $issuer->sendMessage("§l§b- §r§f/adminfun explode <player> <radius>"); return true; } else { if (is_numeric($args[1])) { switch ($args[1]) { case 1: $this->getPlugin()->getServer()->dispatchCommand($issuer, "af help"); return true; break; case 2: $issuer->sendMessage("§aShowing help page §6(2/3)"); $issuer->sendMessage("§l§b- §r§f/adminfun fakejoin <name>"); $issuer->sendMessage("§l§b- §r§f/adminfun fakeop <player>"); $issuer->sendMessage("§l§b- §r§f/adminfun fakequit <name>"); $issuer->sendMessage("§l§b- §r§f/adminfun freeze <player>"); $issuer->sendMessage("§l§b- §r§f/adminfun help <1|2|3>"); $issuer->sendMessage("§l§b- §r§f/adminfun maxhealth <hearts>"); $issuer->sendMessage("§l§b- §r§f/adminfun playerchat <player> <msg..>"); $issuer->sendMessage("§l§b- §r§f/adminfun randomtp <troll/safe> <player>"); return true; break; case 3: $issuer->sendMessage("§aShowing help page §6(3/3)"); $issuer->sendMessage("§l§b- §r§f/adminfun reload"); $issuer->sendMessage("§l§b- §r§f/adminfun rocket <player>"); $issuer->sendMessage("§l§b- §r§f/adminfun spamcast <msg..>"); $issuer->sendMessage("§l§b- §r§f/adminfun swap <player1> <player2>"); $issuer->sendMessage("§l§b- §r§f/adminfun void <player>"); return true; break; } } else { $this->getPlugin()->getServer()->dispatchCommand($issuer, "af help"); return true; } } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "freeze": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.freeze")) { if (isset($args[1])) { $target = $this->getPlugin()->getServer()->getPlayer($args[1]); if ($target !== null) { if ($this->getPlugin()->isFrozen($target) !== true) { $this->getPlugin()->freeze($target); $issuer->sendMessage($target->getName() . " §ahas been frozen!"); $target->sendMessage("§eYou have been §bfrozen§e!"); return true; } else { $this->getPlugin()->unfreeze($target); $issuer->sendMessage($target->getName() . " §ahas been unfrozen!"); $target->sendMessage("§eYou have been §cunfrozen§e!"); return true; } } else { $issuer->sendMessage("§cInvalid target!"); return true; } } else { $issuer->sendMessage("Usage: /af freeze <player>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "maxhealth": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.morehealth")) { if ($issuer instanceof Player) { if (isset($args[1])) { if (is_numeric($args[1])) { $issuer->setMaxHealth($args[1] * 2); $issuer->setHealth($issuer->getMaxHealth()); $issuer->sendMessage("§aSet " . $args[1] . " hearts as your max health!\n§a+ Healed you!"); return true; } else { $issuer->sendMessage("§cInvalid numbers of hearts!"); return true; } } else { $issuer->sendMessage("Usage: /af maxhealth <hearts>"); return true; } } else { $issuer->sendMessage("§cCommand only works in-game!"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "playerchat": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.playerchat")) { if (isset($args[1]) && count($args) > 2) { $target = str_replace("&", "§", $args[1]); unset($args[1]); unset($args[0]); $msg = implode(" ", $args); $this->getPlugin()->getServer()->broadcastMessage(str_replace(array("&", "%name%", "%msg%"), array("§", $target, $msg), $this->getPlugin()->getConfig()->get("playerchat-format"))); return true; } else { $issuer->sendMessage("Usage: /af playerchat <player> <msg..>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "randomtp": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.randomtp")) { if ($issuer instanceof Player) { if (isset($args[1])) { switch ($args[1]) { case "troll": if (isset($args[2])) { $target = $this->getPlugin()->getServer()->getPlayer($args[2]); if ($target !== null) { $target->setGamemode(0); $target->teleport(new Position(rand(0, 255), rand(0, 255), rand(0, 255), $target->getLevel())); $issuer->sendMessage("§aYou teleported " . $target->getName() . " to a random location!"); $target->sendMessage("§l§eLOL"); return true; } else { $issuer->sendMessage("§cInvalid target!"); return true; } } else { $issuer->sendMessage("§cIf you choose 'troll', you must enter the target's name! You won't troll yourself right..?"); return true; } break; case "safe": if (isset($args[2])) { $target = $this->getPlugin()->getServer()->getPlayer($args[2]); if ($target !== null) { $x = rand(0, 255); $z = rand(0, 255); $y = rand(0, 200); $target->teleport($target->getLevel()->getSafeSpawn(new Vector3($x, $y, $z))); $issuer->sendMessage("§aTeleported " . $target->getName() . " to a safe random location"); return true; } else { $issuer->sendMessage("§cInvalid target!"); return true; } } else { $x = rand(0, 255); $z = rand(0, 255); $y = rand(0, 200); $issuer->teleport($issuer->getLevel()->getSafeSpawn(new Vector3($x, $y, $z))); $issuer->sendMessage("§aTeleported to a safe random location"); return true; } break; default: $issuer->sendMessage("§cInvalid args[1]"); return true; } } else { $issuer->sendMessage("Usage: /af randomtp troll|safe <player>"); return true; } } else { $issuer->sendMessage("Command only works in-game!"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "reload": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.reload")) { $this->getPlugin()->saveDefaultConfig(); $this->getPlugin()->reloadConfig(); $issuer->sendMessage("§bAdminFun §ahas been reloaded!"); return true; } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "rocket": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.rocket")) { if (isset($args[1])) { $target = $this->getPlugin()->getServer()->getPlayer($args[1]); if ($target !== null) { $target->getLevel()->addSound(new LaunchSound($target)); $motion = new Vector3($target->motionX, $target->motionY, $target->motionZ); $motion->y = 20; $target->setMotion($motion); $target->sendMessage("§b§lYou turned into a rocket!"); $issuer->sendMessage("§aYou turned " . $target->getName() . " into a rocket!"); return true; } else { $issuer->sendMessage("§cInvalid target!"); return true; } } else { $issuer->sendMessage("Usage: /af rocket <player>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "spamcast": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.spamcast")) { if (count($args) > 1) { foreach ($this->getPlugin()->getServer()->getOnlinePlayers() as $p) { unset($args[0]); $msg = implode(" ", $args); for ($i = 0; $i < 20; $i++) { $p->sendMessage("§l[SpamCast] §3" . $msg); } $issuer->sendMessage("§aMessage has been spammed!"); return true; } } else { $issuer->sendMessage("Usage: /af spamcast <msg..>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "swap": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.swap")) { if (isset($args[1]) && isset($args[2])) { $player1 = $this->getPlugin()->getServer()->getPlayer($args[1]); $player2 = $this->getPlugin()->getServer()->getPlayer($args[2]); if ($player1 !== null && $player2 !== null) { if ($player1->getName() != $player2->getName()) { $x1 = $player1->x; $y1 = $player1->y; $z1 = $player1->z; $w1 = $player1->getLevel(); $x2 = $player2->x; $y2 = $player2->y; $z2 = $player2->z; $w2 = $player2->getLevel(); $player2->teleport(new Position($x1, $y1, $z1, $w1)); $player1->teleport(new Position($x2, $y2, $z2, $w2)); $issuer->sendMessage(TextFormat::GREEN . "You swap " . $player1->getName() . "'s and " . $player2->getName() . "'s position!"); return true; } else { $issuer->sendMessage("§cYou cannot swap between the same person!"); return true; } } else { $issuer->sendMessage("§cInvalid target!"); return true; } } else { $issuer->sendMessage("Usage: /af swap <player1> <player2>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; case "void": if ($issuer->hasPermission("adminfun.command") || $issuer->hasPermission("adminfun.command.void")) { if (isset($args[1])) { $target = $this->getPlugin()->getServer()->getPlayer($args[1]); if ($target !== null) { $target->teleport(new Position($target->x, 0, $target->z, $target->getLevel())); $target->sendMessage("§l§aWelcome to the void!"); $issuer->sendMessage("§aYou teleported " . $target->getName() . " to the void!"); return true; } else { $issuer->sendMessage("§cInvalid target!"); return true; } } else { $issuer->sendMessage("Usage: /af void <player>"); return true; } } else { $issuer->sendMessage("§cYou don't have permission for this!"); return true; } break; } } else { return false; } break; } }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $param) { switch ($cmd->getName()) { case "startp": if (!$sender instanceof Player) { $sender->sendMessage($this->getMessage("run-cmd-in-game")); return true; } $x = floor($sender->x); $z = floor($sender->z); $level = $sender->getLevel()->getFolderName(); $this->start[$sender->getName()] = array("x" => $x, "z" => $z, "level" => $level); $sender->sendMessage($this->getMessage("first-position-saved")); return true; case "endp": if (!$sender instanceof Player) { $sender->sendMessage($this->getMessage("run-cmd-in-game")); return true; } if (!isset($this->start[$sender->getName()])) { $sender->sendMessage($this->getMessage("set-first-position")); return true; } if ($sender->getLevel()->getFolderName() !== $this->start[$sender->getName()]["level"]) { $sender->sendMessage($this->getMessage("cant-set-position-in-different-world")); return true; } $startX = $this->start[$sender->getName()]["x"]; $startZ = $this->start[$sender->getName()]["z"]; $endX = floor($sender->x); $endZ = floor($sender->z); $this->end[$sender->getName()] = array("x" => $endX, "z" => $endZ); if ($startX > $endX) { $temp = $endX; $endX = $startX; $startX = $temp; } if ($startZ > $endZ) { $temp = $endZ; $endZ = $startZ; $startZ = $temp; } $startX--; $endX++; $startZ--; $endZ++; $price = ($endX - $startX - 1) * ($endZ - $startZ - 1) * $this->config->get("price-per-y-axis"); $sender->sendMessage($this->getMessage("confirm-buy-land", array($price, "%2", "%3"))); return true; case "land": $sub = array_shift($param); switch ($sub) { case "buy": if (!$sender->hasPermission("economyland.command.land.buy")) { $sender->sendMessage($this->getMessage("no-permission-command")); return true; } if (!$sender instanceof Player) { $sender->sendMessage($this->getMessage("run-cmd-in-game")); return true; } if (in_array($sender->getLevel()->getFolderName(), $this->config->get("buying-disallowed-worlds"))) { $sender->sendMessage($this->getMessage("not-allowed-to-buy")); return true; } $cnt = count($this->db->getLandsByOwner($sender->getName())); if (is_numeric($this->config->get("player-land-limit"))) { if ($cnt >= $this->config->get("player-land-limit")) { $sender->sendMessage($this->getMessage("land-limit", array($cnt, $this->config->get("player-land-limit"), "%3", "%4"))); return true; } } if (!isset($this->start[$sender->getName()])) { $sender->sendMessage($this->getMessage("set-first-position")); return true; } elseif (!isset($this->end[$sender->getName()])) { $sender->sendMessage($this->getMessage("set-second-position")); return true; } $l = $this->start[$sender->getName()]; $endp = $this->end[$sender->getName()]; $startX = floor($l["x"]); $endX = floor($endp["x"]); $startZ = floor($l["z"]); $endZ = floor($endp["z"]); if ($startX > $endX) { $backup = $startX; $startX = $endX; $endX = $backup; } if ($startZ > $endZ) { $backup = $startZ; $startZ = $endZ; $endZ = $backup; } $result = $this->db->checkOverlap($startX, $endX, $startZ, $endZ, $sender->getLevel()->getFolderName()); if ($result) { $sender->sendMessage($this->getMessage("land-around-here", array($result["owner"], $result["ID"], "%3"))); return true; } $price = ($endX + 1 - ($startX - 1) - 1) * ($endZ + 1 - ($startZ - 1) - 1) * $this->config->get("price-per-y-axis"); if (EconomyAPI::getInstance()->reduceMoney($sender, $price, true, "EconomyLand") === EconomyAPI::RET_INVALID) { $sender->sendMessage($this->getMessage("no-money-to-buy-land")); return true; } $this->db->addLand($startX, $endX, $startZ, $endZ, $sender->getLevel()->getFolderName(), $price, $sender->getName()); unset($this->start[$sender->getName()], $this->end[$sender->getName()]); $sender->sendMessage($this->getMessage("bought-land", array($price, "%2", "%3"))); break; case "list": if (!$sender->hasPermission("economyland.command.land.list")) { $sender->sendMessage($this->getMessage("no-permission-command")); return true; } $page = isset($param[0]) ? (int) $param[0] : 1; $land = $this->db->getAll(); $output = ""; $max = ceil(count($land) / 5); $pro = 1; $page = (int) $page; $output .= $this->getMessage("land-list-top", array($page, $max, "")); $current = 1; foreach ($land as $l) { $cur = (int) ceil($current / 5); if ($cur > $page) { continue; } if ($pro == 6) { break; } if ($page === $cur) { $output .= $this->getMessage("land-list-format", array($l["ID"], ($l["endX"] + 1 - ($l["startX"] - 1) - 1) * ($l["endZ"] + 1 - ($l["startZ"] - 1) - 1), $l["owner"])); $pro++; } $current++; } $sender->sendMessage($output); break; case "whose": if (!$sender->hasPermission("economyland.command.land.whose")) { $sender->sendMessage($this->getMessage("no-permission-command")); return true; } $player = array_shift($param); $alike = true; if (str_replace(" ", "", $player) === "") { $player = $sender->getName(); $alike = false; } if ($alike) { $lands = $this->db->getLandsByKeyword($player); } else { $lands = $this->db->getLandsByOwner($player); } $sender->sendMessage("Results from query : {$player}\n"); foreach ($lands as $info) { $sender->sendMessage($this->getMessage("land-list-format", array($info["ID"], ($info["endX"] + 1 - ($info["startX"] - 1) - 1) * ($info["endZ"] + 1 - ($info["startZ"] - 1) - 1), $info["owner"]))); } break; case "move": if (!$sender instanceof Player) { $sender->sendMessage($this->getMessage("run-cmd-in-game")); return true; } if (!$sender->hasPermission("economyland.command.land.move")) { $sender->sendMessage($this->getMessage("no-permission-command")); return true; } $num = array_shift($param); if (trim($num) == "") { $sender->sendMessage("Usage: /land move <land num>"); return true; } if (!is_numeric($num)) { $sender->sendMessage("Usage: /land move <land num>"); return true; } $info = $this->db->getLandById($num); if ($info === false) { $sender->sendMessage($this->getMessage("no-land-found", array($num, "", ""))); return true; } if ($info["owner"] !== $sender->getName()) { if (!$sender->hasPermission("economyland.land.move.others")) { $sender->sendMessage($this->getMessage("no-permission-move", [$info["ID"], $info["owner"], "%3"])); return true; } } $level = $this->getServer()->getLevelByName($info["level"]); if (!$level instanceof Level) { $sender->sendMessage($this->getMessage("land-corrupted", array($num, $info["level"], ""))); return true; } $x = (int) ($info["startX"] + ($info["endX"] - $info["startX"]) / 2); $z = (int) ($info["startZ"] + ($info["endZ"] - $info["startZ"]) / 2); $cnt = 0; for ($y = 128;; $y--) { $vec = new Vector3($x, $y, $z); if ($level->getBlock($vec)->isSolid()) { $y++; break; } if ($cnt === 5) { break; } if ($y <= 0) { ++$cnt; ++$x; --$z; $y = 128; continue; } } $sender->teleport(new Position($x + 0.5, $y + 0.1, $z + 0.5, $level)); $sender->sendMessage($this->getMessage("success-moving", array($num, "", ""))); return true; case "give": if (!$sender instanceof Player) { $sender->sendMessage($this->getMessage("run-cmd-in-game")); return true; } if (!$sender->hasPermission("economyland.command.land.give")) { $sender->sendMessage($this->getMessage("no-permission-command")); return true; } $player = array_shift($param); $landnum = array_shift($param); if (trim($player) == "" or trim($landnum) == "" or !is_numeric($landnum)) { $sender->sendMessage("Usage: /{$cmd} give <player> <land number>"); return true; } $username = $player; $player = $this->getServer()->getPlayer($username); if (!$player instanceof Player) { $sender->sendMessage($this->getMessage("player-not-connected", [$username, "%2", "%3"])); return true; } $info = $this->db->getLandById($landnum); if ($info === false) { $sender->sendMessage($this->getMessage("no-land-found", array($landnum, "%2", "%3"))); return true; } if ($sender->getName() !== $info["owner"] and !$sender->hasPermission("economyland.land.give.others")) { $sender->sendMessage($this->getMessage("not-your-land", array($landnum, "%2", "%3"))); } else { if ($sender->getName() === $player->getName()) { $sender->sendMessage($this->getMessage("cannot-give-land-myself")); } else { if (is_numeric($this->config->get("player-land-limit"))) { $cnt = count($this->db->getLandsByOwner($player->getName())); if ($cnt >= $this->config->get("player-land-limit")) { $sender->sendMessage($this->getMessage("give-land-limit", array($player->getName(), $cnt, $this->config->get("player-land-limit"), "%4"))); return true; } } $this->db->setOwnerById($info["ID"], $player->getName()); $sender->sendMessage($this->getMessage("gave-land", array($landnum, $player->getName(), "%3"))); $player->sendMessage($this->getMessage("got-land", array($sender->getName(), $landnum, "%3"))); } } return true; case "invite": if (!$sender->hasPermission("economyland.command.land.invite")) { $sender->sendMessage($this->getMessage("no-permission-command")); return true; } $landnum = array_shift($param); $player = array_shift($param); if (trim($player) == "" or trim($landnum) == "") { $sender->sendMessage("Usage : /land <invite> <land number> <[r:]player>"); return true; } if (!is_numeric($landnum)) { $sender->sendMessage($this->getMessage("land-num-must-numeric", array($landnum, "%2", "%3"))); return true; } $info = $this->db->getLandById($landnum); if ($info === false) { $sender->sendMessage($this->getMessage("no-land-found", array($landnum, "%2", "%3"))); return true; } elseif ($info["owner"] !== $sender->getName()) { $sender->sendMessage($this->getMessage("not-your-land", array($landnum, "%2", "%3"))); return true; } else { if (preg_match('#^[a-zA-Z0-9_]{3,16}$#', $player) == 0) { $sender->sendMessage($this->getMessage("invalid-invitee", [$player, "%2", "%3"])); return true; } $result = $this->db->addInviteeById($landnum, $player); if ($result === false) { $sender->sendMessage($this->getMessage("already-invitee", array($player, "%2", "%3"))); return true; } $sender->sendMessage($this->getMessage("success-invite", array($player, $landnum, "%3"))); } return true; case "kick": if (!$sender->hasPermission("economyland.command.land.invite.remove")) { $sender->sendMessage($this->getMessage("no-permission-command")); return true; } $landnum = array_shift($param); $player = array_shift($param); if (trim($player) === "") { $sender->sendMessage(TextFormat::RED . "Usage: " . $command->getUsage()); return true; } if (!is_numeric($landnum)) { $sender->sendMessage($this->getMessage("land-num-must-numeric", array($landnum, "%2", "%3"))); return true; } $info = $this->db->getLandById($landnum); if ($info === false) { $sender->sendMessage($this->getMessage("no-land-found", array($landnum, "%2", "%3"))); return true; } if ($sender->hasPermission("economyland.command.land.invite.remove.others") and $info["owner"] !== $sender->getName() or $info["owner"] === $sender->getName()) { $result = $this->db->removeInviteeById($landnum, $player); if ($result === false) { $sender->sendMessage($this->getMessage("not-invitee", array($player, $landnum, "%3"))); return true; } $sender->sendMessage($this->getMessage("removed-invitee", array($player, $landnum, "%3"))); } return true; case "invitee": $landnum = array_shift($param); if (trim($landnum) == "" or !is_numeric($landnum)) { $sender->sendMessage("Usage: /land invitee <land number>"); return true; } $info = $this->db->getInviteeById($landnum); if ($info === false) { $sender->sendMessage($this->getMessage("no-land-found", array($landnum, "%2", "%3"))); return true; } $output = "Invitee of land #{$landnum} : \n"; $output .= implode(", ", $info); $sender->sendMessage($output); return true; case "here": if (!$sender instanceof Player) { $sender->sendMessage($this->getMessage("run-cmd-in-game")); return true; } $x = $sender->x; $z = $sender->z; $info = $this->db->getByCoord($x, $z, $sender->getLevel()->getFolderName()); if ($info === false) { $sender->sendMessage($this->getMessage("no-one-owned")); return true; } $sender->sendMessage($this->getMessage("here-land", array($info["ID"], $info["owner"], "%3"))); return true; default: $sender->sendMessage("Usage: " . $cmd->getUsage()); } return true; case "landsell": $id = array_shift($param); switch ($id) { case "here": if (!$sender instanceof Player) { $sender->sendMessage($this->getMessage("run-cmd-in-game")); return true; } $x = $sender->getX(); $z = $sender->getZ(); $info = $this->db->getByCoord($x, $z, $sender->getLevel()->getFolderName()); if ($info === false) { $sender->sendMessage($this->getMessage("no-one-owned")); return true; } if ($info["owner"] !== $sender->getName() and !$sender->hasPermission("economyland.landsell.others")) { $sender->sendMessage($this->getMessage("not-my-land")); } else { EconomyAPI::getInstance()->addMoney($sender, $info["price"] / 2); $sender->sendMessage($this->getMessage("sold-land", array($info["price"] / 2, "%2", "%3"))); //$this->land->exec("DELETE FROM land WHERE ID = {$info["ID"]}"); $this->db->removeLandById($info["ID"]); } return true; default: $p = $id; if (is_numeric($p)) { $info = $this->db->getLandById($p); if ($info === false) { $sender->sendMessage($this->getMessage("no-land-found", array($p, "%2", "%3"))); return true; } if ($info["owner"] === $sender->getName() or $sender->hasPermission("economyland.landsell.others")) { EconomyAPI::getInstance()->addMoney($sender, $info["price"] / 2, true, "EconomyLand"); $sender->sendMessage($this->getMessage("sold-land", array($info["price"] / 2, "", ""))); $this->db->removeLandById($p); } else { $sender->sendMessage($this->getMessage("not-your-land", array($p, $info["owner"], "%3"))); } } else { $sender->sendMessage("Usage: /landsell <here|land number>"); } } return true; } return false; }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { switch ($cmd->getName()) { case "skywarshowto": if ($sender->hasPermission("skywars.command.howto") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) { $sender->sendMessage("----How To Play skywars----"); $sender->sendMessage("/sk play = start a game"); $sender->sendMessage("/sk exit = exit from a game"); $sender->sendMessage("/sk stat [player] = get a player stats"); $sender->sendMessage("/sk skiptime = skip the waiting time"); return true; } else { $sender->sendMessage("You haven't the permission to run this command"); } case "skywars": case "sw": //same as setting aliases in plugin.yml, both cmds (skywars & sw) are usable //same as setting aliases in plugin.yml, both cmds (skywars & sw) are usable case "sk": switch ($args[0]) { case "play": if ($sender->hasPermission("skywars.command.play") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) { if ($this->aplayers >= $this->getConfig()->get('neededplayers') and $this->skywarsstarted == false) { //if players in the world are more or equal as the max players $sender->sendMessage("The game is full"); // game full return true; } elseif ($this->aplayers < $this->getConfig()->get('neededplayers') and $this->skywarsstarted == false) { //if player number is less than the max. $spawn = $this->getConfig()->get('spawns')[$this->aplayers]; //no need to do + 1 on this, because arrays start counting form 0 // get the correct spawn place $sender->teleport(new Position($spawn[0], $spawn[1], $spawn[2], $this->getServer()->getLevelByName($this->getConfig()->get('aworld')))); //teleport to it $this->aplayers = $this->aplayers + 1; //then add a player to the array $sender->sendMessage("You have been teleported to the game world."); if ($this->aplayers == $this->getConfig()->get('neededplayers')) { //if the players became the same as neededplayers $this->startGame($this->getConfig() > get('aworld')); //start the game } return true; } elseif ($this->skywarsstarted == true) { //if the game is already started $sender->sendMessage("The game is already started"); return true; } } else { $sender->sendMessage("You haven't the permission to run this command."); return true; } break; case "exit": if ($sender->hasPermission("skywars.command.exit") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) { if ($sender->getLevel()->getName() == $this->getConfig()->get('aworld')) { //if the level of the sender is a skywars one $this->aplayers = $this->aplayers - 1; //remove 1 to the array $sender->teleport($this->getServer()->getLevelByName($this->getConfig() > get('lobby'))->getSafeSpawn()); //teleport to the lobby $sender->sendMessage("You left the game."); if ($this->aplayers <= 1) { //if only 1 player is left foreach ($this->getServer()->getLevelByName($this->getConfig()->get('aworld'))->getPlayers() as $p) { //detects the winner if ($p->getGameMode() == 0) { $p->sendMessage("You won the match!"); $p->sendMessage("The game has finished, you will be teleported to the lobby."); $p->teleport($this->getServer()->getLevelByName($this->config->get('lobby'))->getSafeSpawn()); //teleport to the lobby $points = $this->points->get($p)[2] + $this->getConfig()->get('points-per-match'); //get points and add $deaths = $this->points->get($player)[0]; //get the victim's deaths, add one and store in a variable $kills = $this->points->get($player)[1]; //get the players kills and store in a var $this->getConfig()->set($p, array($deaths, $kills, $points)); } else { $p->sendMessage("The match has finished, thanks for watching."); $p->teleport($this->getServer()->getLevelByName($this->getConfig()->get('lobby'))->getSafeSpawn()); $p->setGameMode(0); } $this->stopGame($this->getConfig()->get('aworld')); //stop the game } } return true; } else { $sender->sendMessage("You are not in the SkyWars world."); return true; } } else { $sender->sendMessage("You haven't the permission to run this command."); return true; } break; case "stat": if ($sender->hasPermission("skywars.command.stat") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) { if (!isset($args[1])) { $player = $sender->getName(); $deaths = $this->points->get($player)[0]; $kills = $this->points->get($player)[1]; $points = $this->points->get($player)[2]; $sender->sendMessage("You have " . $deaths . " deaths, " . $kills . " kills and " . $points . " points."); return true; } else { $player = $args[1]; $deaths = $this->points->get($player)[0]; $kills = $this->points->get($player)[1]; $points = $this->points->get($player)[2]; $sender->sendMessage($player . " has " . $deaths . " deaths, " . $kills . " kills and " . $points . " points."); return true; } } else { $sender->sendMessage("You haven't the permission to run this command."); return true; } break; case "spawnpos": if ($sender->hasPermission("skywars.command.pos") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) { $x = $sender->getX(); $y = $sender->getY(); //get coordinates and store in variables $z = $sender->getZ(); $this->getConfig()->set('spawns', array($x, $y, $z)); $sender->sendMessage("Spawn position set to: " . $x . ", " . $y . ", " . $z . ", level: " . $sender->getLevel()->getName()); return true; } else { $sender->sendMessage("You haven't the permission to run this command."); return true; } break; case "skiptime": if ($sender->hasPermission("skywars.command.skiptime") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) { if ($this->aplayers >= $this->getConfig()->get("minplayers")) { $this->startGame($sender->getLevel()->getName()); //start game on the sender level $sender->sendMessage("You started the game skipping the waiting time!"); return true; } else { $sender->sendMessage("There are less than 3 players, you can't start the game yet."); return true; } } else { $sender->sendMessage("You haven't the permission to run this command."); return true; } break; case "left": if ($sender->hasPermission("skywars.command.left") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) { if ($sender->getLevel()->getName() == $this->getConfig()->get('aworld')) { $playersleft = $this->getConfig()->get('neededplayers') - $this->aplayers; $sender->sendMessage("Players left untill the game begin: " . $playersleft); return true; } else { $sender->sendMessage("You are not in a SkyWars world."); return true; } } else { $sender->sendMessage("You haven't the permission to run this command."); return true; } break; case "see": if ($sender->hasPermission("skywars.command.see") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) { $sender->sendMessage("You will join a match as a spectator"); $sender->setGamemode(3); //Actually, this will crash mcpe I think. $spawn = $this->getConfig()->get('spectatorspawn'); $sender->teleport(new Position($spawn[0], $spawn[1], $spawn[2], $this->getServer()->getLevelByName($this->getConfig()->get('aworld')))); } else { $sender->sendMessage("You haven't the permission to run this command."); return true; } break; default: return false; } } }
public function onCommand(CommandSender $player, Command $cmd, $label, array $args) { switch ($cmd->getName()) { case "wizard": $p = $player->getName(); $config = new Config($this->getDataFolder() . "/classes.yml", Config::YAML); $class = "Wizard"; $config->set($p, $class); $config->save(); $player->sendMessage("You have choosen the Wizard Class"); return true; case "warrior": $p = $player->getName(); $config = new Config($this->getDataFolder() . "/classes.yml", Config::YAML); $class = "Warrior"; $config->set($p, $class); $config->save(); $player->sendMessage("You have choosen the Warrior Class"); return true; case "archer": $p = $player->getName(); $config = new Config($this->getDataFolder() . "/classes.yml", Config::YAML); $class = "Archer"; $config->set($p, $class); $config->save(); $player->sendMessage("You have choosen the Archer Class"); return true; case "xyz": $world = $player->getLevel()->getFolderName(); $x = round($player->getX()); $y = round($player->getY()); $z = round($player->getZ()); $player->sendMessage("{$world}§7, X:§9{$x}§7, Y:§9{$y}§7, Z:§9{$z}"); return true; } }
public function onCommand(CommandSender $p, Command $cmd, $label, array $args) { if (!$p instanceof Player) { $p->sendMessage(TextFormat::RED . "Command must be used in-game."); return true; } if (!isset($args[0])) { return false; } $n = strtolower($p->getName()); $action = strtolower($args[0]); switch ($action) { case "pos1": if ($p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.pos1")) { if (isset($this->sel1[$n]) || isset($this->sel2[$n])) { $o = "You're already selecting a position!"; } else { $this->sel1[$n] = true; $o = "Please place or break the first position."; } } else { $o = "You do not have permission to use this subcommand."; } break; case "pos2": if ($p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.pos2")) { if (isset($this->sel1[$n]) || isset($this->sel2[$n])) { $o = "You're already selecting a position!"; } else { $this->sel2[$n] = true; $o = "Please place or break the second position."; } } else { $o = "You do not have permission to use this subcommand."; } break; case "create": if ($p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.create")) { if (isset($args[1])) { if (isset($this->pos1[$n]) && isset($this->pos2[$n])) { if (!isset($this->areas[strtolower($args[1])])) { $area = new Area(strtolower($args[1]), array("edit" => true, "god" => false, "touch" => true), array($this->pos1[$n]->getX(), $this->pos1[$n]->getY(), $this->pos1[$n]->getZ()), array($this->pos2[$n]->getX(), $this->pos2[$n]->getY(), $this->pos2[$n]->getZ()), $p->getLevel()->getName(), array($n), $this); $this->saveAreas(); unset($this->pos1[$n]); unset($this->pos2[$n]); $o = "Area created!"; } else { $o = "An area with that name already exists."; } } else { $o = "Please select both positions first."; } } else { $o = "Please specify a name for this area."; } } else { $o = "You do not have permission to use this subcommand."; } break; case "list": if ($p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.list")) { $o = "Areas:"; foreach ($this->areas as $area) { $o = $o . " " . $area->getName() . ";"; } } break; case "flag": if ($p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.flag")) { if (isset($args[1])) { if (isset($this->areas[strtolower($args[1])])) { $area = $this->areas[strtolower($args[1])]; if (isset($args[2])) { if (isset($area->flags[strtolower($args[2])])) { $flag = strtolower($args[2]); if (isset($args[3])) { $mode = strtolower($args[3]); if ($mode == "true" || $mode == "on") { $mode = true; } else { $mode = false; } $area->setFlag($flag, $mode); } else { $area->toggleFlag($flag); } if ($area->getFlag($flag)) { $status = "on"; } else { $status = "off"; } $o = "Flag " . $flag . " set to " . $status . " for area " . $area->getName() . "!"; } else { $o = "Flag not found. (Flags: edit, god, touch)"; } } else { $o = "Please specify a flag. (Flags: edit, god, touch)"; } } else { $o = "Area doesn't exist."; } } else { $o = "Please specify the area you would like to flag."; } } else { $o = "You do not have permission to use this subcommand."; } break; case "delete": if ($p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.delete")) { if (isset($args[1])) { if (isset($this->areas[strtolower($args[1])])) { $area = $this->areas[strtolower($args[1])]; $area->delete(); $o = "Area deleted!"; } else { $o = "Area does not exist."; } } else { $o = "Please specify an area to delete."; } } else { $o = "You do not have permission to use this subcommand."; } break; case "whitelist": if ($p->hasPermission("iprotector") || $p->hasPermission("iprotector.command") || $p->hasPermission("iprotector.command.area") || $p->hasPermission("iprotector.command.area.delete")) { if (isset($args[1]) && isset($this->areas[strtolower($args[1])])) { $area = $this->areas[strtolower($args[1])]; if (isset($args[2])) { $action = strtolower($args[2]); switch ($action) { case "add": $w = $this->getServer()->getPlayer($args[3]) instanceof Player ? strtolower($this->getServer()->getPlayer($args[3])->getName()) : strtolower($args[3]); if (!$area->isWhitelisted($w)) { $area->setWhitelisted($w); $o = "Player {$w} has been whitelisted in area " . $area->getName() . "."; } else { $o = "Player {$w} is already whitelisted in area " . $area->getName() . "."; } break; case "list": $o = "Area " . $area->getName() . "'s whitelist:"; foreach ($area->getWhitelist() as $w) { $o .= " {$w};"; } break; case "delete": case "remove": $w = $this->getServer()->getPlayer($args[3]) instanceof Player ? strtolower($this->getServer()->getPlayer($args[3])->getName()) : strtolower($args[3]); if ($area->isWhitelisted($w)) { $area->setWhitelisted($w, false); $o = "Player {$w} has been unwhitelisted in area " . $area->getName() . "."; } else { $o = "Player {$w} is already unwhitelisted in area " . $area->getName() . "."; } break; default: $o = "Please specify a valid action. Usage: /area whitelist " . $area->getName() . " <add/list/remove> [player]"; break; } } else { $o = "Please specify an action. Usage: /area whitelist " . $area->getName() . " <add/list/remove> [player]"; } } else { $o = "Area doesn't exist. Usage: /area whitelist <area> <add/list/remove> [player]"; } } else { $o = "You do not have permission to use this subcommand."; } break; default: return false; break; } $p->sendMessage($o); return true; }
public function onCommand(CommandSender $sender, Command $command, $label, array $args) { switch (strtolower($command->getName())) { case 'nothing': return true; break; case 'rca': if (count($args) < 2) { $sender->sendMessage("Please enter a player and a command."); } $player = $this->getServer()->getPlayer(array_shift($args)); if (!($player === null)) { $this->getServer()->dispatchCommand($player, trim(implode(" ", $args))); } else { $sender->sendMessage(TextFormat::RED . "Player not found."); } return true; break; case "slapper": if ($sender instanceof Player) { if (!isset($args[0])) { if ($sender->hasPermission("slapper.command") || $sender->hasPermission("slapper")) { $sender->sendMessage($this->prefix . "Please type '/slapper help'."); return true; } else { $sender->sendMessage($this->noperm); return true; } } $arg = array_shift($args); switch ($arg) { case "id": if ($sender->hasPermission("slapper.id") || $sender->hasPermission("slapper")) { $this->idSessions[$sender->getName()] = true; $sender->sendMessage($this->prefix . "Hit an entity to get its ID!"); return true; } else { $sender->sendMessage($this->noperm); } return true; break; case "fixall": case "updateall": case "migrateall": $server = $this->getServer(); $count = 0; foreach ($server->getLevels() as $level) { foreach ($level->getEntities() as $entity) { if ($entity instanceof SlapperEntity && $entity instanceof Entity) { $count++; if (!isset($entity->namedtag->Commands)) { $entity->namedtag->Commands = new Compound("Commands", []); } $oldCmds = $this->getConfig()->get($entity->getName()); if ($oldCmds) { foreach ($oldCmds as $oldCmd) { $entity->namedtag->Commands[$oldCmd] = new String($oldCmd, $oldCmd); } } } if ($entity instanceof SlapperHuman) { if ($entity->getSkinName() === "") { $entity->setSkin($entity->getSkinData(), "Standard_Custom"); $entity->despawnFromAll(); $entity->spawnToAll(); } } } } $sender->sendMessage($this->prefix . "Updated " . $count . " Slapper entities."); return true; break; case "version": if ($sender->hasPermission("slapper.version") || $sender->hasPermission("slapper")) { $desc = $this->getDescription(); $sender->sendMessage($this->prefix . TextFormat::BLUE . $desc->getName() . " " . $desc->getVersion() . " " . TextFormat::GREEN . "by " . TextFormat::GOLD . "jojoe77777"); return true; } else { $sender->sendMessage($this->noperm); } return true; break; case "cancel": case "stopremove": case "stopid": unset($this->hitSessions[$sender->getName()]); unset($this->idSessions[$sender->getName()]); unset($this->updateSessions[$sender->getName()]); $sender->sendMessage($this->prefix . "Cancelled."); return true; break; case "remove": if ($sender->hasPermission("slapper.remove") || $sender->hasPermission("slapper")) { if (isset($args[0])) { $entity = $sender->getLevel()->getEntity($args[0]); if (!($entity == null)) { if ($entity instanceof SlapperEntity) { if ($entity instanceof SlapperHuman) { $entity->getInventory()->clearAll(); } $entity->kill(); $sender->sendMessage($this->prefix . "Entity removed."); } else { $sender->sendMessage($this->prefix . "That entity is not handled by Slapper."); } } else { $sender->sendMessage($this->prefix . "Entity does not exist."); } return true; } $this->hitSessions[$sender->getName()] = true; $sender->sendMessage($this->prefix . "Hit an entity to remove it."); } else { $sender->sendMessage($this->noperm); return true; } return true; break; case "edit": if ($sender->hasPermission("slapper.edit") || $sender->hasPermission("slapper")) { if (isset($args[0])) { $level = $sender->getLevel(); $entity = $level->getEntity($args[0]); if (!($entity == null)) { if ($entity instanceof SlapperEntity && $entity instanceof Entity) { if (isset($args[1])) { switch ($args[1]) { case "helm": case "helmet": case "head": case "hat": case "cap": if ($entity instanceof SlapperHuman) { if (isset($args[2])) { $entity->getInventory()->setHelmet(Item::fromString($args[2])); $sender->sendMessage($this->prefix . "Helmet updated."); } else { $sender->sendMessage($this->prefix . "Please enter an item ID."); } } else { $sender->sendMessage($this->prefix . "That entity can not wear armor."); } return true; case "chest": case "shirt": case "chestplate": if ($entity instanceof SlapperHuman) { if (isset($args[2])) { $entity->getInventory()->setChestplate(Item::fromString($args[2])); $sender->sendMessage($this->prefix . "Chestplate updated."); } else { $sender->sendMessage($this->prefix . "Please enter an item ID."); } } else { $sender->sendMessage($this->prefix . "That entity can not wear armor."); } return true; case "pants": case "legs": case "leggings": if ($entity instanceof SlapperHuman) { if (isset($args[2])) { $entity->getInventory()->setLeggings(Item::fromString($args[2])); $sender->sendMessage($this->prefix . "Leggings updated."); } else { $sender->sendMessage($this->prefix . "Please enter an item ID."); } } else { $sender->sendMessage($this->prefix . "That entity can not wear armor."); } return true; case "feet": case "boots": case "shoes": if ($entity instanceof SlapperHuman) { if (isset($args[2])) { $entity->getInventory()->setBoots(Item::fromString($args[2])); $sender->sendMessage($this->prefix . "Boots updated."); } else { $sender->sendMessage($this->prefix . "Please enter an item ID."); } } else { $sender->sendMessage($this->prefix . "That entity can not wear armor."); } return true; case "hand": case "item": case "holding": case "arm": case "held": if ($entity instanceof SlapperHuman) { if (isset($args[2])) { $entity->getInventory()->setItemInHand(Item::fromString($args[2])); $sender->sendMessage($this->prefix . "Item updated."); } else { $sender->sendMessage($this->prefix . "Please enter an item ID."); } } else { $sender->sendMessage($this->prefix . "That entity can not wear armor."); } return true; case "setskin": case "changeskin": case "editskin": case "skin": if ($entity instanceof SlapperHuman) { $entity->setSkin($sender->getSkinData(), $sender->getSkinName()); $entity->respawnToAll(); $sender->sendMessage($this->prefix . "Skin updated."); } else { $sender->sendMessage($this->prefix . "That entity can't have a skin."); } return true; case "name": case "customname": if (isset($args[2])) { array_shift($args); array_shift($args); $entity->setDataProperty(2, Entity::DATA_TYPE_STRING, trim(implode(" ", $args))); $entity->respawnToAll(); $sender->sendMessage($this->prefix . "Name updated."); } else { $sender->sendMessage($this->prefix . "Please enter a name."); } return true; case "listname": case "nameonlist": case "menuname": if ($entity instanceof SlapperHuman) { if (isset($args[2])) { $type = 0; array_shift($args); array_shift($args); $input = trim(implode(" ", $args)); switch (strtolower($input)) { case "remove": case "": case "disable": case "off": case "hide": $type = 1; } if ($type === 0) { $entity->namedtag->MenuName = new String("MenuName", $input); } else { $entity->namedtag->MenuName = new String("MenuName", ""); } $entity->respawnToAll(); $sender->sendMessage($this->prefix . "Menu name updated."); } else { $sender->sendMessage($this->prefix . "Please enter a menu name."); return true; } } else { $sender->sendMessage($this->prefix . "That entity can not have a menu name."); } return true; break; case "namevisible": case "customnamevisible": case "tagvisible": case "name_visible": case "custom_name_visible": case "tag_visible": if (isset($args[2])) { $entity->setDataProperty(3, 0, intval($args[2])); $entity->respawnToAll(); $sender->sendMessage($this->prefix . "Name visibility updated."); } else { $sender->sendMessage($this->prefix . "Please enter a value, 1 or 0."); } return true; case "addc": case "addcmd": case "addcommand": if (isset($args[2])) { array_shift($args); array_shift($args); $input = trim(implode(" ", $args)); if (isset($entity->namedtag->Commands[$input])) { $sender->sendMessage($this->prefix . "That command has already been added."); return true; } $entity->namedtag->Commands[$input] = new String($input, $input); $sender->sendMessage($this->prefix . "Command added."); } else { $sender->sendMessage($this->prefix . "Please enter a command."); } return true; case "delc": case "delcmd": case "delcommand": case "removecommand": if (isset($args[2])) { array_shift($args); array_shift($args); $input = trim(implode(" ", $args)); unset($entity->namedtag->Commands[$input]); $sender->sendMessage($this->prefix . "Command removed."); } else { $sender->sendMessage($this->prefix . "Please enter a command."); } return true; case "listcommands": case "listcmds": case "listcs": if (!empty($entity->namedtag->Commands)) { $id = 0; foreach ($entity->namedtag->Commands as $cmd) { $id++; $sender->sendMessage(TextFormat::GREEN . "[" . TextFormat::YELLOW . "S" . TextFormat::GREEN . "] " . TextFormat::YELLOW . $id . ". " . TextFormat::GREEN . $cmd . "\n"); } } else { $sender->sendMessage($this->prefix . "That entity does not have any commands."); } return true; case "update": case "fix": case "migrate": if ($this->getConfig()->get($entity->getName()) !== false) { foreach ($this->getConfig()->get($entity->getName()) as $cmd) { $entity->namedtag->Commands[$cmd] = new String($cmd, $cmd); } $sender->sendMessage($this->prefix . "Commands migrated."); } else { $sender->sendMessage($this->prefix . "No old commands found."); } return true; case "block": case "tile": case "blockid": case "tileid": if ($entity instanceof SlapperFallingSand) { $entity->namedtag->BlockID = new Int("BlockID", intval($args[2])); $entity->respawnToAll(); $sender->sendMessage($this->prefix . "Block updated."); } else { $sender->sendMessage($this->prefix . "That entity is not a block."); } return true; break; case "teleporthere": case "tphere": case "movehere": case "bringhere": $entity->teleport($sender); $sender->sendMessage($this->prefix . "Teleported entity to you."); $entity->respawnToAll(); return true; break; case "teleportto": case "tpto": case "goto": case "teleport": case "tp": $sender->teleport($entity); $sender->sendMessage($this->prefix . "Teleported you to entity."); return true; break; default: $sender->sendMessage($this->prefix . "Unknown command."); return true; } } else { $sender->sendMessage($this->helpHeader); foreach ($this->editArgs as $msgArg) { $sender->sendMessage(str_ireplace("<eid>", $args[0], TextFormat::GREEN . " - " . $msgArg . "\n")); } return true; } } else { $sender->sendMessage($this->prefix . "That entity is not handled by Slapper."); } } else { $sender->sendMessage($this->prefix . "Entity does not exist."); } return true; } else { $sender->sendMessage($this->helpHeader); foreach ($this->editArgs as $msgArg) { $sender->sendMessage(TextFormat::GREEN . " - " . $msgArg . "\n"); } return true; } } else { $sender->sendMessage($this->prefix . "You don't have permission."); } return true; break; case "help": case "?": $sender->sendMessage($this->helpHeader); foreach ($this->mainArgs as $msgArg) { $sender->sendMessage(TextFormat::GREEN . " - " . $msgArg . "\n"); } return true; break; case "add": case "make": case "create": case "spawn": case "apawn": $type = array_shift($args); $spawn = true; $name = str_replace("{color}", "§", str_replace("{line}", "\n", trim(implode(" ", $args)))); if ($type === null || $type === "" || $type === " ") { $sender->sendMessage($this->prefix . "Please enter an entity type."); return true; } $defaultName = $sender->getDisplayName(); if (empty($name)) { $name = $defaultName; } $playerX = $sender->getX(); $playerY = $sender->getY(); $playerZ = $sender->getZ(); $inventory = $sender->getInventory(); $theOne = "Blank"; foreach (["Chicken", "ZombiePigman", "Pig", "Sheep", "Cow", "Mooshroom", "MushroomCow", "Wolf", "Enderman", "Spider", "Skeleton", "PigZombie", "Creeper", "Slime", "Silverfish", "Villager", "Zombie", "Human", "Player", "Squid", "Bat", "CaveSpider", "LavaSlime", "Ghast", "Ocelot", "Blaze", "ZombieVillager", "VillagerZombie", "Snowman", "SnowGolem", "Minecart", "FallingSand", "FallingBlock", "FakeBlock", "Boat", "PrimedTNT"] as $entityType) { if (strtolower($type) === strtolower($entityType)) { $theOne = $entityType; } } $typeToUse = "Nothing"; switch ($theOne) { case "Human": $typeToUse = "SlapperHuman"; break; case "Player": $typeToUse = "SlapperHuman"; break; case "Pig": $typeToUse = "SlapperPig"; break; case "Bat": $typeToUse = "SlapperBat"; break; case "Cow": $typeToUse = "SlapperCow"; break; case "Sheep": $typeToUse = "SlapperSheep"; break; case "MushroomCow": $typeToUse = "SlapperMushroomCow"; break; case "Mooshroom": $typeToUse = "SlapperMushroomCow"; break; case "LavaSlime": $typeToUse = "SlapperLavaSlime"; break; case "Enderman": $typeToUse = "SlapperEnderman"; break; case "Zombie": $typeToUse = "SlapperZombie"; break; case "Creeper": $typeToUse = "SlapperCreeper"; break; case "Skeleton": $typeToUse = "SlapperSkeleton"; break; case "Silverfish": $typeToUse = "SlapperSilverfish"; break; case "Chicken": $typeToUse = "SlapperChicken"; break; case "Villager": $typeToUse = "SlapperVillager"; break; case "CaveSpider": $typeToUse = "SlapperCaveSpider"; break; case "Spider": $typeToUse = "SlapperSpider"; break; case "Squid": $typeToUse = "SlapperSquid"; break; case "Wolf": $typeToUse = "SlapperWolf"; break; case "Slime": $typeToUse = "SlapperSlime"; break; case "PigZombie": $typeToUse = "SlapperPigZombie"; break; case "MagmaCube": $typeToUse = "SlapperLavaSlime"; break; case "ZombiePigman": $typeToUse = "SlapperPigZombie"; break; case "PrimedTNT": $typeToUse = "SlapperPrimedTNT"; break; case "Minecart": $typeToUse = "SlapperMinecart"; break; case "Boat": $typeToUse = "SlapperBoat"; break; case "FallingSand": $typeToUse = "SlapperFallingSand"; break; case "FallingBlock": $typeToUse = "SlapperFallingSand"; break; case "FakeBlock": $typeToUse = "SlapperFallingSand"; break; } switch ($theOne) { case "ZombieVillager": $typeToUse = "SlapperZombieVillager"; break; case "VillagerZombie": $typeToUse = "SlapperZombieVillager"; break; case "Ghast": $typeToUse = "SlapperGhast"; break; case "Blaze": $typeToUse = "SlapperBlaze"; break; case "IronGolem": $typeToUse = "SlapperIronGolem"; break; case "VillagerGolem": $typeToUse = "SlapperIronGolem"; break; case "SnowGolem": $typeToUse = "SlapperSnowman"; break; case "Snowman": $typeToUse = "SlapperSnowman"; break; case "Ocelot": $typeToUse = "SlapperOcelot"; break; } if (!($typeToUse === "Nothing") && !($theOne === "Blank")) { $nbt = $this->makeNBT($sender->getSkinData(), $sender->getSkinName(), $name, $inventory, $sender->getYaw(), $sender->getPitch(), $playerX, $playerY, $playerZ); $slapperEntity = Entity::createEntity($typeToUse, $sender->getLevel()->getChunk($playerX >> 4, $playerZ >> 4), $nbt); $sender->sendMessage($this->prefix . $theOne . " entity spawned with name " . TextFormat::WHITE . "\"" . TextFormat::BLUE . $name . TextFormat::WHITE . "\"" . TextFormat::GREEN . " and entity ID " . TextFormat::BLUE . $slapperEntity->getId()); } if (isset($slapperEntity) && $slapperEntity instanceof SlapperHuman) { $inv = $slapperEntity->getInventory(); $inv->setHelmet($inventory->getHelmet()); $inv->setChestplate($inventory->getChestplate()); $inv->setLeggings($inventory->getLeggings()); $inv->setBoots($inventory->getBoots()); $inv->setHeldItemSlot($inventory->getHeldItemSlot()); $inv->setItemInHand($inventory->getItemInHand()); } if (!($theOne == "Blank") && isset($slapperEntity)) { $slapperEntity->spawnToAll(); } if ($typeToUse === "Nothing" || $theOne === "Blank") { if ($spawn) { $sender->sendMessage($this->prefix . "Invalid entity."); } } return true; default: $sender->sendMessage($this->prefix . "Unknown command. Type '/slapper help' for help."); return true; } } else { $sender->sendMessage($this->prefix . "This command only works in game."); return true; } } return true; }