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

Register events & Timer problem.

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

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Can I register an event listener from another non-main-plugin class?
    I have this in a class called Arena.php:
    PHP:
    $this->plugin->getServer()->getPluginManager()->re

    gisterEvents
    (new EventHandler($this), $this);
    Where $this->plugin is the Main class instance.
    I want to have different EventHandlers for every arena.
    It throws me an error and crashes... (The error says the second parameter needs to be a Main class, not Arena class itself)
    What can I do to fix this? Is there an another way?

    Also, I get also an error: Invalid owner of PluginTask LOL\TimerTask. I didin Arena.php:
    PHP:
    $this->timer = new TimerTask($this);
            
    $h $this->plugin->getServer()->getScheduler()->scheduleRepeatingTask($this->timer20);
            
    $this->timer->setHandler($h);
    How can I fix this?
    Last edited: Sep 17, 2015
  2. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    Try
    PHP:
    $this->plugin->getServer()->getPluginManager()->registerEvents(new EventHandler($this), $this->plugin);
    Legoboy0215 likes this.
  3. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Learn OOP. http://php.net/manual/en/language.oop5.php
    Legoboy0215 likes this.
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215

Share This Page

Advertisement