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;
}
/** * @param int $currentTick */ public function onRun($currentTick) { $this->getPlugin()->getServer()->getLogger()->debug(TextFormat::YELLOW . "Running EssentialsPE's AFKKickTask"); if ($this->getPlugin()->isAFK($this->player) && !$this->player->hasPermission("essentials.afk.kickexempt") && time() - $this->getPlugin()->getLastPlayerMovement($this->player) >= $this->getPlugin()->getConfig()->getNested("afk.auto-set")) { $this->player->kick("You have been kicked for idling more than " . (($time = floor($this->getPlugin()->getConfig()->getNested("afk.auto-kick"))) / 60 >= 1 ? $time / 60 . " minutes" : $time . " seconds"), false); } }