PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
pocketmine\event\player\PlayerPreLoginEvent Class Reference
+ Inheritance diagram for pocketmine\event\player\PlayerPreLoginEvent:
+ Collaboration diagram for pocketmine\event\player\PlayerPreLoginEvent:

Public Member Functions

 __construct (private PlayerInfo $playerInfo, private string $ip, private int $port, protected bool $authRequired)
 
 call ()
 
 clearAllKickFlags ()
 
 clearKickFlag (int $flag)
 
 getDisconnectReason (int $flag)
 
 getDisconnectScreenMessage (int $flag)
 
 getEventName ()
 
 getFinalDisconnectReason ()
 
 getFinalDisconnectScreenMessage ()
 
 getIp ()
 
 getKickFlags ()
 
 getPlayerInfo ()
 
 getPort ()
 
 isAllowed ()
 
 isAuthRequired ()
 
 isKickFlagSet (int $flag)
 
 setAuthRequired (bool $v)
 
 setKickFlag (int $flag, Translatable|string $disconnectReason, Translatable|string|null $disconnectScreenMessage=null)
 

Static Public Member Functions

static hasHandlers ()
 

Public Attributes

const KICK_FLAG_BANNED = 3
 
const KICK_FLAG_PLUGIN = 0
 
const KICK_FLAG_PRIORITY
 
const KICK_FLAG_SERVER_FULL = 1
 
const KICK_FLAG_SERVER_WHITELISTED = 2
 

Protected Attributes

array $disconnectReasons = []
 
array $disconnectScreenMessages = []
 
string $eventName = null
 

Detailed Description

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.

Definition at line 42 of file PlayerPreLoginEvent.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\event\player\PlayerPreLoginEvent::__construct ( private PlayerInfo $playerInfo,
private string $ip,
private int $port,
protected bool $authRequired )

Definition at line 60 of file PlayerPreLoginEvent.php.

Member Function Documentation

◆ call()

pocketmine\event\Event::call ( )
inherited

Calls event handlers registered for this event.

Exceptions

RuntimeException if event call recursion reaches the max depth limit

Definition at line 49 of file Event.php.

◆ clearAllKickFlags()

pocketmine\event\player\PlayerPreLoginEvent::clearAllKickFlags ( )

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

Definition at line 133 of file PlayerPreLoginEvent.php.

◆ clearKickFlag()

pocketmine\event\player\PlayerPreLoginEvent::clearKickFlag ( int $flag)

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

Parameters
int$flagSpecific flag to clear.

Definition at line 126 of file PlayerPreLoginEvent.php.

◆ getDisconnectReason()

pocketmine\event\player\PlayerPreLoginEvent::getDisconnectReason ( int $flag)

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.

Definition at line 149 of file PlayerPreLoginEvent.php.

◆ getDisconnectScreenMessage()

pocketmine\event\player\PlayerPreLoginEvent::getDisconnectScreenMessage ( int $flag)

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.

Definition at line 157 of file PlayerPreLoginEvent.php.

◆ getEventName()

pocketmine\event\Event::getEventName ( )
finalinherited

Definition at line 40 of file Event.php.

◆ getFinalDisconnectReason()

pocketmine\event\player\PlayerPreLoginEvent::getFinalDisconnectReason ( )

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.

See also
PlayerPreLoginEvent::KICK_FLAG_PRIORITY

Definition at line 168 of file PlayerPreLoginEvent.php.

◆ getFinalDisconnectScreenMessage()

pocketmine\event\player\PlayerPreLoginEvent::getFinalDisconnectScreenMessage ( )

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.

See also
PlayerPreLoginEvent::KICK_FLAG_PRIORITY

Definition at line 185 of file PlayerPreLoginEvent.php.

◆ getIp()

pocketmine\event\player\PlayerPreLoginEvent::getIp ( )

Definition at line 76 of file PlayerPreLoginEvent.php.

◆ getKickFlags()

pocketmine\event\player\PlayerPreLoginEvent::getKickFlags ( )

