Exemplo n.º 1
0
 function marryCommand(CommandSender $sender, array $args)
 {
     if (count($args) !== 1) {
         $sender->sendMessage($this->getMessage("l.marry.usage"));
         return true;
     }
     if ($this->provider->isMarried($sender->getName())) {
         $sender->sendMessage($this->getMessage("l.married"));
         return true;
     }
     if ($this->provider->isMarried($args[0])) {
         $sender->sendMessage($this->getMessage("l.is-married", $args[0]));
         return true;
     }
     if (strtolower($sender->getName()) == strtolower($args[0])) {
         $sender->sendMessage($this->getMessage("no-marry-you"));
         return true;
     }
     $this->updateQueries();
     if (isset($this->queries[strtolower($sender->getName())])) {
         $sender->sendMessage($this->getMessage("l.queried", $this->queries[strtolower($sender->getName())]->to));
         return true;
     }
     if (!($to = $this->getServer()->getPlayer($args[0]))) {
         $sender->sendMessage($this->getMessage("l.offline"));
         return true;
     }
     $query = new Query();
     $query->time = time();
     $query->from = $sender->getName();
     $query->to = $to->getName();
     $this->queries[strtolower($sender->getName())] = $query;
     foreach ($this->getServer()->getLevels() as $Level) {
         foreach ($Level->getPlayers() as $Player) {
             if ($Player->getId() != $sender->getId() && $Player->getId() != $to->getId()) {
                 $Player->sendMessage($this->getMessage("l.query-all", $sender->getName(), $to->getName()));
             }
         }
     }
     $sender->sendMessage($this->getMessage("l.you-query", $to->getName()));
     $to->sendMessage($this->getMessage("l.query", $sender->getName()));
     $to->sendMessage($this->getMessage("l.query-yes", $sender->getName()));
     $to->sendMessage($this->getMessage("l.query-no"));
     return true;
 }