1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to send custom event?

Discussion in 'Development' started by HittmanA, Jan 14, 2017.

  1. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    Say I want to send a custom event MyEvent to plugins. Kind of like OnPlayerJoin or anything like that. How would I do that?
     
  2. kaliiks

    kaliiks Zombie

    Messages:
    250
    Create new class with name of the event
    PHP:
    <?php
    use pocketmine\event\plugin\PluginEvent;
    use 
    pocketmine\Player;

    class 
    EVENT extends PluginEvent implements Listener{
    public static 
    $handlerList null;
    public function 
    __construct(YourMain $pluginPlayer $playerArena $arena) {
    parent::__construct($plugin);
    }
    public function 
    eventFunctions(){
    //blablabla
    }
    }
     
  3. HittmanA

    HittmanA Zombie

    Messages:
    207
    GitHub:
    hittmana
    Ok how could I then send it to toher plugins?
     
  4. kaliiks

    kaliiks Zombie

    Messages:
    250
    Do
    PHP:
    use FolderWhereIsEvent\eventclassname;
    and then
    PHP:
    public function onMyCustomEvent(YourEventFileName $e){
     
  5. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    callEvent or broadcast event under Server afaik (hint see economy api etc if you still didnt get it)
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.