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

[New API] Invalid owner of PluginTask

Comments in 'Plugin Development' started by boybook, Aug 15, 2014.

  1. boybook
    Offline

    boybook New Member Plugin Developer

    Joined:
    Mar 16, 2014
    Posts:
    18
    Plugins:
    3
    Minecraft User:
    boybook
    My code is:
    $par["room"] = $room;
    $par["num"] = 0;
    $this->getServer()->getScheduler()->scheduleDelayedTask(new TimerOut($par), 20);

    But the server crashed, showed an error: "Invalid owner of PluginTask"
    What is the matter, how can I fix it ?? I need help !
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    You have to pass $this to PluginTask.
  3. boybook
    Offline

    boybook New Member Plugin Developer

    Joined:
    Mar 16, 2014
    Posts:
    18
    Plugins:
    3
    Minecraft User:
    boybook
    but how can i transfer parameters ?
  4. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Use parent::__construct() inside the constructor.
    64FF00, PEMapModder and LDX like this.
  5. boybook
    Offline

    boybook New Member Plugin Developer

    Joined:
    Mar 16, 2014
    Posts:
    18
    Plugins:
    3
    Minecraft User:
    boybook
    But i don't want to transfer the main class. i only want to transfer the $par. and it may run a few times in one second.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What do you mean?
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Can you upload all files?
  8. Kagehis4
    Offline

    Kagehis4 New Member

    Joined:
    Aug 20, 2014
    Posts:
    44
    Minecraft User:
    Kagehis4
    Every task, must have an owner, or it will become a DeadLock or whatever it called, so you must pass it's owner

    Code:
    $this->getServer()->getScheduler()->scheduleDelayedTask(new TimerOut($this, $par), 20);
    
    and in the TimerOut class

    Code:
    class TimerOut extends PluginTask{
    
        private $plugin;
        private $par;
       
        public function __construct(Plugin $plugin, $par){
            parent::__construct($plugin);
            $this->plugin = $plugin;
            $this->par = $par;
        }
    
    
    

Share This Page

Advertisement