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

Custom events?

Comments in 'Plugin Development' started by Legoboy0215, Aug 17, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
  2. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    PHP:
    <?php

    namespace MyPlugin\Event;

    use 
    pocketmine\event\plugin\PluginEvent;
    use 
    pocketmine\Player;

    class 
    PlayerWinEvent extends PluginEvent{
       
        public static 
    $handlerList null;
       
        protected 
    $player;
       
        public function 
    __construct(Player $p) {
            
    $this->player $p;
        }
       
        public function 
    getPlayer(){
            return 
    $this->player;
        }
    }
    EvolSoft and Legoboy0215 like this.
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    PHP:
    $this->getServer()->getPluginManager()->callEvent(new PlayerWinEvent($player));
    EvolSoft and Legoboy0215 like this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You have to run a line parent::__construct($plugin) in constructor.
    CrazedMiner likes this.
  5. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    Thx so $plugin is main file?
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    No. I think $this->getOwner?
    How would implementing cancelble affect the file?
  7. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    implements Cancellable
  8. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    What ablout checking if a event is cancelled? Like the callEvent? Ia it cancelEvent or what ever...
  9. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    if($event->isCancelled()){}
    PEMapModder likes this.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Learn PHP. Nowhere is that method defined.
    Wrong concept: file
    Correct concept: class/object
  11. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    lol. I forgot $event->setCancelled()…

Share This Page

Advertisement