Returns an array of kick flags currently assigned.

Returns
int[]

Definition at line 97 of file PlayerPreLoginEvent.php.

◆ getPlayerInfo()

pocketmine\event\player\PlayerPreLoginEvent::getPlayerInfo ( )

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.

Definition at line 72 of file PlayerPreLoginEvent.php.

◆ getPort()

pocketmine\event\player\PlayerPreLoginEvent::getPort ( )

Definition at line 80 of file PlayerPreLoginEvent.php.

◆ hasHandlers()

static pocketmine\event\Event::hasHandlers ( )
staticinherited

Returns whether the current class context has any registered global handlers. This can be used in hot code paths to avoid unnecessary event object creation.

Usage: SomeEventClass::hasHandlers()

Definition at line 77 of file Event.php.

◆ isAllowed()

pocketmine\event\player\PlayerPreLoginEvent::isAllowed ( )

Returns whether the player is allowed to continue logging in.

Definition at line 141 of file PlayerPreLoginEvent.php.

◆ isAuthRequired()

pocketmine\event\player\PlayerPreLoginEvent::isAuthRequired ( )

Definition at line 84 of file PlayerPreLoginEvent.php.

◆ isKickFlagSet()

pocketmine\event\player\PlayerPreLoginEvent::isKickFlagSet ( int $flag)

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

Definition at line 104 of file PlayerPreLoginEvent.php.

◆ setAuthRequired()

pocketmine\event\player\PlayerPreLoginEvent::setAuthRequired ( bool $v)

Definition at line 88 of file PlayerPreLoginEvent.php.

◆ setKickFlag()

pocketmine\event\player\PlayerPreLoginEvent::setKickFlag ( int $flag,
Translatable|string $disconnectReason,
Translatable|string|null $disconnectScreenMessage = null )

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.

Parameters
Translatable | string$disconnectReasonShown in the server log - this should be a short one-line message
Translatable | string | null$disconnectScreenMessageShown on the player's disconnection screen (null will use the reason)

Definition at line 115 of file PlayerPreLoginEvent.php.

Member Data Documentation

◆ $disconnectReasons

array pocketmine\event\player\PlayerPreLoginEvent::$disconnectReasons = []
protected

Definition at line 56 of file PlayerPreLoginEvent.php.

◆ $disconnectScreenMessages

array pocketmine\event\player\PlayerPreLoginEvent::$disconnectScreenMessages = []
protected

Definition at line 58 of file PlayerPreLoginEvent.php.

◆ $eventName

string pocketmine\event\Event::$eventName = null
protectedinherited

Definition at line 38 of file Event.php.

◆ KICK_FLAG_BANNED

const pocketmine\event\player\PlayerPreLoginEvent::KICK_FLAG_BANNED = 3

Definition at line 46 of file PlayerPreLoginEvent.php.

◆ KICK_FLAG_PLUGIN

const pocketmine\event\player\PlayerPreLoginEvent::KICK_FLAG_PLUGIN = 0

Definition at line 43 of file PlayerPreLoginEvent.php.

◆ KICK_FLAG_PRIORITY

const pocketmine\event\player\PlayerPreLoginEvent::KICK_FLAG_PRIORITY
Initial value:
= [
self::KICK_FLAG_PLUGIN,
self::KICK_FLAG_SERVER_FULL,
self::KICK_FLAG_SERVER_WHITELISTED,
self::KICK_FLAG_BANNED
]

Definition at line 48 of file PlayerPreLoginEvent.php.

◆ KICK_FLAG_SERVER_FULL

const pocketmine\event\player\PlayerPreLoginEvent::KICK_FLAG_SERVER_FULL = 1

Definition at line 44 of file PlayerPreLoginEvent.php.

◆ KICK_FLAG_SERVER_WHITELISTED

const pocketmine\event\player\PlayerPreLoginEvent::KICK_FLAG_SERVER_WHITELISTED = 2

Definition at line 45 of file PlayerPreLoginEvent.php.


The documentation for this class was generated from the following file: