Пример #1
0
 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
0
 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
0
 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);
 }
 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()) {
                         $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));
                     $newLeader->getPlayer()->sendMessage($this->plugin->formatMessage("You are now leader of " . $ses->getFaction()->getName() . "!", true));
                     $ses->updateTag();
                     $newLeader->updateTag();
                 }
                 /////////////////////////////// PROMOTE ///////////////////////////////
                 if ($args[0] == "promote") {
                     if ($this->plugin->commands->get("/f promote") == 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 promote <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()->hasPlayer_string($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is not in this faction!"));
                         return true;
                     }
                     $demoted = $this->plugin->getSessionFromName($args[1]);
                     if (strcmp($ses->getFaction()->getRank_string($args[1]), "Officer") == 0) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is already Officer"));
                         return true;
                     }
                     $ses->getFaction()->setRank_string($args[1], "Officer");
                     $sender->sendMessage($this->plugin->formatMessage("" . $args[1] . " has been promoted to Officer.", true));
                     if (!$promoted == false) {
                         $demoted->getPlayer()->sendMessage($this->plugin->formatMessage("You were Promoted to Officer.", true));
                         $promoted->updateRank();
                         $promoted->updateTag();
                     }
                 }
                 /////////////////////////////// DEMOTE ///////////////////////////////
                 if ($args[0] == "demote") {
                     if ($this->plugin->commands->get("/f demote") == 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 demote <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()->hasPlayer_string($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is not in this faction!"));
                         return true;
                     }
                     $demoted = $this->plugin->getSessionFromName($args[1]);
                     if (strcmp($ses->getFaction()->getRank_string($args[1]), "Officer") != 0) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is already Member"));
                         return true;
                     }
                     $ses->getFaction()->setRank_string($args[1], "Member");
                     $sender->sendMessage($this->plugin->formatMessage("" . $args[1] . " has been demoted to Member.", true));
                     if (!$demoted == false) {
                         $demoted->getPlayer()->sendMessage($this->plugin->formatMessage("You were demoted to Member.", true));
                         $demoted->updateRank();
                         $demoted->updateTag();
                     }
                 }
                 /////////////////////////////// KICK ///////////////////////////////
                 //TODO: what if kicked is offline??
                 if ($args[0] == "kick") {
                     if ($this->plugin->commands->get("/f kick") == 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 kick <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()->hasPlayer_string($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is not in this faction!"));
                         return true;
                     }
                     if (strtolower($ses->getPlayer()->getName()) == strtolower($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("You may not kick yourself. Use /f leave or /f del instead."));
                         return true;
                     }
                     $ses->getFaction()->removePlayer_string($args[1]);
                     $sender->sendMessage($this->plugin->formatMessage("You successfully kicked {$args['1']}!", true));
                     $players[] = $this->plugin->getServer()->getOnlinePlayers();
                     if ($this->plugin->getServer()->getPlayer($args[1]) instanceof Player) {
                         $factionName = $ses->getFaction()->getName();
                         $this->plugin->getServer()->getPlayer($args[1])->sendMessage($this->plugin->formatMessage("You have been kicked from \n {$factionName}.", true));
                         $this->plugin->getSession($this->plugin->getServer()->getPlayer($args[1]))->updateFaction();
                         $this->plugin->getSession($this->plugin->getServer()->getPlayer($args[1]))->updateTag();
                         return true;
                     }
                 }
                 /////////////////////////////// DESC ///////////////////////////////
                 if (strtolower($args[0]) == "desc") {
                     if ($this->plugin->commands->get("/f desc") == 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 (!$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;
                     }
                     $desc = "";
                     for ($i = 0; $i < count($args) - 1; $i++) {
                         if ($i == 0) {
                             $desc = $args[$i + 1];
                         } else {
                             $desc = $desc . " " . $args[$i + 1];
                         }
                     }
                     $ses->getFaction()->setDescription($desc);
                     $sender->sendMessage(TextFormat::GREEN . "Updated description to: " . TextFormat::WHITE . $desc);
                 }
                 /////////////////////////////// INFO ///////////////////////////////
                 if (strtolower($args[0]) == 'info') {
                     if ($this->plugin->commands->get("/f info") == 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])) {
                         if (!ctype_alnum($args[1]) | !$this->plugin->factionExists($args[1])) {
                             $sender->sendMessage($this->plugin->formatMessage("Faction does not exist"));
                             return true;
                         }
                         $faction = $this->plugin->getFaction($args[1])->getName();
                         $leader = $this->plugin->getFaction($args[1])->getLeader();
                         $numPlayers = $this->plugin->getFaction($args[1])->getNumberMembers();
                         $sender->sendMessage(TextFormat::BOLD . TextFormat::BLUE . "------[ " . TextFormat::GOLD . $faction . TextFormat::BLUE . " ]------");
                         $sender->sendMessage(TextFormat::BOLD . TextFormat::BLUE . "Description: " . TextFormat::RESET . TextFormat::WHITE . "{$desc}");
                         $sender->sendMessage(TextFormat::BOLD . TextFormat::BLUE . "Leader: " . TextFormat::RESET . TextFormat::WHITE . "{$leader}");
                         $sender->sendMessage(TextFormat::BOLD . TextFormat::BLUE . "# of Players: " . TextFormat::RESET . TextFormat::WHITE . "{$numPlayers}");
                     } else {
                         $faction = $ses->getFaction()->getName();
                         $desc = $ses->getFaction()->getDescription();
                         $leader = $ses->getFaction()->getLeader();
                         $numPlayers = $ses->getFaction()->getNumberMembers();
                         $sender->sendMessage(TextFormat::BOLD . TextFormat::BLUE . "------[ " . TextFormat::GOLD . $faction . TextFormat::BLUE . " ]------");
                         $sender->sendMessage(TextFormat::BOLD . TextFormat::BLUE . "Description: " . TextFormat::RESET . TextFormat::WHITE . "{$desc}");
                         $sender->sendMessage(TextFormat::BOLD . TextFormat::BLUE . "Leader: " . TextFormat::RESET . TextFormat::WHITE . "{$leader}");
                         $sender->sendMessage(TextFormat::BOLD . TextFormat::BLUE . "# of Players: " . TextFormat::RESET . TextFormat::WHITE . "{$numPlayers}");
                     }
                 }
                 /////////////////////////////// HOME ///////////////////////////////
                 if (strtolower($args[0] == "home")) {
                     if ($this->plugin->commands->get("/f home") == 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 (!$ses->inFaction()) {
                         $sender->sendMessage($this->plugin->formatMessage("You must be in a faction to do this."));
                     }
                     if (isset($args[1]) && strtolower($args[1] == "set")) {
                         if (!$ses->isLeader()) {
                             $sender->sendMessage($this->plugin->formatMessage("You must be leader to set home."));
                             return true;
                         }
                         $ses->getFaction()->setHome($sender->getPlayer()->getPosition());
                         $sender->sendMessage($this->plugin->formatMessage("Home updated!", true));
                         return true;
                     }
                     if (isset($args[1]) && strtolower($args[1] == "unset")) {
                         if (!$ses->isLeader()) {
                             $sender->sendMessage($this->plugin->formatMessage("You must be leader to set home."));
                             return true;
                         }
                         $ses->getFaction()->unsetHome();
                         $sender->sendMessage($this->plugin->formatMessage("Home has been unset.", true));
                         return true;
                     }
                     if ($ses->getFaction()->hasHome()) {
                         $sender->getPlayer()->teleport($ses->getFaction()->getHome());
                         $sender->sendMessage($this->plugin->formatMessage("Teleported home.", true));
                         return true;
                     } else {
                         $sender->sendMessage($this->plugin->formatMessage("Home is not set."));
                     }
                 }
                 if (strtolower($args[0]) == "help") {
                     if (!isset($args[1]) || $args[1] == 1) {
                         $sender->sendMessage(TextFormat::BLUE . "FactionsPro Help Page 1 of 2" . TextFormat::RED . "\n/f about\n\t\t\t\t\t\t\t\t\t\n/f accept\n\t\t\t\t\t\t\t\t\t\n/f create <name>\n\t\t\t\t\t\t\t\t\t\n/f del\n\t\t\t\t\t\t\t\t\t\n/f demote <player>\n\t\t\t\t\t\t\t\t\t\n/f deny\n\t\t\t\t\t\t\t\t\t\n/f desc <description>");
                         return true;
                     }
                     if ($args[1] == 2) {
                         $sender->sendMessage(TextFormat::BLUE . "FactionsPro Help Page 2 of 2" . TextFormat::RED . "\n/f home <set/unset>\n\t\t\t\t\t\t\t\t\t\n/f help <page>\n\t\t\t\t\t\t\t\t\t\n/f info <faction>\n\t\t\t\t\t\t\t\t\t\n/f invite <player>\n\t\t\t\t\t\t\t\t\t\n/f kick <player>\n\t\t\t\t\t\t\t\t\t\n/f leader <player>\n\t\t\t\t\t\t\t\t\t\n/f leave\n\t\t\t\t\t\t\t\t\t\n/f promote <player>");
                         return true;
                     }
                 }
             }
             if (count($args == 1)) {
                 /////////////////////////////// ACCEPT ///////////////////////////////
                 if (strtolower($args[0]) == "accept") {
                     if (!$ses->hasInvite()) {
                         $sender->sendMessage($this->plugin->formatMessage("You have not been invited to any factions!"));
                         return true;
                     }
                     if ($ses->getInvite()->getTimeout() <= time()) {
                         $sender->sendMessage($this->plugin->formatMessage("Invite has timed out!"));
                         $ses->deregisterInvite();
                         return true;
                     }
                     $ses->joinFaction($ses->getInvite()->getFaction());
                     $sender->sendMessage($this->plugin->formatMessage("You successfully joined " . $ses->getFaction()->getName() . "!", true));
                     if ($ses->getInvite()->getInvitedby() instanceof Player) {
                         $ses->getInvite()->getInvitedby()->sendMessage($this->plugin->formatMessage($sender->getPlayer()->getName() . " joined the faction!", true));
                     }
                     $ses->updateTag();
                     $ses->deregisterInvite();
                 }
                 /////////////////////////////// DENY ///////////////////////////////
                 if (strtolower($args[0]) == "deny") {
                     if (!$ses->hasInvite()) {
                         $sender->sendMessage($this->plugin->formatMessage("You have not been invited to any factions!"));
                         return true;
                     }
                     if ($ses->getInvite()->getTimeout() <= time()) {
                         $sender->sendMessage($this->plugin->formatMessage("Invite has timed out!"));
                         $ses->deregisterInvite();
                         return true;
                     }
                     $sender->sendMessage($this->plugin->formatMessage("Invite declined."));
                     if ($ses->getInvite()->getInvitedby() instanceof Player) {
                         $ses->getInvite()->getInvitedby()->sendMessage($this->plugin->formatMessage($sender->getPlayer()->getName() . " declined your invite."));
                     }
                     $ses->deregisterInvite();
                 }
                 /////////////////////////////// DELETE ///////////////////////////////
                 if (strtolower($args[0]) == "del") {
                     if ($this->plugin->commands->get("/f delete") == 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 (!$ses->inFaction()) {
                         $sender->sendMessage($this->plugin->formatMessage("You are not in a faction!"));
                     }
                     if (!$ses->isLeader()) {
                         $sender->sendMessage($this->plugin->formatMessage("You are not leader!"));
                     }
                     $ses->getFaction()->delete();
                     $sender->sendMessage($this->plugin->formatMessage("Faction successfully disbanded!", true));
                     $ses->updateTag();
                 }
                 /////////////////////////////// LEAVE ///////////////////////////////
                 if (strtolower($args[0] == "leave")) {
                     if ($this->plugin->commands->get("/f leave") == 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 (!$ses->isLeader()) {
                         $faction = $ses->getFaction()->getName();
                         $ses->leaveFaction();
                         $sender->sendMessage($this->plugin->formatMessage("You successfully left {$faction}", true));
                         $ses->updateTag();
                     } else {
                         $sender->sendMessage($this->plugin->formatMessage("You must delete or give\nleadership first!"));
                     }
                 }
                 /////////////////////////////// ABOUT ///////////////////////////////
                 if (strtolower($args[0] == 'about')) {
                     $sender->sendMessage(TextFormat::BLUE . "FactionsPro v1.5b3 by " . TextFormat::BOLD . "Tethered_\n" . TextFormat::RESET . TextFormat::BLUE . "Twitter: " . TextFormat::ITALIC . "@Tethered_");
                 }
             }
         } else {
             $this->plugin->getServer()->getLogger()->info($this->plugin->formatMessage("Please run command in game"));
         }
     }
 }
Пример #5
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");
     }
 }
 /**
  * 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()) {
                 $sender->sendMessage($this->getMsg("ctf.error.no-permission"));
                 return;
             }
             $this->getPlugIn()->setupModeAction = self::CTF_COMMAND_SETBLOCK_ID_TEAM_BORDER;
             $sender->sendMessage($this->getMsg("ctf.setup.action") . self::CTF_COMMAND_SETBLOCK_ID_TEAM_BORDER);
             $sender->sendMessage($this->getMsg("ctf.setup.select"));
         } elseif (strtolower($args[0]) == self::CTF_COMMAND_SETBLOCK_ID_DEFENCE_WALL_BLUE_TEAM) {
             if (!$sender->isOp()) {
                 $sender->sendMessage($this->getMsg("ctf.error.no-permission"));
                 return;
             }
             $this->getPlugIn()->setupModeAction = self::CTF_COMMAND_SETBLOCK_ID_DEFENCE_WALL_BLUE_TEAM;
             $sender->sendMessage($this->getMsg("ctf.setup.action") . self::CTF_COMMAND_SETBLOCK_ID_DEFENCE_WALL_BLUE_TEAM);
             $sender->sendMessage($this->getMsg("ctf.setup.select"));
         } elseif (strtolower($args[0]) == self::CTF_COMMAND_SETBLOCK_ID_DEFENCE_WALL_RED_TEAM) {
             if (!$sender->isOp()) {
                 $sender->sendMessage($this->getMsg("ctf.error.no-permission"));
                 return;
             }
             $this->getPlugIn()->setupModeAction = self::CTF_COMMAND_SETBLOCK_ID_DEFENCE_WALL_RED_TEAM;
             $sender->sendMessage($this->getMsg("ctf.setup.action") . self::CTF_COMMAND_SETBLOCK_ID_DEFENCE_WALL_RED_TEAM);
             $sender->sendMessage($this->getMsg("ctf.setup.select"));
         }
     }
 }
Пример #7
0
 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);
                         //sets player into map list.
                         array_push($d, $player);
                         if (Server::getInstance()->loadLevel($map4) != false) {
                             $event->getPlayer()->teleport(Server::getInstance()->getLevelByName($map4)->getSafeSpawn());
                             include 'SGPro/tasks/match1.php';
                             return true;
                         } else {
                             $player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " That map is currently unavailable.");
                             return true;
                         }
                     }
                     if ($args[1] === "map5") {
                         //gets player name and returns as $player
                         $player = $sender->getName();
                         //send player confirmation.
                         $player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Transport to map " . $map5);
                         //sets player into map list.
                         array_push($e, $player);
                         if (Server::getInstance()->loadLevel($map5) != false) {
                             $event->getPlayer()->teleport(Server::getInstance()->getLevelByName($map5)->getSafeSpawn());
                             return true;
                         } else {
                             $player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " That map is currently unavailable.");
                             return true;
                         }
                     }
                 }
             }
         case "match1":
             if (!isset($args[0])) {
                 $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . "That is not valid.");
             }
             if ($args[0] === "register") {
                 $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " You have been registered into the match.");
                 $status = file_get_contents("match1pro.txt");
                 if ($status === "nr") {
                     $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " This round is not ready yet. Please hold on.");
                     return true;
                 } elseif ($status === "sr") {
                     $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " This round is halfway until showdown!");
                     return true;
                 } elseif ($status === "r") {
                     $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " This round is about to go underway!");
                     return true;
                 }
                 foreach ($a as $player) {
                     $player = $this->getServer()->getPlayer($player);
                     $server = $sender->getName();
                     $mapname = $this->getConfig()->get("name1");
                     if ($sender instanceof Player) {
                         $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " New player " . TEXTFORMAT::RED . $server . " has joined the match.");
                     }
                 }
             }
             return true;
     }
 }
Пример #8
0
 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));
                     $newLeader->getPlayer()->sendMessage($this->plugin->formatMessage("You are now leader of " . $ses->getFaction()->getName() . "!", true));
                     $ses->updateTag();
                     $newLeader->updateTag();
                 }
                 /////////////////////////////// PROMOTE ///////////////////////////////
                 if ($args[0] == "promote") {
                     if (!isset($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Usage: /f promote <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 this faction!"));
                         return true;
                     }
                     if ($this->plugin->getSession($this->plugin->getServer()->getPlayer($args[1]))->isOfficer()) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is already Officer"));
                         return true;
                     }
                     $promoted = $this->plugin->getSession($this->plugin->getServer()->getPlayer($args[1]));
                     $ses->getFaction()->setRank($promoted->getPlayer(), "Officer");
                     $sender->sendMessage($this->plugin->formatMessage("" . $promoted->getPlayer()->getName() . " has been promoted to Officer!", true));
                     $promoted->getPlayer()->sendMessage($this->plugin->formatMessage("You are now Officer!", true));
                     $promoted->updateRank();
                     $promoted->updateTag();
                 }
                 /////////////////////////////// DEMOTE ///////////////////////////////
                 if ($args[0] == "demote") {
                     if (!isset($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Usage: /f demote <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;
                     }
                     $demoted = $this->plugin->getSession($this->plugin->getServer()->getPlayer($args[1]));
                     if ($ses->getFaction() != $demoted->getFaction()) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is not in this faction!"));
                         return true;
                     }
                     if (!$demoted->isOfficer()) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is already Member"));
                         return true;
                     }
                     $demoted->getFaction()->setRank($demoted->getPlayer(), "Member");
                     $sender->sendMessage($this->plugin->formatMessage("" . $demoted->getPlayer()->getName() . " has been demoted to Member.", true));
                     $demoted->getPlayer()->sendMessage($this->plugin->formatMessage("You were demoted to Member.", true));
                     $demoted->updateRank();
                     $demoted->updateTag();
                 }
                 /////////////////////////////// KICK ///////////////////////////////
                 //TODO: what if kicked is offline??
                 if ($args[0] == "kick") {
                     if (!isset($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Usage: /f kick <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()->hasPlayer_string($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is not in this faction!"));
                         return true;
                     }
                     if (strtolower($ses->getPlayer()->getName()) == strtolower($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("You may not kick yourself. Use /f leave or /f del instead."));
                         return true;
                     }
                     $ses->getFaction()->removePlayer_string($args[1]);
                     $sender->sendMessage($this->plugin->formatMessage("You successfully kicked {$args['1']}!", true));
                     $players[] = $this->plugin->getServer()->getOnlinePlayers();
                     if ($this->plugin->getServer()->getPlayer($args[1]) instanceof Player) {
                         $factionName = $ses->getFaction()->getName();
                         $this->plugin->getServer()->getPlayer($args[1])->sendMessage($this->plugin->formatMessage("You have been kicked from \n {$factionName}.", true));
                         $this->plugin->getSession($this->plugin->getServer()->getPlayer($args[1]))->updateFaction();
                         $this->plugin->getSession($this->plugin->getServer()->getPlayer($args[1]))->updateTag();
                         return true;
                     }
                 }
                 /////////////////////////////// INFO ///////////////////////////////
                 /*
                 					if(strtolower($args[0]) == 'info') {
                 						if(isset($args[1])) {
                 							if( !(ctype_alnum($args[1])) | !($this->plugin->factionExists($args[1]))) {
                 								$sender->sendMessage($this->plugin->formatMessage("Faction does not exist"));
                 								return true;
                 							}
                 							$faction = strtolower($args[1]);
                 							$leader = $this->plugin->getLeader($faction);
                 							$numPlayers = $this->plugin->getNumberOfPlayers($faction);
                 							$sender->sendMessage(TextFormat::BOLD . "-------------------------");
                 							$sender->sendMessage("$faction");
                 							$sender->sendMessage(TextFormat::BOLD . "Leader: " . TextFormat::RESET . "$leader");
                 							$sender->sendMessage(TextFormat::BOLD . "# of Players: " . TextFormat::RESET . "$numPlayers");
                 							$sender->sendMessage(TextFormat::BOLD . "MOTD: " . TextFormat::RESET . "$message");
                 							$sender->sendMessage(TextFormat::BOLD . "-------------------------");
                 						} 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(TextFormat::BOLD . "-------------------------");
                 							$sender->sendMessage("$faction");
                 							$sender->sendMessage(TextFormat::BOLD . "Leader: " . TextFormat::RESET . "$leader");
                 							$sender->sendMessage(TextFormat::BOLD . "# of Players: " . TextFormat::RESET . "$numPlayers");
                 							$sender->sendMessage(TextFormat::BOLD . "MOTD: " . TextFormat::RESET . "$message");
                 							$sender->sendMessage(TextFormat::BOLD . "-------------------------");
                 						}
                 					}
                 					if(strtolower($args[0]) == "help") {
                 						if(!isset($args[1]) || $args[1] == 1) {
                 							$sender->sendMessage(TextFormat::BLUE . "FactionsPro Help Page 1 of 3" . TextFormat::RED . "\n/f about\n/f accept\n/f claim\n/f create <name>\n/f del\n/f demote <player>\n/f deny");
                 							return true;
                 						}
                 						if($args[1] == 2) {
                 							$sender->sendMessage(TextFormat::BLUE . "FactionsPro Help Page 2 of 3" . TextFormat::RED . "\n/f home\n/f help <page>\n/f info\n/f info <faction>\n/f invite <player>\n/f kick <player>\n/f leader <player>\n/f leave");
                 							return true;
                 						} else {
                 							$sender->sendMessage(TextFormat::BLUE . "FactionsPro Help Page 3 of 3" . TextFormat::RED . "\n/f motd\n/f promote <player>\n/f sethome\n/f unclaim\n/f unsethome");
                 							return true;
                 						}
                 					}
                 				}
                 				if(count($args == 1)) {
                 					
                 					/////////////////////////////// CLAIM ///////////////////////////////
                 					
                 					if(strtolower($args[0]) == 'claim') {
                 						if($this->plugin->prefs->get("ClaimingEnabled") == "false") {
                 							$sender->sendMessage($this->plugin->formatMessage("Plots are not enabled on this server."));
                 							return true;
                 						}
                 						if($this->plugin->claimingIsDisabled($sender->getPlayer()->getLevel()))
                 						{
                 							$sender->sendMessage($this->plugin->formatMessage("You may not claim here"));
                 							return true;
                 						}
                 						if(!$this->plugin->getSession($sender->getPlayer())->inFaction()) {
                 							$sender->sendMessage($this->plugin->formatMessage("You must be in a faction."));
                 							return true;
                 						}
                 						if($this->plugin->prefs->get("OfficersCanClaim") == "false" && $this->plugin->isOfficer($sender->getName())) {
                 							$sender->sendMessage($this->plugin->formatMessage("You are not allowed to claim."));
                 							return true;
                 						}
                 						if(!$this->plugin->isLeader($player)) {
                 							$sender->sendMessage($this->plugin->formatMessage("You must be leader to use this."));
                 							return true;
                 						}
                 						if($this->plugin->inOwnPlot($sender)) {
                 							$sender->sendMessage($this->plugin->formatMessage("Your faction has already claimed this area."));
                 							return true;
                 						}
                 						$x = floor($sender->getX());
                 						$y = floor($sender->getY());
                 						$z = floor($sender->getZ());
                 						$faction = $this->plugin->getPlayerFaction($sender->getPlayer()->getName());
                 						if($this->plugin->drawPlot($sender, $faction, $x, $y, $z, $sender->getPlayer()->getLevel(), $this->plugin->prefs->get("PlotSize")) == false) {
                 							return true;
                 						}
                 						$sender->sendMessage($this->plugin->formatMessage("Plot claimed.", true));
                 					}
                 					
                 					/////////////////////////////// UNCLAIM ///////////////////////////////
                 					
                 					if(strtolower($args[0]) == "unclaim") {
                 						if($this->plugin->prefs->get("ClaimingEnabled") == "false") {
                 							$sender->sendMessage($this->plugin->formatMessage("Plots are not enabled on this server."));
                 							return true;
                 						}
                 						if(!$this->plugin->isLeader($sender->getName())) {
                 							$sender->sendMessage($this->plugin->formatMessage("You must be leader to use this."));
                 							return true;
                 						}
                 						$faction = $this->plugin->getPlayerFaction($sender->getName());
                 						$this->plugin->db->query("DELETE FROM plots WHERE faction='$faction';");
                 						$sender->sendMessage($this->plugin->formatMessage("Plot unclaimed.", true));
                 					}
                 					
                 					/////////////////////////////// MOTD ///////////////////////////////
                 					
                 					if(strtolower($args[0]) == "motd") {
                 						if(!$this->plugin->getSession($sender->getPlayer())->inFaction()) {
                 							$sender->sendMessage($this->plugin->formatMessage("You must be in a faction to use this!"));
                 							return true;
                 						}
                 						if($this->plugin->isLeader($player) == false) {
                 							$sender->sendMessage($this->plugin->formatMessage("You must be leader to use this"));
                 							return true;
                 						}
                 						$sender->sendMessage($this->plugin->formatMessage("Type your message in chat. It will not be visible to other players", true));
                 						$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") {
                     if (!$ses->hasInvite()) {
                         $sender->sendMessage($this->plugin->formatMessage("You have not been invited to any factions!"));
                         return true;
                     }
                     if ($ses->getInvite()->getTimeout() <= time()) {
                         $sender->sendMessage($this->plugin->formatMessage("Invite has timed out!"));
                         $ses->deregisterInvite();
                         return true;
                     }
                     $ses->joinFaction($ses->getInvite()->getFaction());
                     $sender->sendMessage($this->plugin->formatMessage("You successfully joined " . $ses->getFaction()->getName() . "!", true));
                     if ($ses->getInvite()->getInvitedby() instanceof Player) {
                         $ses->getInvite()->getInvitedby()->sendMessage($this->plugin->formatMessage($sender->getPlayer()->getName() . " joined the faction!", true));
                     }
                     $ses->updateTag();
                     $ses->deregisterInvite();
                 }
                 /////////////////////////////// DENY ///////////////////////////////
                 if (strtolower($args[0]) == "deny") {
                     if (!$ses->hasInvite()) {
                         $sender->sendMessage($this->plugin->formatMessage("You have not been invited to any factions!"));
                         return true;
                     }
                     if ($ses->getInvite()->getTimeout() <= time()) {
                         $sender->sendMessage($this->plugin->formatMessage("Invite has timed out!"));
                         $ses->deregisterInvite();
                         return true;
                     }
                     $sender->sendMessage($this->plugin->formatMessage("Invite declined."));
                     if ($ses->getInvite()->getInvitedby() instanceof Player) {
                         $ses->getInvite()->getInvitedby()->sendMessage($this->plugin->formatMessage($sender->getPlayer()->getName() . " declined your invite."));
                     }
                     $ses->deregisterInvite();
                 }
                 /////////////////////////////// DELETE ///////////////////////////////
                 if (strtolower($args[0]) == "del") {
                     if (!$ses->inFaction()) {
                         $sender->sendMessage($this->plugin->formatMessage("You are not in a faction!"));
                     }
                     if (!$ses->isLeader()) {
                         $sender->sendMessage($this->plugin->formatMessage("You are not leader!"));
                     }
                     $ses->getFaction()->delete();
                     $sender->sendMessage($this->plugin->formatMessage("Faction successfully disbanded!", true));
                     $ses->updateTag();
                 }
                 /////////////////////////////// LEAVE ///////////////////////////////
                 if (strtolower($args[0] == "leave")) {
                     if (!$ses->isLeader()) {
                         $faction = $ses->getFaction()->getName();
                         $ses->leaveFaction();
                         $sender->sendMessage($this->plugin->formatMessage("You successfully left {$faction}", true));
                         $ses->updateTag();
                     } else {
                         $sender->sendMessage($this->plugin->formatMessage("You must delete or give\nleadership first!"));
                     }
                 }
                 /////////////////////////////// SETHOME ///////////////////////////////
                 /*
                 if(strtolower($args[0] == "sethome")) {
                 	if(!$this->plugin->getSession($sender->getPlayer())->inFaction()) {
                 		$sender->sendMessage($this->plugin->formatMessage("You must be in a faction to do this."));
                 		return true;
                 	}
                 	if(!$this->plugin->isLeader($player)) {
                 		$sender->sendMessage($this->plugin->formatMessage("You must be leader to set home."));
                 		return true;
                 	}
                 	$factionName = $this->plugin->getPlayerFaction($sender->getName());
                 	$stmt = $this->plugin->db->prepare("INSERT OR REPLACE INTO home (faction, x, y, z) VALUES (:faction, :x, :y, :z);");
                 	$stmt->bindValue(":faction", $factionName);
                 	$stmt->bindValue(":x", $sender->getX());
                 	$stmt->bindValue(":y", $sender->getY());
                 	$stmt->bindValue(":z", $sender->getZ());
                 	$result = $stmt->execute();
                 	$sender->sendMessage($this->plugin->formatMessage("Home updated!", true));
                 }
                 
                 /////////////////////////////// UNSETHOME ///////////////////////////////
                 	
                 if(strtolower($args[0] == "unsethome")) {
                 	if(!$this->plugin->getSession($sender->getPlayer())->inFaction()) {
                 		$sender->sendMessage($this->plugin->formatMessage("You must be in a faction to do this."));
                 		return true;
                 	}
                 	if(!$this->plugin->isLeader($player)) {
                 		$sender->sendMessage($this->plugin->formatMessage("You must be leader to unset home."));
                 		return true;
                 	}
                 	$faction = $this->plugin->getPlayerFaction($sender->getName());
                 	$this->plugin->db->query("DELETE FROM home WHERE faction = '$faction';");
                 	$sender->sendMessage($this->plugin->formatMessage("Home unset!", true));
                 }
                 
                 /////////////////////////////// HOME ///////////////////////////////
                 	
                 if(strtolower($args[0] == "home")) {
                 	if(!$this->plugin->getSession($sender->getPlayer())->inFaction()) {
                 		$sender->sendMessage($this->plugin->formatMessage("You must be in a faction to do this."));
                 	}
                 	$faction = $this->plugin->getPlayerFaction($sender->getName());
                 	$result = $this->plugin->db->query("SELECT * FROM home WHERE faction = '$faction';");
                 	$array = $result->fetchArray(SQLITE3_ASSOC);
                 	if(!empty($array)) {
                 		$sender->getPlayer()->teleport(new Vector3($array['x'], $array['y'], $array['z']));
                 		$sender->sendMessage($this->plugin->formatMessage("Teleported home.", true));
                 		return true;
                 	} else {
                 		$sender->sendMessage($this->plugin->formatMessage("Home is not set."));
                 		}
                 	}
                 */
                 /////////////////////////////// ABOUT ///////////////////////////////
                 if (strtolower($args[0] == 'about')) {
                     $sender->sendMessage(TextFormat::BLUE . "FactionsPro v1.5b1 by " . TextFormat::BOLD . "Tethered_\n" . TextFormat::RESET . TextFormat::BLUE . "Twitter: " . TextFormat::ITALIC . "@Tethered_");
                 }
             }
         }
     } else {
         $this->plugin->getServer()->getLogger()->info($this->plugin->formatMessage("Please run command in game"));
     }
 }
