Skip to content

PlayerPreLoginEvent ​

class · pocketmine\event\player\PlayerPreLoginEvent · source

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 ​

php
public const KICK_FLAG_BANNED = 3

KICK_FLAG_PLUGIN ​

php
public const KICK_FLAG_PLUGIN = 0

KICK_FLAG_PRIORITY ​

php
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 ​

php
public const KICK_FLAG_SERVER_FULL = 1

KICK_FLAG_SERVER_WHITELISTED ​

php
public const KICK_FLAG_SERVER_WHITELISTED = 2

Properties ​

$authRequired ​

php
public bool $authRequired

$disconnectReasons protected ​

php
protected array $disconnectReasons

$disconnectScreenMessages protected ​

php
protected array $disconnectScreenMessages

Methods ​

__construct() ​

php
public function __construct(\pocketmine\player\PlayerInfo $playerInfo, string $ip, int $port, bool $authRequired)

clearAllKickFlags() ​

php
public function clearAllKickFlags() : void

Clears all pre-assigned kick reasons, allowing the player to continue logging in.

clearKickFlag() ​

php
public function clearKickFlag(int $flag) : void

Clears 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() ​

php
public function getDisconnectReason(int $flag) : \pocketmine\lang\Translatable|string|null

Returns 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() ​

php
public function getDisconnectScreenMessage(int $flag) : \pocketmine\lang\Translatable|string|null

Returns 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() ​

php
public function getFinalDisconnectReason() : \pocketmine\lang\Translatable|string

Resolves 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() ​

php
public function getFinalDisconnectScreenMessage() : \pocketmine\lang\Translatable|string

Resolves 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() ​

php
public function getIp() : string

getKickFlags() ​

php
public function getKickFlags() : array

Returns an array of kick flags currently assigned.

getPlayerInfo() ​

php
public function getPlayerInfo() : \pocketmine\player\PlayerInfo

Returns 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() ​

php
public function getPort() : int

isAllowed() ​

php
public function isAllowed() : bool

Returns whether the player is allowed to continue logging in.

isAuthRequired() ​

php
public function isAuthRequired() : bool

isKickFlagSet() ​

php
public function isKickFlagSet(int $flag) : bool

Returns whether the given kick flag is set for this event.

setAuthRequired() ​

php
public function setAuthRequired(bool $v) : void

setKickFlag() ​

php
public function setKickFlag(int $flag, \pocketmine\lang\Translatable|string $disconnectReason, \pocketmine\lang\Translatable|string|null $disconnectScreenMessage = null) : void

Sets 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.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.