예제 #1
0
 public function onRun(array $args, Faction $faction, Player $player)
 {
     $reason = implode(" ", $args);
     $members = $faction->getMembers(true);
     unset($members[strtolower($player->getName())]);
     $faction->setMembers($members);
     $faction->sendMessage($player->getName() . " quitted the faction.", Faction::CHAT_ANNOUNCEMENT);
     if (strlen($reason) > 0) {
         $faction->sendMessage("Reason: {$reason}");
     }
     return "[PF] You have successfully quitted {$faction}.";
 }
예제 #2
0
 public function onRun(array $args, Faction $faction, Player $player)
 {
     if (!isset($args[0])) {
         return false;
     }
     $faction->setMotto($motto = implode(" ", $args));
     $faction->sendMessage("[PF] Your faction's motto has been set to:\n[PF] ''{$motto}'' by {$player->getName()}.");
     return "";
 }
 public function onRun(array $args, Faction $faction)
 {
     if (!isset($args[0])) {
         $args[0] = "check";
     }
     switch ($args[0]) {
         case "on":
         case "yes":
         case "open":
         case "true":
         case "unwhite":
         case "unwhitelist":
             $fee = $this->getMain()->getSetOpenFee();
             $account = $faction->getAccount($fee["account"]);
             if ($account->canPay($fee["amount"])) {
                 return "Your faction doesn't have enough " . $account->getName() . " money to turn off white-list!";
             }
             $account->pay($this->getMain()->getXEconService(), $fee["amount"], "Opening faction for joining");
             $faction->setWhitelisted(false);
             $faction->sendMessage("Your faction is now open for joining.", Faction::CHAT_ANNOUNCEMENT);
             return "";
         case "off":
         case "no":
         case "close":
         case "false":
         case "white":
         case "whitelist":
             $fee = $this->getMain()->getSetNotOpenFee();
             $account = $faction->getAccount($fee["account"]);
             if ($account->canPay($fee["amount"])) {
                 return "Your faction doesn't have enough " . $account->getName() . " money to turn on white-list!";
             }
             $account->pay($this->getMain()->getXEconService(), $fee["amount"], "White-listing faction");
             $faction->setWhitelisted(true);
             $faction->sendMessage("Your faction is now white-listed.", Faction::CHAT_ANNOUNCEMENT);
             return "";
     }
     return $faction->isOpen() ? "Your faction is open for joining." : "Your faction is white-listed.";
 }
 public function onRun(array $args, Faction $faction, Player $player)
 {
     if (!isset($args[0])) {
         $args[0] = "default";
     }
     if (!$faction->hasChunk(Chunk::fromObject($player))) {
         return "Homes must be created in chunks claimed by your faction!";
     }
     $homes = $faction->getHomes();
     if (isset($homes[$args[0]])) {
         $fee = $this->getMain()->getMoveHomeFee();
         $account = $faction->getAccount($fee["account"]);
         if (!$account->canPay($fee["amount"])) {
             return "Your faction doesn't have enough " . $fee["account"] . " money to move a home.";
         }
         $account->pay($this->getMain()->getXEconService(), $fee["amount"], "Moving home");
         $faction->setHome($args[0], $player);
         // a new position will be created instead of the player position
         $faction->sendMessage("Faction {$args['0']} home has been moved to " . $player->getName() . "'s location.", Faction::CHAT_ANNOUNCEMENT);
         return "";
     }
     if (count($homes) + 1 > ($max = $this->getMain()->getMaxHomes())) {
         //whaaaaa??? || only 1 home foreach factions please xD
         return "A faction can only set a maximum of {$max} home(s)!";
         //what???????? || on FactionsBukkit, their is only 1 home.
     }
     $fee = $this->getMain()->getNewHomeFee();
     $account = $faction->getAccount($fee["account"]);
     if (!$account->canPay($fee["amount"])) {
         return "Your faction doesn't have enough " . $fee["account"] . " money to add a new home.";
     }
     $account->pay($this->getMain()->getXEconService(), $fee["amount"], "Adding new home");
     $faction->setHome($args[0], $player);
     $faction->sendMessage("A new home of {$args['0']} has been created at " . $player->getName() . "'s location.", Faction::CHAT_ANNOUNCEMENT);
     return "";
 }
