Esempio n. 1
0
 /**
  * Kicks a player from the server
  *
  * @param string $reason
  * @param bool   $isAdmin
  *
  * @return bool
  */
 public function kick($reason = "", $isAdmin = true)
 {
     $this->server->getPluginManager()->callEvent($ev = new PlayerKickEvent($this, $reason, $this->getLeaveMessage()));
     if (!$ev->isCancelled()) {
         if ($isAdmin) {
             $message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : "");
         } else {
             if ($reason === "") {
                 $message = "disconnectionScreen.noReason";
             } else {
                 $message = $reason;
             }
         }
         $this->close($ev->getQuitMessage(), $message);
         return true;
     }
     return false;
 }
Esempio n. 2
0
 /**
  * Kicks a player from the server
  *
  * @param string $reason
  *
  * @return bool
  */
 public function kick($reason = "")
 {
     $this->server->getPluginManager()->callEvent($ev = new PlayerKickEvent($this, $reason, TextFormat::YELLOW . $this->username . " has left the game"));
     if (!$ev->isCancelled()) {
         $message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : "");
         $this->sendMessage($message);
         $this->close($ev->getQuitMessage(), $message);
         return true;
     }
     return false;
 }
Esempio n. 3
0
 /**
  * Kicks a player from the server
  *
  * @param string $reason
  * @param bool   $isAdmin
  *
  * @return bool
  */
 public function kick($reason = "Disconnected from server.")
 {
     $this->server->getPluginManager()->callEvent($ev = new PlayerKickEvent($this, $reason, TextFormat::YELLOW . $this->username . " has left the game"));
     if (!$ev->isCancelled()) {
         $message = $reason;
         $this->sendMessage($message);
         $this->close($ev->getQuitMessage(), $message);
         return true;
     }
     return false;
 }
Esempio n. 4
0
 public function onKick(PlayerKickEvent $e)
 {
     if ($e->isCancelled()) {
         return;
     }
     if (preg_match('/flying/i', $e->getReason())) {
         $state = $this->getState($e->getPlayer(), null);
         if ($state) {
             $e->setCancelled();
         }
     }
 }