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

Solved Pass plugin to Task

Comments in 'Plugin Development' started by Tim // robske Büba, Feb 13, 2016.

  1. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    I'm trying to pass my plugin object to the task but i keep getting:
    Uncaught exception 'UndefinedVariableException' with message 'Undefined variable: plugin' in /Users/Tim/Desktop/Pocket_Server_0.13.x_TEST/plugins/Server_Core/src/robske_110/ServerCore/Ampel.php:42
    (I'm trying to access it with $this->plugin)
    Here is my Task:
    PHP:
    class Ampel extends PluginTask{
        public 
    $plugin;
       

        public function 
    __construct(Main $plugin){
            
    parent::__construct($plugin);
            
    $this->plugin $plugin;
        }
    //CODE
    }
  2. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Weird, i just lookd in some other plugin sources and they do the exact same thing :(
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Try to first set the variable, then construct
  4. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Sorry. Didn't understand that. I'm creating the var with global $plugin;
  5. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    Try :
    PHP:
    /** @var Main */$this->getOwner();
  6. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Magically working now :)
    THANKS
  7. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    which one?
  8. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Yours
    But without that (later edited) @var stuff

Share This Page

Advertisement