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

Adding custom properties (???) to Player class

Comments in 'Plugin Development' started by Legoboy0215, Mar 31, 2016.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Is it good practice to do this?
    PHP:
    $player $event->getPlayer();
    $player->checksPassed true;
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    I would rather create an own Class that extends Player, then do everything with that.
    PHP:
    public class myPlayer extends Player{
    public 
    $checksPassed false;
    }
    Then
    PHP:
    public function onPlayerCreation(PlayerCreationEvent $event) {
            
    $event->setPlayerClass(myPlayer::class);
        }
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If more than one plugin does this, it will conflict. Only the plugin with the highest priority wins.

    Unless it's a private plugin, avoid using it. PlayerCreationEvent was originally for things that are really impossible to do without using it. For example, to override the sendTranslation function.
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    True. Though, if having all plugins coded yourself, this would be good for the core(auth system, stats, etc.)
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then we don't need plugins at all; we just need to create patches to the PocketMine source; that's the best for the core :D

Share This Page

Advertisement