本文整理汇总了PHP中pocketmine\command\CommandSender::getZ方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandSender::getZ方法的具体用法?PHP CommandSender::getZ怎么用?PHP CommandSender::getZ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::getZ方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCommand
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;
}
示例2: onCommand
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.");
}
}
}
示例3: onCommand
//.........这里部分代码省略.........
$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;
}
}
}
示例4: onCommand
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])) {
//.........这里部分代码省略.........
示例5: execute
/**
* @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"));
}
}
示例6: onCommand
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;
//.........这里部分代码省略.........
示例7: onCommand
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;
}
}
示例8: onCommand
//.........这里部分代码省略.........
$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();
示例9: onCommand
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;
}
}
}
示例10: onCommand
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;
}
示例11: onCommand
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";
}
//.........这里部分代码省略.........
示例12: onCommand
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;
}
示例13: onCommand
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;
}
}
}