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

Tasks

Comments in 'Plugin Development' started by minebuilder0110, Feb 9, 2016.

  1. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Okay; So I am very new to the use of tasks (feel free to call me a code noob and google noob), and after reading the tutorials in the resource section, I still cannot find what exactly __construct is used for. I don't really understand the idea of $owner and $plugin. Also, I am not sure the definition of them at all, since I can't find where it is defined at.
    PHP:
    function __construct(EconomyGamble $owner) {
    parent::__construct ($owner);
    }
    PHP:
    protected $owner$plugin;
    public function 
    __construct(Plugin $ownerMain $plugin) {
    parent::__construct ($owner);
    $this->plugin $plugin;
    }
    In other words, I just don't understand the meaning of it at all... the __construct and parent::__construct($owner) is quite different from what I have learnt, and the use/meaning of $plugin and $owner...
  2. CookieSteve
    Offline

    CookieSteve Active Member

    Joined:
    Apr 22, 2014
    Posts:
    132
    Minecraft User:
    iStrqfeChris
    Code:
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this,"Task"]),10);
    is this what your Looking for?
  3. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Not really, since I am trying to understand the usage and the meaning of the __construct used in the examples provided above.
    Also, never use CallBackTask.
  4. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    PHP.net: PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.
    AndrewBit, Vaivez66 and applqpak like this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    This is entirely irrelevant to the question.
    AndrewBit and applqpak like this.

Share This Page

Advertisement