Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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.");
             }
     }
 }
Exemplo n.º 3
0
 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;
             }
     }
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 /**
  * @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"));
     }
 }
Exemplo n.º 6
0
Arquivo: Main.php Projeto: onebone/NPC
 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;
 }
Exemplo n.º 7
0
 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;
     }
 }
Exemplo n.º 8
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if ($sender instanceof Player) {
         $player = $sender->getPlayer()->getName();
         if (strtolower($command->getName('f'))) {
             if (empty($args)) {
                 $sender->sendMessage("[FactionsPro] Please use /f help for a list of commands");
             }
             if (count($args == 2)) {
                 //Create
                 if ($args[0] == "create") {
                     if (!ctype_alnum($args[1])) {
                         $sender->sendMessage("[FactionsPro] You may only use letters and numbers!");
                         return true;
                     }
                     if ($this->plugin->factionExists($args[1]) == true) {
                         $sender->sendMessage("[FactionsPro] Faction already exists");
                         return true;
                     }
                     if (strlen($args[1]) > $this->plugin->prefs->get("MaxFactionNameLength")) {
                         $sender->sendMessage("[FactionsPro] Faction name is too long. Please try again!");
                         return true;
                     }
                     if ($this->plugin->isInFaction($sender->getName())) {
                         $sender->sendMessage("[FactionsPro] You must leave this faction first");
                         return true;
                     } else {
                         $factionName = $args[1];
                         $player = strtolower($player);
                         $rank = "Leader";
                         $stmt = $this->plugin->db->prepare("INSERT OR REPLACE INTO master (player, faction, rank) VALUES (:player, :faction, :rank);");
                         $stmt->bindValue(":player", $player);
                         $stmt->bindValue(":faction", $factionName);
                         $stmt->bindValue(":rank", $rank);
                         $result = $stmt->execute();
                         $sender->sendMessage("[FactionsPro] Faction successfully created!");
                         return true;
                     }
                 }
                 //Invite
                 if ($args[0] == "invite") {
                     if ($this->plugin->isFactionFull($this->plugin->getPlayerFaction($player))) {
                         $sender->sendMessage("[FactionsPro] Faction is full. Please kick players to make room.");
                         return true;
                     }
                     $invited = $this->plugin->getServer()->getPlayerExact($args[1]);
                     if ($this->plugin->isInFaction($invited) == true) {
                         $sender->sendMessage("[FactionsPro] Player is currently in a faction");
                         return true;
                     }
                     if ($this->plugin->prefs->get("OnlyLeadersCanInvite") & !$this->plugin->isLeader($player)) {
                         $sender->sendMessage("[FactionsPro] Only your faction leader may invite!");
                         return true;
                     }
                     if (!$invited instanceof Player) {
                         $sender->sendMessage("[FactionsPro] Player not online!");
                         return true;
                     }
                     if ($invited->isOnline() == true) {
                         $factionName = $this->plugin->getPlayerFaction($player);
                         $invitedName = $invited->getName();
                         $rank = "Member";
                         $stmt = $this->plugin->db->prepare("INSERT OR REPLACE INTO confirm (player, faction, invitedby, timestamp) VALUES (:player, :faction, :invitedby, :timestamp);");
                         $stmt->bindValue(":player", strtolower($invitedName));
                         $stmt->bindValue(":faction", $factionName);
                         $stmt->bindValue(":invitedby", $sender->getName());
                         $stmt->bindValue(":timestamp", time());
                         $result = $stmt->execute();
                         $sender->sendMessage("[FactionsPro] Successfully invited {$invitedName}!");
                         $invited->sendMessage("[FactionsPro] You have been invited to {$factionName}. Type '/f accept' or '/f deny' into chat to accept or deny!");
                     } else {
                         $sender->sendMessage("[FactionsPro] Player not online!");
                     }
                 }
                 //Leader
                 if ($args[0] == "leader") {
                     if ($this->plugin->isInFaction($sender->getName()) == true) {
                         if ($this->plugin->isLeader($player) == true) {
                             if ($this->plugin->getPlayerFaction($player) == $this->plugin->getPlayerFaction($args[1])) {
                                 if ($this->plugin->getServer()->getPlayerExact($args[1])->isOnline() == true) {
                                     $factionName = $this->plugin->getPlayerFaction($player);
                                     $factionName = $this->plugin->getPlayerFaction($player);
                                     $stmt = $this->plugin->db->prepare("INSERT OR REPLACE INTO master (player, faction, rank) VALUES (:player, :faction, :rank);");
                                     $stmt->bindValue(":player", $player);
                                     $stmt->bindValue(":faction", $factionName);
                                     $stmt->bindValue(":rank", "Member");
                                     $result = $stmt->execute();
                                     $stmt = $this->plugin->db->prepare("INSERT OR REPLACE INTO master (player, faction, rank) VALUES (:player, :faction, :rank);");
                                     $stmt->bindValue(":player", strtolower($args[1]));
                                     $stmt->bindValue(":faction", $factionName);
                                     $stmt->bindValue(":rank", "Leader");
                                     $result = $stmt->execute();
                                     $sender->sendMessage("[FactionsPro] You are no longer leader!");
                                     $this->plugin->getServer()->getPlayerExact($args[1])->sendMessage("[FactionsPro] You are now leader \nof {$factionName}!");
                                 } else {
                                     $sender->sendMessage("[FactionsPro] Player not online!");
                                 }
                             } else {
                                 $sender->sendMessage("[FactionsPro] Add player to faction first!");
                             }
                         } else {
                             $sender->sendMessage("[FactionsPro] You must be leader to use this");
                         }
                     } else {
                         $sender->sendMessage("[FactionsPro] You must be in a faction to use this!");
                     }
                 }
                 //Promote
                 if ($args[0] == "promote") {
                     $factionName = $this->plugin->getPlayerFaction($player);
                     if ($this->plugin->isInFaction($sender->getName()) == false) {
                         $sender->sendMessage("[FactionsPro] You must be in a faction to use this!");
                         return true;
                     }
                     if ($this->plugin->isLeader($player) == false) {
                         $sender->sendMessage("[FactionsPro] You must be leader to use this");
                         return true;
                     }
                     if ($this->plugin->getPlayerFaction($player) != $this->getPlayerFaction($args[1])) {
                         $sender->sendMessage("[FactionsPro] Player is not in this faction!");
                         return true;
                     }
                     if ($this->plugin->isOfficer($player) == true) {
                         $sender->sendMessage("[FactionsPro] Player is already officer");
                         return true;
                     }
                     $stmt = $this->plugin->db->prepare("INSERT OR REPLACE INTO master (player, faction, rank) VALUES (:player, :faction, :rank);");
                     $stmt->bindValue(":player", strtolower($args[1]));
                     $stmt->bindValue(":faction", $factionName);
                     $stmt->bindValue(":rank", "Officer");
                     $result = $stmt->execute();
                 }
                 //Demote
                 if ($args[0] == "demote") {
                     $factionName = $this->plugin->getPlayerFaction($player);
                     if ($this->plugin->isInFaction($sender->getName()) == false) {
                         $sender->sendMessage("[FactionsPro] You must be in a faction to use this!");
                         return true;
                     }
                     if ($this->plugin->isLeader($player) == false) {
                         $sender->sendMessage("[FactionsPro] You must be leader to use this");
                         return true;
                     }
                     if ($this->plugin->getPlayerFaction($player) != $this->getPlayerFaction($args[1])) {
                         $sender->sendMessage("[FactionsPro] Player is not in this faction!");
                         return true;
                     }
                     if ($this->plugin->isOfficer($player) == false) {
                         $sender->sendMessage("[FactionsPro] Player is not Officer");
                         return true;
                     }
                     $stmt = $this->plugin->db->prepare("INSERT OR REPLACE INTO master (player, faction, rank) VALUES (:player, :faction, :rank);");
                     $stmt->bindValue(":player", strtolower($args[1]));
                     $stmt->bindValue(":faction", $factionName);
                     $stmt->bindValue(":rank", "Member");
                     $result = $stmt->execute();
                 }
                 //Kick
                 if ($args[0] == "kick") {
                     if ($this->plugin->isInFaction($sender->getName()) == false) {
                         $sender->sendMessage("[FactionsPro] You must be in a faction to use this!");
                         return true;
                     }
                     if ($this->plugin->isLeader($player) == false) {
                         $sender->sendMessage("[FactionsPro] You must be leader to use this");
                         return true;
                     }
                     if ($this->plugin->getPlayerFaction($player) != $this->getPlayerFaction($args[1])) {
                         $sender->sendMessage("[FactionsPro] Player is not in this faction!");
                         return true;
                     }
                     $kicked = $this->plugin->getServer()->getPlayerExact($args[1]);
                     $factionName = $this->plugin->getPlayerFaction($player);
                     $this->plugin->db->query("DELETE FROM master WHERE player='{$args['1']}';");
                     $sender->sendMessage("[FactionsPro] You successfully kicked {$args['1']}!");
                     $players[] = $this->plugin->getServer()->getOnlinePlayers();
                     if (in_array($args[1], $players) == true) {
                         $this->plugin->getServer()->getPlayerExact($args[1])->sendMessage("[FactionsPro] You have been kicked from \n {$factionName}!");
                         return true;
                     }
                 }
                 //Info
                 if (strtolower($args[0]) == 'info') {
                     if (isset($args[1])) {
                         if (!ctype_alnum($args[1]) | !$this->plugin->factionExists($args[1])) {
                             $sender->sendMessage("[FactionsPro] Faction does not exist");
                             return true;
                         }
                         $faction = strtolower($args[1]);
                         $leader = $this->plugin->getLeader($faction);
                         $numPlayers = $this->plugin->getNumberOfPlayers($faction);
                         $sender->sendMessage("-------------------------");
                         $sender->sendMessage("{$faction}");
                         $sender->sendMessage("Leader: {$leader}");
                         $sender->sendMessage("# of Players: {$numPlayers}");
                         $sender->sendMessage("MOTD: {$message}");
                         $sender->sendMessage("-------------------------");
                     } else {
                         $faction = $this->plugin->getPlayerFaction(strtolower($sender->getName()));
                         $result = $this->plugin->db->query("SELECT * FROM motd WHERE faction='{$faction}';");
                         $array = $result->fetchArray(SQLITE3_ASSOC);
                         $message = $array["message"];
                         $leader = $this->plugin->getLeader($faction);
                         $numPlayers = $this->plugin->getNumberOfPlayers($faction);
                         $sender->sendMessage("-------------------------");
                         $sender->sendMessage("{$faction}");
                         $sender->sendMessage("Leader: {$leader}");
                         $sender->sendMessage("# of Players: {$numPlayers}");
                         $sender->sendMessage("MOTD: {$message}");
                         $sender->sendMessage("-------------------------");
                     }
                 }
             }
             if (count($args == 1)) {
                 //Plot
                 if (strtolower($args[0]) == "plot") {
                     $x = floor($sender->getX());
                     $y = floor($sender->getY());
                     $z = floor($sender->getZ());
                     $faction = $this->plugin->getPlayerFaction($sender->getPlayer()->getName());
                     $this->plugin->drawPlot($faction, $x, $y, $z, $sender->getPlayer()->getLevel(), $this->plugin->prefs->get("PlotSize"));
                     $sender->sendMessage("[FactionsPro] Plot claimed.");
                 }
                 //MOTD
                 if (strtolower($args[0]) == "motd") {
                     if ($this->plugin->isInFaction($sender->getName()) == false) {
                         $sender->sendMessage("[FactionsPro] You must be in a faction to use this!");
                         return true;
                     }
                     if ($this->plugin->isLeader($player) == false) {
                         $sender->sendMessage("[FactionsPro] You must be leader to use this");
                         return true;
                     }
                     $sender->sendMessage("[FactionsPro] Type your message in chat. It will not be visible to other players");
                     $stmt = $this->plugin->db->prepare("INSERT OR REPLACE INTO motdrcv (player, timestamp) VALUES (:player, :timestamp);");
                     $stmt->bindValue(":player", strtolower($sender->getName()));
                     $stmt->bindValue(":timestamp", time());
                     $result = $stmt->execute();
                 }
                 //Accept
                 if (strtolower($args[0]) == "accept") {
                     $player = $sender->getName();
                     $lowercaseName = strtolower($player);
                     $result = $this->plugin->db->query("SELECT * FROM confirm WHERE player='{$lowercaseName}';");
                     $array = $result->fetchArray(SQLITE3_ASSOC);
                     if (empty($array) == true) {
                         $sender->sendMessage("[FactionsPro] You have not been invited to any factions!");
                         return true;
                     }
                     $invitedTime = $array["timestamp"];
                     $currentTime = time();
                     if ($currentTime - $invitedTime <= 60) {
                         //This should be configurable
                         $faction = $array["faction"];
                         $stmt = $this->plugin->db->prepare("INSERT OR REPLACE INTO master (player, faction, rank) VALUES (:player, :faction, :rank);");
                         $stmt->bindValue(":player", strtolower($player));
                         $stmt->bindValue(":faction", $faction);
                         $stmt->bindValue(":rank", "Member");
                         $result = $stmt->execute();
                         $this->plugin->db->query("DELETE FROM confirm WHERE player='{$lowercaseName}';");
                         $sender->sendMessage("[FactionsPro] You successfully joined {$faction}!");
                         $this->plugin->getServer()->getPlayerExact($array["invitedby"])->sendMessage("[FactionsPro] {$player} joined the faction!");
                     } else {
                         $sender->sendMessage("[FactionsPro] Invite has timed out!");
                         $this->plugin->db->query("DELETE * FROM confirm WHERE player='{$player}';");
                     }
                 }
                 //Deny
                 if (strtolower($args[0]) == "deny") {
                     $player = $sender->getName();
                     $lowercaseName = strtolower($player);
                     $result = $this->plugin->db->query("SELECT * FROM confirm WHERE player='{$lowercaseName}';");
                     $array = $result->fetchArray(SQLITE3_ASSOC);
                     if (empty($array) == true) {
                         $sender->sendMessage("[FactionsPro] You have not been invited to any factions!");
                         return true;
                     }
                     $invitedTime = $array["timestamp"];
                     $currentTime = time();
                     if ($currentTime - $invitedTime <= 60) {
                         //This should be configurable
                         $this->plugin->db->query("DELETE * FROM confirm WHERE player='{$lowercaseName}';");
                         $sender->sendMessage("[FactionsPro] Invite declined!");
                         $this->plugin->getServer()->getPlayerExact($array["invitedby"])->sendMessage("[FactionsPro] {$player} declined the invite!");
                     } else {
                         $sender->sendMessage("[FactionsPro] Invite has timed out!");
                         $this->plugin->db->query("DELETE * FROM confirm WHERE player='{$lowercaseName}';");
                     }
                 }
                 //Delete
                 if (strtolower($args[0]) == "del") {
                     if ($this->plugin->isInFaction($player) == true) {
                         if ($this->plugin->isLeader($player)) {
                             $faction = $this->plugin->getPlayerFaction($player);
                             $this->plugin->db->query("DELETE FROM master WHERE faction='{$faction}';");
                             $sender->sendMessage("[FactionsPro] Faction successfully disbanded!");
                         } else {
                             $sender->sendMessage("[FactionsPro] You are not leader!");
                         }
                     } else {
                         $sender->sendMessage("[FactionsPro] You are not in a faction!");
                     }
                 }
                 //Leave
                 if (strtolower($args[0] == "leave")) {
                     if ($this->plugin->isLeader($player) == false) {
                         $remove = $sender->getPlayer()->getNameTag();
                         $faction = $this->plugin->getPlayerFaction($player);
                         $name = $sender->getName();
                         $this->plugin->db->query("DELETE FROM master WHERE player='{$name}';");
                         $sender->sendMessage("[FactionsPro] You successfully left {$faction}");
                     } else {
                         $sender->sendMessage("[FactionsPro] You must delete or give\nleadership first!");
                     }
                 }
                 if (strtolower($args[0]) == "help") {
                     $sender->sendMessage("FactionsPro Commands\n/f create <name>\n/f del\n/f help\n/f invite <player>\n/f kick <player>\n/f leave\n/f leader <player>\n/f leave\n/f motd\n/f info");
                 }
             } else {
                 $sender->sendMessage("[FactionsPro] Please use /f help for a list of commands");
             }
         }
     } else {
         $this->plugin->getServer()->getLogger()->info(TextFormat::RED . "[FactionsPro] Please run command in game");
     }
 }
Exemplo n.º 9
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch ($command->getName()) {
         case 'nothing':
             return true;
             break;
         case 'rca':
             if (count($args) < 2) {
                 $sender->sendMessage("Please enter a player and a command.");
                 return false;
             }
             $player = $this->getServer()->getPlayer($tuv = array_shift($args));
             if (!($player == null)) {
                 $commandForSudo = trim(implode(" ", $args));
                 $this->getServer()->dispatchCommand($player, $commandForSudo);
                 return true;
                 break;
             }
             $sender->sendMessage(TextFormat::RED . "Player not found.");
             return true;
             break;
         case "slapper":
             if ($sender instanceof Player) {
                 $name = trim(implode(" ", $args));
                 $defaultName = $sender->getDisplayName();
                 if ($name == null) {
                     $name = $defaultName;
                 }
                 $senderSkin = $sender->getSkinData();
                 $IsSlim = $sender->isSkinSlim();
                 $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();
                 $playerYaw = $sender->getYaw();
                 $playerPitch = $sender->getPitch();
                 $humanInv = $sender->getInventory();
                 $pHealth = $sender->getHealth();
                 $nbt = new Compound();
                 $motion = new Vector3(0, 0, 0);
                 $nbt->Pos = new Enum("Pos", [new Double("", $playerX), new Double("", $playerY), new Double("", $playerZ)]);
                 $nbt->Motion = new Enum("Motion", [new Double("", $motion->x), new Double("", $motion->y), new Double("", $motion->z)]);
                 $nbt->Rotation = new Enum("Rotation", [new Float("", $playerYaw), new Float("", $playerPitch)]);
                 $nbt->Health = new Short("Health", $pHealth);
                 $nbt->Inventory = new Enum("Inventory", $humanInv);
                 $nbt->NameTag = new String("name", $name);
                 $nbt->Invulnerable = new Byte("Invulnerable", 1);
                 $nbt->CustomTestTag = new Byte("CustomTestTag", 1);
                 $nbt->Skin = new Compound("Skin", ["Data" => new String("Data", $senderSkin), "Slim" => new Byte("Slim", $IsSlim)]);
                 $clonedHuman = Entity::createEntity("Human", $sender->getLevel()->getChunk($playerX >> 4, $playerZ >> 4), $nbt);
                 $Inv = $clonedHuman->getInventory();
                 $sender->sendMessage(TextFormat::GREEN . "[" . TextFormat::YELLOW . "Slapper" . TextFormat::GREEN . "] " . "Human entity spawned with name " . TextFormat::WHITE . "\"" . TextFormat::BLUE . $name . TextFormat::WHITE . "\"");
                 $pHelm = $humanInv->getHelmet();
                 $pChes = $humanInv->getChestplate();
                 $pLegg = $humanInv->getLeggings();
                 $pBoot = $humanInv->getBoots();
                 $Inv->setHelmet($pHelm);
                 $Inv->setChestplate($pChes);
                 $Inv->setLeggings($pLegg);
                 $Inv->setBoots($pBoot);
                 $clonedHuman->getInventory()->setHeldItemSlot($sender->getInventory()->getHeldItemSlot());
                 $clonedHuman->getInventory()->setItemInHand($sender->getInventory()->getItemInHand());
                 $clonedHuman->spawnToAll();
                 return true;
             } else {
                 $sender->sendMessage("This command only works in game.");
                 return true;
             }
     }
 }
Exemplo n.º 10
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch ($command->getName()) {
         case "gamelevel":
             if (count($args) < 1) {
                 return false;
             }
             if (!$sender instanceof Player) {
                 $sender->sendMessage(TextFormat::RED . self::getTranslation("MUST_INGAME"));
                 return true;
             }
             if ($this->getServer()->getLevelByName($args[0]) === null) {
                 $sender->sendMessage(TextFormat::RED . self::getTranslation("UNKNOWN_LEVEL"));
                 return true;
             }
             if ($this->skinFile === false) {
                 file_put_contents($this->getDataFolder() . "npc.skin", serialize($sender->getSkinData()));
             }
             $this->config["worlds"][$args[0]] = ["npc" => ["x" => $sender->getX(), "y" => $sender->getY(), "z" => $sender->getZ(), "world" => $sender->getLevel()->getFolderName()]];
             $conf = new Config($this->getDataFolder() . "config.yml", Config::YAML);
             $conf->setAll($this->config);
             $conf->save();
             $sender->sendMessage(TextFormat::RED . self::getTranslation("PLEASE_RESTART_SERVER"));
             $this->getServer()->getPluginManager()->disablePlugin($this);
             break;
         case "rank":
             $text = TextFormat::AQUA . "=========" . self::getTranslation("RANK") . "=========" . TextFormat::YELLOW;
             foreach ($this->wins as $winner => $count) {
                 $text .= "\n" . $winner . " : " . $count;
             }
             $sender->sendMessage($text);
             break;
     }
     return true;
 }
Exemplo n.º 11
0
 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.");
                 return true;
             }
             $player = $this->getServer()->getPlayer(array_shift($args));
             if (!($player === null)) {
                 $this->getServer()->dispatchCommand($player, trim(implode(" ", $args)));
                 return true;
                 break;
             }
             $sender->sendMessage(TextFormat::RED . "Player not found.");
             return true;
             break;
         case "slapper":
             if ($sender instanceof Player) {
                 $type = array_shift($args);
                 $name = str_replace("{color}", "§", str_replace("{line}", "\n", trim(implode(" ", $args))));
                 if ($type === null || $type === "" || $type === " ") {
                     return false;
                 }
                 $defaultName = $sender->getDisplayName();
                 if ($name == null) {
                     $name = $defaultName;
                 }
                 $senderSkin = $sender->getSkinData();
                 $isSlim = $sender->isSkinSlim();
                 $playerX = $sender->getX();
                 $playerY = $sender->getY();
                 $playerZ = $sender->getZ();
                 $playerYaw = $sender->getYaw();
                 $playerPitch = $sender->getPitch();
                 $humanInv = $sender->getInventory();
                 $theOne = "Blank";
                 $nameToSay = "Human";
                 $didMatch = "No";
                 foreach (["Chicken", "ZombiePigman", "Pig", "Sheep", "Cow", "Mooshroom", "MushroomCow", "Wolf", "Enderman", "Spider", "Skeleton", "PigZombie", "Creeper", "Slime", "Silverfish", "Villager", "Zombie", "Human", "Player", "Squid", "Bat", "CaveSpider", "LavaSlime"] as $entityType) {
                     if (strtolower($type) === strtolower($entityType)) {
                         $didMatch = "Yes";
                         $theOne = $entityType;
                     }
                 }
                 $typeToUse = "Nothing";
                 if ($theOne === "Human") {
                     $typeToUse = "SlapperHuman";
                 }
                 if ($theOne === "Player") {
                     $typeToUse = "SlapperHuman";
                 }
                 if ($theOne === "Pig") {
                     $typeToUse = "SlapperPig";
                 }
                 if ($theOne === "Bat") {
                     $typeToUse = "SlapperBat";
                 }
                 if ($theOne === "Cow") {
                     $typeToUse = "SlapperCow";
                 }
                 if ($theOne === "Sheep") {
                     $typeToUse = "SlapperSheep";
                 }
                 if ($theOne === "MushroomCow") {
                     $typeToUse = "SlapperMushroomCow";
                 }
                 if ($theOne === "Mooshroom") {
                     $typeToUse = "SlapperMushroomCow";
                 }
                 if ($theOne === "LavaSlime") {
                     $typeToUse = "SlapperLavaSlime";
                 }
                 if ($theOne === "Enderman") {
                     $typeToUse = "SlapperEnderman";
                 }
                 if ($theOne === "Zombie") {
                     $typeToUse = "SlapperZombie";
                 }
                 if ($theOne === "Creeper") {
                     $typeToUse = "SlapperCreeper";
                 }
                 if ($theOne === "Skeleton") {
                     $typeToUse = "SlapperSkeleton";
                 }
                 if ($theOne === "Silverfish") {
                     $typeToUse = "SlapperSilverfish";
                 }
                 if ($theOne === "Chicken") {
                     $typeToUse = "SlapperChicken";
                 }
                 if ($theOne === "Villager") {
                     $typeToUse = "SlapperVillager";
                 }
                 if ($theOne === "CaveSpider") {
                     $typeToUse = "SlapperCaveSpider";
                 }
                 if ($theOne === "Spider") {
                     $typeToUse = "SlapperSpider";
                 }
                 if ($theOne === "Squid") {
                     $typeToUse = "SlapperSquid";
                 }
                 if ($theOne === "Wolf") {
                     $typeToUse = "SlapperWolf";
                 }
                 if ($theOne === "Slime") {
                     $typeToUse = "SlapperSlime";
                 }
                 if ($theOne === "PigZombie") {
                     $typeToUse = "SlapperPigZombie";
                 }
                 if ($theOne === "MagmaCube") {
                     $typeToUse = "SlapperLavaSlime";
                 }
                 if ($theOne === "ZombiePigman") {
                     $typeToUse = "SlapperPigZombie";
                 }
                 if ($theOne === "PigZombie") {
                     $typeToUse = "SlapperPigZombie";
                 }
                 if (strtolower($theOne) === "remove") {
                     if ($sender->hasPermission("slapper.remove")) {
                         $this->hitSessions[$sender->getName()] = "on";
                         $sender->sendMessage(TextFormat::GREEN . "[" . TextFormat::YELLOW . "Slapper" . TextFormat::GREEN . "]" . "Hit an entity to remove it");
                     }
                 }
                 if (!($typeToUse === "Nothing") && !($theOne === "Blank")) {
                     $nbt = $this->makeNBT($senderSkin, $isSlim, $name, $humanInv, $playerYaw, $playerPitch, $playerX, $playerY, $playerZ);
                     $clonedHuman = Entity::createEntity($typeToUse, $sender->getLevel()->getChunk($playerX >> 4, $playerZ >> 4), $nbt);
                     $sender->sendMessage(TextFormat::GREEN . "[" . TextFormat::YELLOW . "Slapper" . TextFormat::GREEN . "] " . $theOne . " entity spawned with name " . TextFormat::WHITE . "\"" . TextFormat::BLUE . $name . TextFormat::WHITE . "\"");
                 }
                 if ($typeToUse === "SlapperHuman") {
                     $Inv = $clonedHuman->getInventory();
                     $pHelm = $humanInv->getHelmet();
                     $pChes = $humanInv->getChestplate();
                     $pLegg = $humanInv->getLeggings();
                     $pBoot = $humanInv->getBoots();
                     $Inv->setHelmet($pHelm);
                     $Inv->setChestplate($pChes);
                     $Inv->setLeggings($pLegg);
                     $Inv->setBoots($pBoot);
                     $clonedHuman->getInventory()->setHeldItemSlot($sender->getInventory()->getHeldItemSlot());
                     $clonedHuman->getInventory()->setItemInHand($sender->getInventory()->getItemInHand());
                 }
                 if (!($theOne == "Blank")) {
                     $clonedHuman->spawnToAll();
                 }
                 if ($typeToUse === "Nothing" || $theOne === "Blank") {
                     $sender->sendMessage("Invalid entity.");
                 }
                 return true;
             } else {
                 $sender->sendMessage("This command only works in game.");
                 return true;
             }
     }
 }
Exemplo n.º 12
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $params)
 {
     if (!$sender instanceof Player) {
         $sender->sendMessage(TextFormat::RED . $this->getTranslation("MUST_INGAME"));
         return true;
     }
     //$sender = (Player) $sender;
     switch ($command->getName()) {
         case "setspawnpos":
             $this->config["spawnpos"] = array("x" => $sender->getX(), "y" => $sender->getY(), "z" => $sender->getZ());
             $sender->sendMessage(TextFormat::AQUA . $this->getTranslation("SPAWNPOS_SET"));
             $config = new Config($this->getDataFolder() . "config.yml", Config::YAML);
             $config->set("spawnpos", $this->config["spawnpos"]);
             $config->save();
             break;
         case "explanation":
             if (count($params) <= 0) {
                 $sender->sendMessage(TextFormat::GREEN . "Explanation (1/3)");
                 $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_1", GameManager::$INITIAL_ZOMBIE_COUNT));
                 $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_2"));
                 $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_3", GameManager::$ROUND_COUNT));
                 $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_4"));
                 $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_5"));
                 return true;
             }
             switch ($params[0]) {
                 case "1":
                     $sender->sendMessage(TextFormat::GREEN . "Explanation (1/3)");
                     $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_1", GameManager::$INITIAL_ZOMBIE_COUNT));
                     $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_2"));
                     $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_3", GameManager::$ROUND_COUNT));
                     $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_4"));
                     $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_5"));
                     break;
                 case "2":
                     $sender->sendMessage(TextFormat::GREEN . "Explanation (2/3)");
                     $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_P2_1"));
                     $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_P2_2"));
                     $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_P2_3"));
                     break;
                 case "3":
                     $sender->sendMessage(TextFormat::GREEN . "Explanation (3/3)");
                     $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_P3_1"));
                     $sender->sendMessage(TextFormat::GREEN . $this->getTranslation("GAME_EXPLANATION_P3_2", floor(GameManager::$INFECTION_MEDICINE_TERM / 20)));
                     break;
                 default:
                     $sender->sendMessage(TextFormat::RED . "/explanation [Page Number]");
                     break;
             }
             break;
         case "setresetpos":
             $this->config["resetpos"] = array("x" => $sender->getX(), "y" => $sender->getY(), "z" => $sender->getZ());
             $sender->sendMessage(TextFormat::AQUA . $this->getTranslation("RESETPOS_SET"));
             $config = new Config($this->getDataFolder() . "config.yml", Config::YAML);
             $config->set("resetpos", $this->config["resetpos"]);
             $config->save();
             break;
         default:
             $sender->sendMessage(TextFormat::RED . $this->getTranslation("UNKNOWN_COMMAND"));
             break;
     }
     return true;
 }
Exemplo n.º 13
0
 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if (strtolower($command->getName()) === "lookout") {
         switch ($args[0]) {
             case "end":
                 if ($sender->hasPermission("lookout.cmd.end")) {
                     if ($this->gamestatus === 1) {
                         $this->endGame();
                         return true;
                     }
                 } else {
                     $sender->sendMessage("You do not have permission to execute this command.");
                     return true;
                 }
                 break;
             case "help":
                 if ($sender->hasPermission("lookout.cmd.help")) {
                     return false;
                 } else {
                     $sender->sendMessage("You do not have permission to execute this command.");
                     return true;
                 }
                 break;
             case "time":
                 if ($sender->hasPermission("lookout.cmd.time")) {
                     $sender->sendMessage($this->timer->endingtime . " seconds left to end.");
                     if ($this->gamestatus === 1 && in_array($this->players, $sender->getName())) {
                         $sender->sendMessage($this->timer->endingtime . " seconds left to end.");
                         return true;
                     }
                 } else {
                     $sender->sendMessage("You do not have permission to execute this command.");
                     return true;
                 }
                 break;
             case "setpos":
                 if ($sender->hasPermission("lookout.cmd.setpos")) {
                     $x = $sender->getX();
                     $y = $sender->getY();
                     $z = $sender->getZ();
                     $this->setting->set("x_axis_for_generation", $x);
                     $this->setting->set("y_axis_for_generation", $y);
                     $this->setting->set("z_axis_for_generation", $z);
                     $sender->sendMessage("Position all set!");
                     return true;
                 } else {
                     $sender->sendMessage("You do not have permission to execute this command.");
                     return true;
                 }
                 break;
             case "setspawns":
                 return true;
                 break;
             default:
                 return false;
                 break;
         }
     }
 }