Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved PlayerCreationEvent

Comments in 'Plugin Development' started by Samueljh1H8sLag, Jan 2, 2016.

  1. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    Hey, Im trying to replace the default player class with a custom player class through PlayerCreationEvent.

    For some reason I can't get this to work.

    Here is the code:

    PHP:
    function onPlayerCreate(PlayerCreationEvent $event) {
       
    $event->setPlayerClass(GamePlayer::class);
    }
    I get this error:

    Code:
    Stopped interface pocketmine\network\RakLibInterface due to Argument 1 passed to Samueljh1\DarkHammer\DHSkywars\Game\Player\GamePlayer::__construct() must be an instance of pocketmine\Player, instance of pocketmine\network\RakLibInterface given, called in phar:///Users/samuel/SkyWars/PocketMine-MP.phar/src/pocketmine/network/RakLibInterface.php on line 126 and defined
    
    This same error also happened when trying to pass a new Player object using the event variables into the custom player class constructor.

    Any ideas? :p
  2. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    Nevermind, lol. You have to change the constructor so it matches the player class' one.
    PEMapModder likes this.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Label solved :)
    Samueljh1H8sLag likes this.
  4. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    Done :)

Share This Page

Advertisement