PlayerPreLoginEvent
Extends Event
Called when a player connects to the server, prior to authentication taking place. Set a kick reason to cancel the event and disconnect the player with the kick message set.
This event should be used to decide if the player may continue to login to the server. Do things like checking bans, whitelisting, server-full etc here.
WARNING: Any information about the player CANNOT be trusted at this stage, because they are not authenticated and could be a hacker posing as another player.
Constants
KICK_FLAG_BANNED
public const KICK_FLAG_BANNED = 3KICK_FLAG_PLUGIN
public const KICK_FLAG_PLUGIN = 0KICK_FLAG_PRIORITY
public const KICK_FLAG_PRIORITY = [
self::KICK_FLAG_PLUGIN,
//Plugin reason should always take priority over anything else
self::KICK_FLAG_SERVER_FULL,
self::KICK_FLAG_SERVER_WHITELISTED,
self::KICK_FLAG_BANNED,
]KICK_FLAG_SERVER_FULL
public const KICK_FLAG_SERVER_FULL = 1KICK_FLAG_SERVER_WHITELISTED
public const KICK_FLAG_SERVER_WHITELISTED = 2Properties
$authRequired
public bool $authRequired$disconnectReasons protected
protected array $disconnectReasons$disconnectScreenMessages protected
protected array $disconnectScreenMessagesMethods
__construct()
public function __construct(\pocketmine\player\PlayerInfo $playerInfo, string $ip, int $port, bool $authRequired)clearAllKickFlags()
public function clearAllKickFlags() : voidClears all pre-assigned kick reasons, allowing the player to continue logging in.
clearKickFlag()
public function clearKickFlag(int $flag) : voidClears a specific kick flag if it was set. This allows fine-tuned kick reason removal without impacting other reasons (for example, a ban can be bypassed without accidentally allowing a player to join a full server).
getDisconnectReason()
public function getDisconnectReason(int $flag) : \pocketmine\lang\Translatable|string|nullReturns the disconnect reason provided for the given kick flag, or null if not set. This is the message which will be shown in the server log and on the console.
getDisconnectScreenMessage()
public function getDisconnectScreenMessage(int $flag) : \pocketmine\lang\Translatable|string|nullReturns the disconnect screen message provided for the given kick flag, or null if not set. This is the message shown to the player on the disconnect screen.
getFinalDisconnectReason()
public function getFinalDisconnectReason() : \pocketmine\lang\Translatable|stringResolves the message that will be shown in the server log if the player is kicked. Only one message (the highest priority one) will be shown. See priority order to decide how to set your messages.
getFinalDisconnectScreenMessage()
public function getFinalDisconnectScreenMessage() : \pocketmine\lang\Translatable|stringResolves the message that will be shown on the player's disconnect screen if they are kicked. Only one message (the highest priority one) will be shown. See priority order to decide how to set your messages.
getIp()
public function getIp() : stringgetKickFlags()
public function getKickFlags() : arrayReturns an array of kick flags currently assigned.
getPlayerInfo()
public function getPlayerInfo() : \pocketmine\player\PlayerInfoReturns an object containing self-proclaimed information about the connecting player. WARNING: THE PLAYER IS NOT VERIFIED DURING THIS EVENT. At this point, this could be a hacker posing as another player.
getPort()
public function getPort() : intisAllowed()
public function isAllowed() : boolReturns whether the player is allowed to continue logging in.
isAuthRequired()
public function isAuthRequired() : boolisKickFlagSet()
public function isKickFlagSet(int $flag) : boolReturns whether the given kick flag is set for this event.
setAuthRequired()
public function setAuthRequired(bool $v) : voidsetKickFlag()
public function setKickFlag(int $flag, \pocketmine\lang\Translatable|string $disconnectReason, \pocketmine\lang\Translatable|string|null $disconnectScreenMessage = null) : voidSets a reason to disallow the player to continue authenticating, with a message. This can also be used to change kick messages for already-set flags.
