Skip to content

PlayerCreationEvent ​

class · pocketmine\event\player\PlayerCreationEvent · source

Extends Event

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.

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.

Methods ​

__construct() ​

php
public function __construct(\pocketmine\network\mcpe\NetworkSession $session)

getAddress() ​

php
public function getAddress() : string

getBaseClass() ​

php
public function getBaseClass() : string

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

getNetworkSession() ​

php
public function getNetworkSession() : \pocketmine\network\mcpe\NetworkSession

getPlayerClass() ​

php
public function getPlayerClass() : string

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

getPort() ​

php
public function getPort() : int

setBaseClass() ​

php
public function setBaseClass(string $class) : void

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.

setPlayerClass() ​

php
public function setPlayerClass(string $class) : void

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.

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