本文整理汇总了PHP中pocketmine\command\CommandSender::getPlayer方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandSender::getPlayer方法的具体用法?PHP CommandSender::getPlayer怎么用?PHP CommandSender::getPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::getPlayer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
switch ($command->getName()) {
case "info1":
$sender->sendMessage($this->getConfig()->get("info1"));
break;
case "info2":
$player = $sender->getPlayer();
$sender->sendMessage($this->getConfig()->get("info2"));
break;
}
}
示例2: execute
public function execute(CommandSender $sender, $label, array $params)
{
if (!$this->plugin->isEnabled()) {
return false;
}
if (!$sender instanceof Player) {
$sender->sendMessage("Please use the command in-game");
return true;
} else {
$this->arenaManager->spawnPlayerToArena($sender->getPlayer());
}
}
示例3: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (!$sender instanceof Player) {
return;
}
$getItemHand = $sender->getInventory()->getItemInHand();
$ItemCode = $getItemHand->getId();
if (strtolower($command->getName()) == "bancraft") {
if (!isset($args[0])) {
$sender->sendMessage(TextFormat::AQUA . "/bancraft <add|remove|reset|list>");
$sender->sendMessage(TextFormat::GOLD . "/bancraft add - 들고있는 아이템 조합을 벤합니다");
$sender->sendMessage(TextFormat::GOLD . "/bancraft remove - 들고있는 아이템 조합벤을 풉니다");
$sender->sendMessage(TextFormat::GOLD . "/bancraft reset - 금지된 조합법들을 초기화 합니다");
$sender->sendMessage(TextFormat::GOLD . "/bancraft list - 금지된 조합법 목록을 확인 합니다");
return;
}
switch (strtolower($args[0])) {
case "add":
$getItemHand = $sender->getInventory()->getItemInHand();
$banItem = $getItemHand->getId() . ":" . $getItemHand->getDamage();
array_push($this->configData["CraftBan"], $banItem);
$sender->sendMessage(TextFormat::RED . $banItem . "를 벤하였습니다");
break;
case "reset":
$this->configData["CraftBan"] = [];
$sender->sendMessage(TextFormat::RED . "조합 금지 리스트 초기화");
break;
case "remove":
$getItemHand = $sender->getInventory()->getItemInHand();
$banItem = $getItemHand->getId() . ":" . $getItemHand->getDamage();
unset($this->configData["CraftBan"][array_search($getItemHand, $this->configData["CraftBan"])]);
$sender->sendMessage(TextFormat::RED . $banItem . "를 초기화 시켰습니다");
case "list":
foreach ($this->configData["CraftBan"] as $banlist) {
$sender->getPlayer()->sendMessage(TextFormat::AQUA . $banlist);
$sender->sendMessage(TextFormat::RED . "금지된 조합목록을 불러옵니다");
}
}
}
$this->config->save();
$this->config->setAll($this->configData);
}
示例4: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if ($sender instanceof Player) {
$ses = $this->plugin->getSession($sender->getPlayer());
//new
$player = $sender->getPlayer()->getName();
if (strtolower($command->getName('f'))) {
if (empty($args)) {
$sender->sendMessage($this->plugin->formatMessage("Please use /f help for a list of commands"));
return true;
}
if (count($args == 2)) {
/////////////////////////////// CREATE ///////////////////////////////
if ($args[0] == "create") {
if ($this->plugin->commands->get("/f create") == false) {
$sender->sendMessage($this->plugin->formatMessage("This command has been disabled, please ask\nan Admin if you think this is a mistake."));
return true;
}
if (!isset($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("Usage: /f create <faction name>"));
return true;
}
if (!ctype_alnum($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("You may only use letters and numbers!"));
return true;
}
if ($this->plugin->isNameBanned($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("This name is not allowed."));
return true;
}
if ($this->plugin->factionExists($args[1]) == true) {
$sender->sendMessage($this->plugin->formatMessage("Faction already exists"));
return true;
}
if (strlen($args[1]) > $this->plugin->prefs->get("Maximum Faction Name Length")) {
$sender->sendMessage($this->plugin->formatMessage("This name is too long. Please try again!"));
return true;
}
if ($ses->inFaction()) {
$sender->sendMessage($this->plugin->formatMessage("You must leave this faction first"));
return true;
} else {
$factionName = $args[1];
$f = new Faction($this->plugin, $args[1], $sender->getPlayer());
//TODO: Split into two lines
$ses->updateFaction();
$sender->sendMessage($this->plugin->formatMessage("Faction successfully created!", true));
return true;
}
}
/////////////////////////////// INVITE ///////////////////////////////
if ($args[0] == "invite") {
if ($this->plugin->commands->get("/f invite") == false) {
$sender->sendMessage($this->plugin->formatMessage("This command has been disabled, please ask\nan Admin if you think this is a mistake."));
return true;
}
if (!isset($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("Usage: /f invite <player>"));
return true;
}
if ($this->plugin->prefs->get("OnlyLeadersAndOfficersCanInvite") && !$ses->isLeader()) {
$sender->sendMessage($this->plugin->formatMessage("You are not allowed to invite."));
return true;
}
if ($ses->getFaction()->isFull()) {
$sender->sendMessage($this->plugin->formatMessage("Faction is full. Please kick players to make room."));
return true;
}
$invited = $this->plugin->getServer()->getPlayer($args[1]);
if (!$invited instanceof Player) {
$sender->sendMessage($this->plugin->formatMessage("Player not online!"));
return true;
}
if ($this->plugin->getSession($invited)->inFaction()) {
$sender->sendMessage($this->plugin->formatMessage("Player is currently in a faction"));
return true;
}
$invite = new FactionInvite($this->plugin->getSession($invited), $ses);
$sender->sendMessage($this->plugin->formatMessage($invited->getName() . " has been invited!", true));
$invited->sendMessage($this->plugin->formatMessage("You have been invited to " . $ses->getFaction()->getName() . ". Type '/f accept' or '/f deny' into chat to accept or deny!", true));
}
/////////////////////////////// LEADER ///////////////////////////////
if ($args[0] == "leader") {
if ($this->plugin->commands->get("/f leader") == false) {
$sender->sendMessage($this->plugin->formatMessage("This command has been disabled, please ask\nan Admin if you think this is a mistake."));
return true;
}
if (!isset($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("Usage: /f leader <player>"));
return true;
}
if (!$ses->inFaction()) {
$sender->sendMessage($this->plugin->formatMessage("You must be in a faction to use this!"));
return true;
}
if (!$ses->isLeader()) {
$sender->sendMessage($this->plugin->formatMessage("You must be leader to use this"));
return true;
}
if ($ses->getFaction() != $this->plugin->getSession($this->plugin->getServer()->getPlayer($args[1]))->getFaction()) {
//.........这里部分代码省略.........
示例5: onCommand
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!");
}
//.........这里部分代码省略.........
示例6: onCommand
/**
* Handle CTF Commands
*
* @param CommandSender $sender
* @param Command $command
* @param unknown $label
* @param array $args
* @return boolean
*/
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
$player = null;
if (!$sender instanceof PLayer) {
$sender->sendMessage($this->getMsg("ctf.error.wrong-sender"));
return;
}
$player = $sender->getPlayer();
if (strtolower($command->getName()) == self::CTF_COMMAND && isset($args[0])) {
if (strtolower($args[0]) == self::CTF_COMMAND_CREATE_ARENA || strtolower($args[0]) == self::CTF_COMMAND_RESET_ARENA) {
if (!$sender->isOp()) {
$sender->sendMessage($this->getMsg("ctf.error.no-permission"));
return;
}
$this->buildGameArena($sender);
$output = TextFormat::BLUE . "----------------------------------\n";
$output .= TextFormat::BLUE . $this->getMsg("arena.created") . "\n";
$output .= TextFormat::BLUE . "----------------------------------\n";
$sender->sendMessage($output);
return true;
} elseif (strtolower($args[0]) == self::CTF_COMMAND_BLOCK_DISPLAY_ON) {
if (!$sender->isOp()) {
$sender->sendMessage($this->getMsg("ctf.error.no-permission"));
return;
}
$this->getPlugIn()->pos_display_flag = 1;
$sender->sendMessage($this->getMsg("block.display-on"));
} elseif (strtolower($args[0]) == self::CTF_COMMAND_BLOCK_DISPLAY_OFF) {
if (!$sender->isOp()) {
$sender->sendMessage($this->getMsg("ctf.error.no-permission"));
return;
}
$this->getPlugIn()->pos_display_flag = 0;
$sender->sendMessage($this->getMsg("block.display-off"));
} elseif (strtolower($args[0]) == self::CTF_COMMAND_JOIN_BLUE_TEAM) {
$sender->sendMessage($this->getMsg("team.join-blue"));
$this->handleJoinBlueTeam($player);
return;
} elseif (strtolower($args[0]) == self::CTF_COMMAND_JOIN_RED_TEAM) {
$sender->sendMessage($this->getMsg("team.join-red"));
$this->handleJoinRedTeam($player);
return;
} elseif (strtolower($args[0]) == self::CTF_COMMAND_LEAVE) {
$sender->sendMessage($this->getMsg("game.player-left"));
$this->handleLeaveTheGame($player);
} elseif (strtolower($args[0]) == self::CTF_COMMAND_STOP) {
$sender->sendMessage($this->getMsg("game.player-stop"));
$this->stopGame($player);
} elseif (strtolower($args[0]) == self::CTF_COMMAND_HOME) {
$sender->sendMessage($this->getMsg("sign.teleport.ctf"));
$this->teleportPlayerToHome($player);
} elseif (strtolower($args[0]) == self::CTF_COMMAND_START) {
$sender->sendMessage($this->getMsg("game.player-start"));
$this->handleStartTheGame($player->getLevel());
} elseif (strtolower($args[0]) == self::CTF_COMMAND_STATS) {
$sender->sendMessage($this->getMsg("game.stats"));
$this->displayTeamScores($sender);
} elseif (strtolower($args[0]) == self::CTF_COMMAND_SET_SIGN_JOIN_BLUE_TEAM) {
if (!$sender->isOp()) {
$sender->sendMessage($this->getMsg("ctf.error.no-permission"));
return;
}
$this->getPlugIn()->setupModeAction = self::CTF_COMMAND_SET_SIGN_JOIN_BLUE_TEAM;
$sender->sendMessage($this->getMsg("ctf.setup.action") . self::CTF_COMMAND_SET_SIGN_JOIN_BLUE_TEAM);
$sender->sendMessage($this->getMsg("ctf.setup.select"));
} elseif (strtolower($args[0]) == self::CTF_COMMAND_SET_SIGN_JOIN_RED_TEAM) {
if (!$sender->isOp()) {
$sender->sendMessage($this->getMsg("ctf.error.no-permission"));
return;
}
$this->getPlugIn()->setupModeAction = self::CTF_COMMAND_SET_SIGN_JOIN_RED_TEAM;
$sender->sendMessage($this->getMsg("ctf.setup.action") . self::CTF_COMMAND_SET_SIGN_JOIN_RED_TEAM);
$sender->sendMessage($this->getMsg("ctf.setup.select"));
} elseif (strtolower($args[0]) == self::CTF_COMMAND_SET_SIGN_NEW_GAME) {
if (!$sender->isOp()) {
$sender->sendMessage($this->getMsg("ctf.error.no-permission"));
return;
}
$this->getPlugIn()->setupModeAction = self::CTF_COMMAND_SET_SIGN_NEW_GAME;
$sender->sendMessage($this->getMsg("ctf.setup.action") . self::CTF_COMMAND_SET_SIGN_NEW_GAME);
$sender->sendMessage($this->getMsg("ctf.setup.select"));
} elseif (strtolower($args[0]) == self::CTF_COMMAND_SET_SIGN_VIEW_STATS) {
if (!$sender->isOp()) {
$sender->sendMessage($this->getMsg("ctf.error.no-permission"));
return;
}
$this->getPlugIn()->setupModeAction = self::CTF_COMMAND_SET_SIGN_VIEW_STATS;
$sender->sendMessage($this->getMsg("ctf.setup.action") . self::CTF_COMMAND_SET_SIGN_VIEW_STATS);
$sender->sendMessage($this->getMsg("ctf.setup.select"));
} elseif (strtolower($args[0]) == self::CTF_COMMAND_SETBLOCK_ID_TEAM_BORDER) {
if (!$sender->isOp()) {
//.........这里部分代码省略.........
示例7: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
switch ($command->getname()) {
case "sg":
$map1status = "nr";
$map2status = "nr";
$map3status = "nr";
$map4status = "nr";
$map5status = "nr";
$map1 = $this->getConfig()->get("name1");
$map2 = $this->getConfig()->get("name2");
$map3 = $this->getConfig()->get("name3");
$map4 = $this->getConfig()->get("name4");
$map5 = $this->getConfig()->get("name5");
$a = array("getstatus" => $map1status);
$b = array("getstatus" => $map2status);
$c = array("getstatus" => $map3status);
$d = array("getstatus" => $map4status);
$e = array("getstatus" => $map5status);
if (!isset($args[0])) {
// when client just performs /sg
$sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Please enter into a match " . "using /sg join.");
return true;
}
if ($args[0] === "join") {
// when client performs /sg join <match>
//defines all global array so that later functions can access array.
global $a;
global $b;
global $c;
global $d;
global $e;
if (!isset($args[1])) {
$sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " /sg join " . $map1);
$sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " /sg join " . $map2);
$sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " /sg join " . $map3);
$sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " /sg join " . $map4);
$sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " /sg join " . $map5);
return true;
}
if ($args[1] === $map1) {
$player = $sender->getName();
//sends all variable information into the datafolder.
$sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Transporting to map " . $map1);
//sets player into map list.
\array_push($a, $player);
if (Server::getInstance()->loadLevel($map1) != false) {
$sender->getPlayer()->teleport(Server::getInstance()->getLevelByName($map1)->getSafeSpawn());
$sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Please enter command /match1 register" . " to register into the match.");
include $this->getDataFolder() . "/" . "/required/" . "match1.php";
$str = fopen("match1pro.txt", "w");
$message = "nr";
\fwrite($str, $message);
foreach ($a as $player) {
$player = $this->getServer()->getPlayer($player);
$mapname = $this->getConfig()->get("name1");
if ($sender instanceof Player) {
$sender->sendMessage("Map 1 - '" . TEXTFORMAT::BLUE . $mapname . TEXTFORMAT::WHITE . "'");
}
}
return true;
} else {
//map doesn't exist, so tells the player there's an error.
$sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . "This" . " match is non-existant. Please check for errors.");
}
if ($args[1] === "map2") {
//gets player name and returns as $player
$player = $sender->getName();
//send player confirmation.
$player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Transport to map " . $map2);
//sets player into map list.
array_push($b, $player);
if (Server::getInstance()->loadLevel($map2) != false) {
$event->getPlayer()->teleport(Server::getInstance()->getLevelByName($map2)->getSafeSpawn());
return true;
} else {
$player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " That map is currently unavailable.");
return true;
}
}
if ($args[1] === "map3") {
//gets player name and returns as $player
$player = $sender->getName();
//send player confirmation.
$player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Transport to map " . $map3);
//sets player into map list.
array_push($c, $player);
if (Server::getInstance()->loadLevel($map3) != false) {
$event->getPlayer()->teleport(Server::getInstance()->getLevelByName($map3)->getSafeSpawn());
return true;
} else {
$player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " That map is currently unavailable.");
return true;
}
}
if ($args[1] === "map4") {
//gets player name and returns as $player
$player = $sender->getName();
//send player confirmation.
$player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Transport to map " . $map4);
//.........这里部分代码省略.........
示例8: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if ($sender instanceof Player) {
$ses = $this->plugin->getSession($sender->getPlayer());
//new
$player = $sender->getPlayer()->getName();
if (strtolower($command->getName('f'))) {
if (empty($args)) {
$sender->sendMessage($this->plugin->formatMessage("Please use /f help for a list of commands"));
return true;
}
if (count($args == 2)) {
/////////////////////////////// CREATE ///////////////////////////////
if ($args[0] == "create") {
if (!isset($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("Usage: /f create <faction name>"));
return true;
}
if (!ctype_alnum($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("You may only use letters and numbers!"));
return true;
}
if ($this->plugin->isNameBanned($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("This name is not allowed."));
return true;
}
if ($this->plugin->factionExists($args[1]) == true) {
$sender->sendMessage($this->plugin->formatMessage("Faction already exists"));
return true;
}
if (strlen($args[1]) > $this->plugin->prefs->get("MaxFactionNameLength")) {
$sender->sendMessage($this->plugin->formatMessage("This name is too long. Please try again!"));
return true;
}
if ($ses->inFaction()) {
$sender->sendMessage($this->plugin->formatMessage("You must leave this faction first"));
return true;
} else {
$factionName = $args[1];
$f = new Faction($this->plugin, $args[1], $sender->getPlayer());
//TODO: Split into two lines
$ses->updateFaction();
$sender->sendMessage($this->plugin->formatMessage("Faction successfully created!", true));
return true;
}
}
/////////////////////////////// INVITE ///////////////////////////////
if ($args[0] == "invite") {
if (!isset($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("Usage: /f invite <player>"));
return true;
}
if ($this->plugin->prefs->get("OnlyLeadersAndOfficersCanInvite") && !$ses->isLeader()) {
$sender->sendMessage($this->plugin->formatMessage("You are not allowed to invite."));
return true;
}
if ($ses->getFaction()->isFull()) {
$sender->sendMessage($this->plugin->formatMessage("Faction is full. Please kick players to make room."));
return true;
}
$invited = $this->plugin->getServer()->getPlayer($args[1]);
if (!$invited instanceof Player) {
$sender->sendMessage($this->plugin->formatMessage("Player not online!"));
return true;
}
if ($this->plugin->getSession($invited)->inFaction()) {
$sender->sendMessage($this->plugin->formatMessage("Player is currently in a faction"));
return true;
}
$invite = new FactionInvite($this->plugin->getSession($invited), $ses);
$sender->sendMessage($this->plugin->formatMessage($invited->getName() . " has been invited!", true));
$invited->sendMessage($this->plugin->formatMessage("You have been invited to " . $ses->getFaction()->getName() . ". Type '/f accept' or '/f deny' into chat to accept or deny!", true));
}
/////////////////////////////// LEADER ///////////////////////////////
if ($args[0] == "leader") {
if (!isset($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("Usage: /f leader <player>"));
return true;
}
if (!$ses->inFaction()) {
$sender->sendMessage($this->plugin->formatMessage("You must be in a faction to use this!"));
return true;
}
if (!$ses->isLeader()) {
$sender->sendMessage($this->plugin->formatMessage("You must be leader to use this"));
return true;
}
if ($ses->getFaction() != $this->plugin->getSession($this->plugin->getServer()->getPlayer($args[1]))->getFaction()) {
$sender->sendMessage($this->plugin->formatMessage("Player is not in your faction"));
return true;
}
if (!$this->plugin->getServer()->getPlayerExact($args[1]) instanceof Player) {
$sender->sendMessage($this->plugin->formatMessage("Player not online!"));
return true;
}
$newLeader = $this->plugin->getSession($this->plugin->getServer()->getPlayer($args[1]));
$ses->getFaction()->setRank($sender->getPlayer(), "Member");
$ses->getFaction()->setRank($newLeader->getPlayer(), "Leader");
//TODO: make setRank availble through session rather than faction?
$sender->sendMessage($this->plugin->formatMessage("You are no longer leader!", true));
//.........这里部分代码省略.........
示例9: onCommand
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($this->plugin->formatMessage("Please use /f help for a list of commands"));
return true;
}
if (count($args == 2)) {
/////////////////////////////// CREATE ///////////////////////////////
if ($args[0] == "create") {
if (!isset($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("Usage: /f create <faction name>"));
return true;
}
if (!ctype_alnum($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("You may only use letters and numbers!"));
return true;
}
if ($this->plugin->isNameBanned($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("This name is not allowed."));
return true;
}
if ($this->plugin->factionExists($args[1]) == true) {
$sender->sendMessage($this->plugin->formatMessage("Faction already exists"));
return true;
}
if (strlen($args[1]) > $this->plugin->prefs->get("MaxFactionNameLength")) {
$sender->sendMessage($this->plugin->formatMessage("This name is too long. Please try again!"));
return true;
}
if ($this->plugin->isInFaction($sender->getName())) {
$sender->sendMessage($this->plugin->formatMessage("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();
if ($this->plugin->prefs->get("FactionNametags")) {
$this->plugin->updateTag($player);
}
$sender->sendMessage($this->plugin->formatMessage("You've created the faction " . TextFormat::YELLOW . "{$factionName}" . TextFormat::DARK_GRAY . ".", true));
return true;
}
}
/////////////////////////////// INVITE ///////////////////////////////
if ($args[0] == "invite") {
if (!isset($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("Usage: /f invite <player>"));
return true;
}
if (!$this->plugin->isInFaction($player)) {
$sender->sendMessage($this->plugin->formatMessage("You must be in a faction to use this."));
return true;
}
if (!$this->plugin->isLeader($player) && !$this->plugin->hasPermission($player, "invite")) {
$sender->sendMessage($this->plugin->formatMessage("You do not have permission to do this!"));
return true;
}
if ($this->plugin->isFactionFull($this->plugin->getPlayerFaction($player))) {
$sender->sendMessage($this->plugin->formatMessage("Faction is full. Please kick players to make room with the command" . TextFormat::YELLOW . "/f kick <Player>" . TextFormat::DARK_GRAY . "."));
return true;
}
$invited = $this->plugin->getServer()->getPlayerExact($args[1]);
if ($this->plugin->isInFaction($invited) == true) {
$sender->sendMessage($this->plugin->formatMessage("That player is currently in a faction."));
return true;
}
if (!$invited instanceof Player) {
$sender->sendMessage($this->plugin->formatMessage("Player not online!"));
return 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($this->plugin->formatMessage("{$invitedName} has been invited!", true));
$invited->sendMessage($this->plugin->formatMessage("You have been invited to {$factionName}. Type '/f accept' or '/f deny' into chat to accept or deny!", true));
}
/////////////////////////////// LEADER ///////////////////////////////
if ($args[0] == "leader") {
if (!isset($args[1])) {
$sender->sendMessage($this->plugin->formatMessage("Usage: /f leader <player>"));
return true;
}
if (!$this->plugin->isInFaction($sender->getName())) {
$sender->sendMessage($this->plugin->formatMessage("You must be in a faction to use this!"));
return true;
}
//.........这里部分代码省略.........
示例10: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
$cmd = strtolower($command->getName());
if ($sender instanceof Player) {
$player = $sender->getPlayer();
switch ($cmd) {
case "qr":
$this->showusage($sender);
break;
case "qrt":
if (isset($args[0])) {
$url = $args[0];
$size = QRhelper::TestQRCode(true, $url);
$sender->sendMessage("QR panel for '{$url}' will need " . $size . "x" . $size . " blocks");
} else {
$this->showusage($sender);
}
break;
case "qrc":
if (isset($args[0])) {
$url = $args[0];
$orientation = isset($args[1]) ? strtolower($args[1]) : "a";
//a - auto
$allor = array("h", "v", "a");
if (!in_array($orientation, $allor)) {
$this->showusage($sender);
} else {
QRhelper::MarkPlayerCanCreateQR($this->pgin, $player, $url, $orientation);
}
} else {
$this->showusage($sender);
}
break;
case "qrl":
if (!isset($this->pgin->qrlist) || count($this->pgin->qrlist) == 0) {
$player->sendMessage("QR panels list is empty!");
} else {
$player->sendMessage("--------------");
$player->sendMessage("QR LIST");
$player->sendMessage("--------------");
foreach ($this->pgin->qrlist as $li) {
$liId = $li[0];
$liText = $li[1];
$liSize = $li[2];
$coord = $li[3];
$liCoord = "x:" . $coord[0] . "-y:" . $coord[1] . "-z:" . $coord[2];
//implode("-",$li[3]);
$player->sendMessage("[{$liId}] '{$liText}' ({$liSize}) {$liCoord}");
}
$player->sendMessage("--------------");
}
break;
case "qrd":
if (!isset($this->pgin->qrlist) || count($this->pgin->qrlist) == 0) {
$player->sendMessage("QR panel list is empty!");
} else {
if (isset($args[0])) {
$idToDelete = $args[0];
$wasDeleted = false;
foreach ($this->pgin->qrlist as $li) {
if ($idToDelete == $li[0]) {
//delete in world (fill with air)
$coord = $li[3];
QRhelper::FillWithAir($player->level, $coord);
//delete from file
unset($this->pgin->qrlist[array_search($li, $this->pgin->qrlist)]);
QRhelper::SaveQRlist($this->pgin);
$wasDeleted = true;
$player->sendMessage("QR panel [{$idToDelete}] deleted.");
break;
}
}
if (!$wasDeleted) {
$player->sendMessage("QR panel [{$idToDelete}] not found.");
}
} else {
$this->showusage($sender);
}
}
break;
case "qrp":
if (!isset($this->pgin->qrlist) || count($this->pgin->qrlist) == 0) {
$player->sendMessage("QR panel list is empty!");
} else {
if (isset($args[0])) {
$idToTP = $args[0];
$qrItem = null;
foreach ($this->pgin->qrlist as $li) {
if ($idToTP == $li[0]) {
$qrItem = $li;
}
}
if (isset($qrItem) && !is_null($qrItem)) {
//get qr code panel coords
$coord = $qrItem[3];
$coord[0] = $coord[0] - 2;
$coord[2] = $coord[2] - 2;
//tp playr
$player->teleport(new Vector3($coord[0], $coord[1], $coord[2]));
$player->sendMessage("You've been teleported nearby QR panel [{$idToTP}].");
//.........这里部分代码省略.........