PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
pocketmine\event\player\PlayerCreationEvent Class Reference
+ Inheritance diagram for pocketmine\event\player\PlayerCreationEvent:
+ Collaboration diagram for pocketmine\event\player\PlayerCreationEvent:

Public Member Functions

 __construct (private NetworkSession $session)
 
 call ()
 
 getAddress ()
 
 getBaseClass ()
 
 getEventName ()
 
 getNetworkSession ()
 
 getPlayerClass ()
 
 getPort ()
 
 setBaseClass (string $class)
 
 setPlayerClass (string $class)
 

Static Public Member Functions

static hasHandlers ()
 

Protected Attributes

string $eventName = null
 

Detailed Description

Allows the use of custom Player classes. This enables overriding built-in Player methods to change behaviour that is not possible to alter any other way.

You probably don't need this event, and found your way here because you looked at some code in an old plugin that abused it (very common). Instead of using custom player classes, you should consider making session classes instead.

See also
https://github.com/pmmp/SessionsDemo

This event is a power-user feature, and multiple plugins using it at the same time will conflict and break unless they've been designed to work together. This means that it's only usually useful in private plugins.

WARNING: This should NOT be used for adding extra functions or properties. This is intended for overriding existing core behaviour, and should only be used if you know EXACTLY what you're doing. Custom player classes may break in any update without warning. This event isn't much more than glorified reflection.

Definition at line 48 of file PlayerCreationEvent.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\event\player\PlayerCreationEvent::__construct ( private NetworkSession $session)

Definition at line 55 of file PlayerCreationEvent.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.

◆ getAddress()

pocketmine\event\player\PlayerCreationEvent::getAddress ( )

Definition at line 61 of file PlayerCreationEvent.php.

◆ getBaseClass()

pocketmine\event\player\PlayerCreationEvent::getBaseClass ( )

Returns the base class that the final player class must extend.

@phpstan-return class-string<Player>

Definition at line 74 of file PlayerCreationEvent.php.

◆ getEventName()

pocketmine\event\Event::getEventName ( )
finalinherited

Definition at line 40 of file Event.php.

◆ getNetworkSession()

pocketmine\event\player\PlayerCreationEvent::getNetworkSession ( )

Definition at line 57 of file PlayerCreationEvent.php.

◆ getPlayerClass()

pocketmine\event\player\PlayerCreationEvent::getPlayerClass ( )

Returns the class that will be instantiated to create the player after the event.

@phpstan-return class-string<Player>

Definition at line 98 of file PlayerCreationEvent.php.

◆ getPort()

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

Definition at line 65 of file PlayerCreationEvent.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.

◆ setBaseClass()

pocketmine\event\player\PlayerCreationEvent::setBaseClass ( string $class)

Sets the class that the final player class must extend. The new base class must be a subclass of the current base class. This can (perhaps) be used to limit the options for custom player classes provided by other plugins.

@phpstan-param class-string<Player> $class

Definition at line 85 of file PlayerCreationEvent.php.

◆ setPlayerClass()

pocketmine\event\player\PlayerCreationEvent::setPlayerClass ( string $class)

Sets the class that will be instantiated to create the player after the event. The class must not be abstract, and must be an instance of the base class.

@phpstan-param class-string<Player> $class

Definition at line 108 of file PlayerCreationEvent.php.

Member Data Documentation

◆ $eventName

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

Definition at line 38 of file Event.php.


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