Пример #9
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($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;
                     }
                     if (!$this->plugin->isLeader($player)) {
                         $sender->sendMessage($this->plugin->formatMessage("You must be leader to use this"));
                         return true;
                     }
                     if ($this->plugin->getPlayerFaction($player) != $this->plugin->getPlayerFaction($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Add player to faction first!"));
                         return true;
                     }
                     if (!$this->plugin->getServer()->getPlayerExact($args[1]) instanceof Player) {
                         $sender->sendMessage($this->plugin->formatMessage("Player not online!"));
                         return 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($this->plugin->formatMessage("You are no longer leader!", true));
                     $this->plugin->getServer()->getPlayer($args[1])->sendMessage($this->plugin->formatMessage("You are now leader \nof {$factionName}!", true));
                     if ($this->plugin->prefs->get("FactionNametags")) {
                         $this->plugin->updateTag($sender->getName());
                         $this->plugin->updateTag($this->plugin->getServer()->getPlayer($args[1])->getName());
                     }
                 }
                 /////////////////////////////// PROMOTE ///////////////////////////////
                 if ($args[0] == "promote") {
                     if (!isset($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Usage: /f promote <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;
                     }
                     if (!$this->plugin->isLeader($player) && !$this->plugin->hasPermission($player, "promote")) {
                         $sender->sendMessage($this->plugin->formatMessage("You do not have permission to do this"));
                         return true;
                     }
                     if ($this->plugin->getPlayerFaction($player) != $this->plugin->getPlayerFaction($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is not in this faction!"));
                         return true;
                     }
                     if ($this->plugin->isOfficer($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is already Officer"));
                         return true;
                     }
                     $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", strtolower($args[1]));
                     $stmt->bindValue(":faction", $factionName);
                     $stmt->bindValue(":rank", "Officer");
                     $result = $stmt->execute();
                     $player = $args[1];
                     $sender->sendMessage($this->plugin->formatMessage("" . $player . " has been promoted to Officer!", true));
                     if ($player = $this->plugin->getServer()->getPlayer($args[1])) {
                         $player->sendMessage($this->plugin->formatMessage("You are now Officer!", true));
                     }
                     if ($this->plugin->prefs->get("FactionNametags")) {
                         $this->plugin->updateTag($player->getName());
                     }
                 }
                 /////////////////////////////// DEMOTE ///////////////////////////////
                 if ($args[0] == "demote") {
                     if (!isset($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Usage: /f demote <player>"));
                         return true;
                     }
                     if ($this->plugin->isInFaction($sender->getName()) == false) {
                         $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, "demote")) {
                         $sender->sendMessage($this->plugin->formatMessage("You do not have permission to do this"));
                         return true;
                     }
                     if ($this->plugin->getPlayerFaction($player) != $this->plugin->getPlayerFaction($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is not in this faction!"));
                         return true;
                     }
                     if (!$this->plugin->isOfficer($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is already Member"));
                         return true;
                     }
                     $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", strtolower($args[1]));
                     $stmt->bindValue(":faction", $factionName);
                     $stmt->bindValue(":rank", "Member");
                     $result = $stmt->execute();
                     $player = $args[1];
                     $sender->sendMessage($this->plugin->formatMessage("" . $player . " has been demoted to Member.", true));
                     if ($player = $this->plugin->getServer()->getPlayer($args[1])) {
                         $player->sendMessage($this->plugin->formatMessage("You were demoted to Member.", true));
                     }
                     if ($this->plugin->prefs->get("FactionNametags")) {
                         $this->plugin->updateTag($player->getName());
                     }
                 }
                 /////////////////////////////// KICK ///////////////////////////////
                 if ($args[0] == "kick") {
                     if (!isset($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Usage: /f kick <player>"));
                         return true;
                     }
                     if ($this->plugin->isInFaction($sender->getName()) == false) {
                         $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, "kick")) {
                         $sender->sendMessage($this->plugin->formatMessage("You do not have permission to do this"));
                         return true;
                     }
                     if ($this->plugin->getPlayerFaction($player) != $this->plugin->getPlayerFaction($args[1])) {
                         $sender->sendMessage($this->plugin->formatMessage("Player is not in this faction!"));
                         return true;
                     }
                     $kicked = $this->plugin->getServer()->getPlayer($args[1]);
                     $factionName = $this->plugin->getPlayerFaction($player);
                     $this->plugin->db->query("DELETE FROM master WHERE player='{$args['1']}';");
                     $sender->sendMessage($this->plugin->formatMessage("You successfully kicked {$args['1']}!", true));
                     $players[] = $this->plugin->getServer()->getOnlinePlayers();
                     if (in_array($args[1], $players) == true) {
                         $this->plugin->getServer()->getPlayer($args[1])->sendMessage($this->plugin->formatMessage("You have been kicked from \n {$factionName}!", true));
                         if ($this->plugin->prefs->get("FactionNametags")) {
                             $this->plugin->updateTag($args[1]);
                         }
                         return true;
                     }
                 }
                 /////////////////////////////// INFO ///////////////////////////////
                 if (strtolower($args[0]) == 'info') {
                     if (isset($args[1])) {
                         if (!ctype_alnum($args[1]) | !$this->plugin->factionExists($args[1])) {
                             $sender->sendMessage($this->plugin->formatMessage("Faction does not exist"));
                             return true;
                         }
                         $faction = strtolower($args[1]);
                         $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(TextFormat::RED . "-------------------------");
                         $sender->sendMessage("{$faction}");
                         $sender->sendMessage(TextFormat::BOLD . "Leader: " . TextFormat::RESET . "{$leader}");
                         $sender->sendMessage(TextFormat::BOLD . "# of Players: " . TextFormat::RESET . "{$numPlayers}");
                         $sender->sendMessage(TextFormat::BOLD . "MOTD: " . TextFormat::RESET . "{$message}");
                         $sender->sendMessage(TextFormat::RED . "-------------------------");
                     } 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(TextFormat::RED . "-------------------------");
                         $sender->sendMessage("{$faction}");
                         $sender->sendMessage(TextFormat::BOLD . "Leader: " . TextFormat::RESET . "{$leader}");
                         $sender->sendMessage(TextFormat::BOLD . "# of Players: " . TextFormat::RESET . "{$numPlayers}");
                         $sender->sendMessage(TextFormat::BOLD . "MOTD: " . TextFormat::RESET . "{$message}");
                         $sender->sendMessage(TextFormat::RED . "-------------------------");
                     }
                 }
                 if (strtolower($args[0]) == "help") {
                     if (!isset($args[1]) || $args[1] == 1) {
                         $sender->sendMessage(TextFormat::BLUE . "Factions Help Page 1 of 3" . TextFormat::RED . "\n/f about\n/f accept\n/f claim\n/f create <name>\n/f del\n/f demote <player>\n/f deny");
                         return true;
                     }
                     if ($args[1] == 2) {
                         $sender->sendMessage(TextFormat::BLUE . "Factions Help Page 2 of 3" . TextFormat::RED . "\n/f home\n/f help <page>\n/f info\n/f info <faction>\n/f invite <player>\n/f kick <player>\n/f leader <player>\n/f leave");
                         return true;
                     } else {
                         $sender->sendMessage(TextFormat::BLUE . "Factions Help Page 3 of 3" . TextFormat::RED . "\n/f motd\n/f promote <player>\n/f sethome\n/f unclaim\n/f unsethome");
                         return true;
                     }
                 }
             }
             if (count($args == 1)) {
                 /////////////////////////////// CLAIM ///////////////////////////////
                 if (strtolower($args[0]) == 'claim') {
                     if ($this->plugin->prefs->get("ClaimingEnabled") == false) {
                         $sender->sendMessage($this->plugin->formatMessage("Plots are not enabled on this server."));
                         return true;
                     }
                     if (!$this->plugin->isInFaction($player)) {
                         $sender->sendMessage($this->plugin->formatMessage("You must be in a faction."));
                         return true;
                     }
                     if (!$this->plugin->isLeader($player) && !$this->plugin->hasPermission($player, "claim")) {
                         $sender->sendMessage($this->plugin->formatMessage("You do not have permission to do this"));
                         return true;
                     }
                     if ($this->plugin->inOwnPlot($sender)) {
                         $sender->sendMessage($this->plugin->formatMessage("Your faction has already claimed this area."));
                         return true;
                     }
                     $x = floor($sender->getX());
                     $y = floor($sender->getY());
                     $z = floor($sender->getZ());
                     $faction = $this->plugin->getPlayerFaction($sender->getPlayer()->getName());
                     if (!$this->plugin->drawPlot($sender, $faction, $x, $y, $z, $sender->getPlayer()->getLevel(), $this->plugin->prefs->get("PlotSize"))) {
                         return true;
                     }
                     $sender->sendMessage($this->plugin->formatMessage("Plot claimed.", true));
                 }
                 /////////////////////////////// UNCLAIM ///////////////////////////////
                 if (strtolower($args[0]) == "unclaim") {
                     if ($this->plugin->prefs->get("ClaimingEnabled") == false) {
                         $sender->sendMessage($this->plugin->formatMessage("Plots are not enabled on this server."));
                         return true;
                     }
                     if (!$this->plugin->isLeader($player) && !$this->plugin->hasPermission($player, "unclaim")) {
                         $sender->sendMessage($this->plugin->formatMessage("You do not have permission to do this"));
                         return true;
                     }
                     $faction = $this->plugin->getPlayerFaction($sender->getName());
                     $this->plugin->db->query("DELETE FROM plots WHERE faction='{$faction}';");
                     $sender->sendMessage($this->plugin->formatMessage("Plot unclaimed.", true));
                 }
                 /////////////////////////////// MOTD ///////////////////////////////
                 if (strtolower($args[0]) == "motd") {
                     if ($this->plugin->isInFaction($sender->getName()) == false) {
                         $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, "motd")) {
                         $sender->sendMessage($this->plugin->formatMessage("You do not have permission to do this"));
                         return true;
                     }
                     $sender->sendMessage($this->plugin->formatMessage("Type your message in chat. It will not be visible to other players", true));
                     $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($this->plugin->formatMessage("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($this->plugin->formatMessage("You successfully joined {$faction}!", true));
                         if ($this->plugin->getServer()->getPlayer($array["invitedby"])) {
                             if ($this->plugin->getServer()->getPlayer($array["invitedby"])) {
                                 $this->plugin->getServer()->getPlayer($array["invitedby"])->sendMessage($this->plugin->formatMessage("{$player} joined the faction!", true));
                             }
                         }
                         if ($this->plugin->prefs->get("FactionNametags")) {
                             $this->plugin->updateTag($sender->getName());
                         }
                     } else {
                         $sender->sendMessage($this->plugin->formatMessage("Invite has timed out!"));
                         $this->plugin->db->query("DELETE FROM confirm WHERE player='{$lowercaseName}';");
                     }
                 }
                 /////////////////////////////// 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($this->plugin->formatMessage("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($this->plugin->formatMessage("Invite declined!", true));
                         $this->plugin->getServer()->getPlayerExact($array["invitedby"])->sendMessage($this->plugin->formatMessage("{$player} declined the invite!"));
                     } else {
                         $sender->sendMessage($this->plugin->formatMessage("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($this->plugin->formatMessage("Faction successfully disbanded!", true));
                             if ($this->plugin->prefs->get("FactionNametags")) {
                                 $this->plugin->updateTag($sender->getName());
                             }
                         } else {
                             $sender->sendMessage($this->plugin->formatMessage("You are not leader!"));
                         }
                     } else {
                         $sender->sendMessage($this->plugin->formatMessage("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($this->plugin->formatMessage("You successfully left {$faction}", true));
                         if ($this->plugin->prefs->get("FactionNametags")) {
                             $this->plugin->updateTag($sender->getName());
                         }
                     } else {
                         $sender->sendMessage($this->plugin->formatMessage("You must delete or give\nleadership first!"));
                     }
                 }
                 /////////////////////////////// SETHOME ///////////////////////////////
                 if (strtolower($args[0] == "sethome")) {
                     if (!$this->plugin->isInFaction($player)) {
                         $sender->sendMessage($this->plugin->formatMessage("You must be in a faction to do this."));
                         return true;
                     }
                     if (!$this->plugin->isLeader($player) && !$this->plugin->hasPermission($player, "sethome")) {
                         $sender->sendMessage($this->plugin->formatMessage("You do not have permission to do this"));
                         return true;
                     }
                     $factionName = $this->plugin->getPlayerFaction($sender->getName());
                     $stmt = $this->plugin->db->prepare("INSERT OR REPLACE INTO home (faction, x, y, z, world) VALUES (:faction, :x, :y, :z, :world);");
                     $stmt->bindValue(":faction", $factionName);
                     $stmt->bindValue(":x", $sender->getX());
                     $stmt->bindValue(":y", $sender->getY());
                     $stmt->bindValue(":z", $sender->getZ());
                     $stmt->bindValue(":world", $sender->getLevel()->getName());
                     $result = $stmt->execute();
                     $sender->sendMessage($this->plugin->formatMessage("Home updated!", true));
                 }
                 /////////////////////////////// UNSETHOME ///////////////////////////////
                 if (strtolower($args[0] == "unsethome")) {
                     if (!$this->plugin->isInFaction($player)) {
                         $sender->sendMessage($this->plugin->formatMessage("You must be in a faction to do this."));
                         return true;
                     }
                     if (!$this->plugin->isLeader($player) && !$this->plugin->hasPermission($player, "unsethome")) {
                         $sender->sendMessage($this->plugin->formatMessage("You do not have permission to do this"));
                         return true;
                     }
                     $faction = $this->plugin->getPlayerFaction($sender->getName());
                     $this->plugin->db->query("DELETE FROM home WHERE faction = '{$faction}';");
                     $sender->sendMessage($this->plugin->formatMessage("Home unset!", true));
                 }
                 /////////////////////////////// HOME ///////////////////////////////
                 if (strtolower($args[0] == "home")) {
                     if (!$this->plugin->isInFaction($player)) {
                         $sender->sendMessage($this->plugin->formatMessage("You must be in a faction to do this."));
                     }
                     if (!$this->plugin->isLeader($player) && !$this->plugin->hasPermission($player, "home")) {
                         $sender->sendMessage($this->plugin->formatMessage("You do not have permission to do this"));
                         return true;
                     }
                     $faction = $this->plugin->getPlayerFaction($sender->getName());
                     $result = $this->plugin->db->query("SELECT * FROM home WHERE faction = '{$faction}';");
                     $array = $result->fetchArray(SQLITE3_ASSOC);
                     if (!empty($array)) {
                         $world = $this->plugin->getServer()->getLevelByName($array['world']);
                         +$sender->getPlayer()->teleport(new Position($array['x'], $array['y'], $array['z'], $world));
                         $sender->sendMessage($this->plugin->formatMessage("Teleported home.", true));
                         return true;
                     } else {
                         $sender->sendMessage($this->plugin->formatMessage("Home is not set."));
                     }
                 }
                 /////////////////////////////// ABOUT ///////////////////////////////
                 if (strtolower($args[0] == 'about')) {
                     $sender->sendMessage(TextFormat::BLUE . "FactionsPro By: " . TextFormat::BOLD . "Tethered" . TextFormat::RESET . TextFormat::BLUE . "Modifications for LEET By: " . TextFormat::ITALIC . "SirGamer");
                 }
             }
         }
     } else {
         $this->plugin->getServer()->getLogger()->info($this->plugin->formatMessage("Please run command in game"));
     }
 }
 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}].");
                         } else {
                             $player->sendMessage("QR panel [{$idToTP}] not found.");
                         }
                     } else {
                         $this->showusage($sender);
                     }
                 }
                 break;
             default:
                 $this->showusage($sender);
                 break;
         }
         return true;
     } else {
         $this->showusage($sender);
     }
 }