getPlayerExact() public méthode

public getPlayerExact ( string $name ) : Player
$name string
Résultat Player
Exemple #1
0
 /**
  * @param int $id
  * @param int $damage
  * @param int $count
  * @param bool $removeInv
  *
  * @return bool
  */
 public function addItem($id, $damage, $count, $removeInv = true)
 {
     if ($removeInv === true) {
         $p = $this->server->getPlayerExact($this->player);
         if (!$p instanceof Player) {
             return false;
         }
         $tmp = $count;
         foreach ($p->getInventory()->getContents() as $slot => $content) {
             if ($content->getID() == $id and $content->getDamage() == $damage) {
                 if ($tmp <= 0) {
                     break;
                 }
                 $take = min($content->getCount(), $tmp);
                 $tmp -= $take;
                 $content->setCount($content->getCount() - $take);
                 $p->getInventory()->setItem($slot, $content);
             }
         }
     }
     if (isset($this->items[$id . ":" . $damage])) {
         $this->items[$id . ":" . $damage] += $count;
     } else {
         $this->items[$id . ":" . $damage] = $count;
     }
     return true;
 }
 public function onCompletion(Server $server)
 {
     $friends = [Session::FRIEND_LEVEL_NONE => [], Session::FRIEND_LEVEL_ACQUAINTANCE => [], Session::FRIEND_LEVEL_GOOD_FRIEND => [], Session::FRIEND_LEVEL_BEST_FRIEND => []];
     if ($this->session->getPlayer()->isOnline()) {
         $result = $this->getResult()["result"];
         foreach ($result as $row) {
             $type = $row["type"];
             $nick = array_filter(explode("|", $row["nicks"]))[0];
             $isOnline = $server->getPlayerExact($nick) instanceof Player;
             $class = $type & ~Session::FRIEND_BITMASK_REQUEST;
             $req = $type & Session::FRIEND_BITMASK_REQUEST;
             if ($isOnline) {
                 $nick = TextFormat::GREEN . "*" . TextFormat::WHITE . $nick;
             }
             if ($req === Session::FRIEND_IN) {
                 $nick .= TextFormat::GOLD . ">";
             } elseif ($req === Session::FRIEND_OUT) {
                 $nick .= TextFormat::DARK_AQUA . "<";
             }
             $nick .= TextFormat::WHITE;
             $friends[$class][] = $nick;
         }
         $this->session->send(Phrases::CMD_FRIEND_LIST_KEY);
         $this->session->sendCurlyLines();
         foreach ($friends as $class => $list) {
             $type = $this->session->translate(Session::$FRIEND_TYPES[$class]);
             $this->session->setMaintainedPopup(TextFormat::BLUE . $type . ": " . implode(TextFormat::WHITE . ":", $list));
         }
         $this->session->sendCurlyLines();
     }
 }
 public function onCompletion(Server $server)
 {
     if (isset($this->error)) {
         $server->getPluginManager()->getPlugin("VoteReward")->getLogger()->error($this->error);
     }
     $server->getPluginManager()->getPlugin("VoteReward")->rewardPlayer($server->getPlayerExact($this->id), $this->rewards);
     array_splice($server->getPluginManager()->getPlugin("VoteReward")->queue, array_search($this->id, $server->getPluginManager()->getPlugin("VoteReward")->queue, true), 1);
 }
Exemple #4
0
 public function onCompletion(Server $server)
 {
     if (($player = $this->player) === "CONSOLE" or ($player = $server->getPlayerExact($this->player)) instanceof Player) {
         $plugin = EconomyAPI::getInstance();
         $output = "- Showing top money list ({$this->page} of {$this->max}) - \n";
         $message = $plugin->getMessage("topmoney-format", $this->player, ["%1", "%2", "%3", "%4"]) . "\n";
         foreach ($this->topList as $n => $list) {
             $output .= str_replace(["%1", "%2", "%3"], [$n, $list[0], $list[1]], $message);
         }
         if ($player instanceof Player) {
             $player->sendMessage($output);
         } else {
             $plugin->getLogger()->info($output);
         }
     }
 }
 public function onCompletion(Server $server)
 {
     $player = $server->getPlayerExact($this->exactName);
     if ($player instanceof Player) {
         $result = $this->getResult();
         if ($result["resulttype"] === self::TYPE_ASSOC) {
             $row = $result["result"];
             /** @var string $ip */
             /** @var int $port */
             extract($row);
             $main = BasePlugin::getInstance($server);
             $main->transfer($player, $ip, $port, Phrases::VAR_success . "Transferring you to a " . Settings::$CLASSES_NAMES[$this->class] . " server.");
         } else {
             $player->sendMessage(Phrases::VAR_error . "No " . Settings::$CLASSES_NAMES[$this->class] . " servers available!");
         }
     }
 }
Exemple #6
0
 public function onCompletion(Server $server)
 {
     if ($this->sender === "CONSOLE" or ($player = $server->getPlayerExact($this->sender)) instanceof Player) {
         // TODO: Rcon
         $plugin = EconomyAPI::getInstance();
         $output = $plugin->getMessage("topmoney-tag", [$this->page, $this->max], $this->sender) . "\n";
         $message = $plugin->getMessage("topmoney-format", [], $this->sender) . "\n";
         foreach (unserialize($this->topList) as $n => $list) {
             $output .= str_replace(["%1", "%2", "%3"], [$n, $list[0], $list[1]], $message);
         }
         $output = substr($output, 0, -1);
         if ($this->sender === "CONSOLE") {
             $plugin->getLogger()->info($output);
         } else {
             $player->sendMessage($output);
         }
     }
 }
Exemple #7
0
 /**
  * @param Server $server
  */
 public function onCompletion(Server $server)
 {
     DebugUtils::taskComplete($this);
     $plugin = $server->getPluginManager()->getPlugin("BuyCraft");
     if ($plugin instanceof BuyCraft && $plugin->isEnabled()) {
         if ($this->player !== false) {
             $player = $server->getPlayerExact($this->player);
             if ($player !== null && $player->isOnline()) {
                 $this->onOutput($plugin, $player);
             }
         } else {
             $this->onOutput($plugin, new ConsoleCommandSender());
         }
     }
 }