예제 #5
0
 public function onRun(array $args, Faction $faction, Player $player)
 {
     if (!isset($args[0])) {
         return false;
     }
     $target = $this->main->getServer()->getPlayer($name = array_shift($args));
     if (!$target instanceof Player) {
         return self::NO_PLAYER;
     }
     /** @var StatsCore $statsCore */
     $statsCore = $this->getMain()->getServer()->getPluginManager()->getPlugin("StatsCore");
     $request = new FactionInviteRequest($faction, new PlayerRequestable($target), implode(" ", $args));
     $statsCore->getRequestList()->add($request);
     $faction->sendMessage("[PF] A request has been sent to {$name} (" . $target->getName() . ")\n[PF] by {$player->getName()}.\n[PF] Preview:\n============\n" . $request->getContent());
     return "";
 }
예제 #6
0
 public function onRun(array $args, Faction $faction, Player $player)
 {
     if (!isset($args[0])) {
         return self::WRONG_USE;
     }
     if ($faction->hasMember($name = strtolower(array_shift($args)))) {
         if ($name === $faction->getFounder()) {
             return "You can't kick the founder!";
         }
         $faction->kick($name);
         $faction->sendMessage("{$name} has been kicked by " . $player->getName() . ". Reason: " . implode(" ", $args));
         if (($p = $this->getMain()->getServer()->getPlayerExact($name)) instanceof Player) {
             $p->sendMessage("You have been kicked from the faction. Reason: " . implode(" ", $args));
         }
     }
     return self::NO_PLAYER;
 }
예제 #7
0
 public function onRun(array $args, Faction $faction, Player $player)
 {
     if (!isset($args[0])) {
         return self::WRONG_USE;
     }
     /** @var \xecon\XEcon $xEcon */
     $xEcon = $this->getMain()->getServer()->getPluginManager()->getPlugin("xEcon");
     $ent = $xEcon->getPlayerEnt($player);
     $account = $ent->getAccount(PlayerEnt::ACCOUNT_BANK);
     $amount = (int) array_shift($args);
     if ($account->canPay($amount)) {
         $factionAccount = $faction->getAccount("Bank");
         $account->pay($factionAccount, $amount, "Donation");
     }
     $faction->sendMessage("Received a donation of \${$amount} from " . $player->getName() . "!");
     return "\${$amount} has been deposited into the faction bank from your bank account.";
 }
예제 #8
0
 public function onRun(array $args, Faction $faction)
 {
     if (!isset($args[0])) {
         return self::WRONG_USE;
     }
     $name = array_shift($args);
     if (preg_replace($this->main->getFactionNamingRule(), "", $name) !== "") {
         return $this->getMain()->getFactionNameErrorMsg();
     } elseif (is_int($this->getMain()->getFList()->getFactionID($name))) {
         return "A faction with name \"{$name}\" already exists!";
     }
     $fee = $this->getMain()->getFactionRenameFee();
     $account = $faction->getAccount($fee["account"]);
     $amount = $account->getAmount() - $fee["amount"];
     if ($amount < 0 - $this->getMain()->getMaxBankOverdraft() and $fee["account"] === "bank" or $amount < 0) {
         return "Your faction doesn't have enough money to rename :( consider taking loans or donating money?";
     }
     $faction->setName($name);
     $account->pay($this->getMain()->getXEconService(), $fee["amount"]);
     $faction->sendMessage("The faction name has been changed to {$args['0']}!");
     return "";
 }
 public function onRun(array $args, Faction $faction, Player $player)
 {
     $faction->sendMessage($player->getName() . " disbanded this faction! Reason given: " . implode(" ", $args), Faction::CHAT_ALL);
     $this->main->getFList()->disband($faction);
 }
 public function onRejected()
 {
     /** @var Faction $to */
     $to = $this->getTo();
     $this->from->sendMessage("The request to be " . $this->getState() . " factions with " . $to->getDisplayName() . " has been rejected!");
 }
 public function onRun(array $args, Faction $faction, Player $player)
 {
     $faction->unclaimAll();
     $faction->sendMessage("All chunks have been unclaimed!");
     return "";
 }