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

Cant use $this->getServer() - server::getInstance()

Comments in 'Plugin Development' started by Sensej, Oct 4, 2014.

  1. iksaku
    Offline

    iksaku Notable Member Plugin Developer

    Joined:
    Sep 2, 2013
    Posts:
    1,130
    Plugins:
    4
    Minecraft User:
    iksaku
    Learn how to register Plugin Tasks from the src pocketmine code, it's pretty simple ;)
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Task ≠ PluginTask.
    64FF00 likes this.
  3. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    The first is always recommended and the second is bad practice in plugin development conventions. I only use the second when I need to make a quick call to some server function inside a class which is going to be run Asynchronously, so as not to have to clean up the reference later.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You mean use that function in other threads?
  5. Sensej
    Offline

    Sensej New Member

    Joined:
    Aug 5, 2014
    Posts:
    64
    So what i can do if i already extend the PluginBase?
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Well, do you know what PluginBase, PluginTask and Listener are respectively, and what is meant by extending/implementing them?
  7. Sensej
    Offline

    Sensej New Member

    Joined:
    Aug 5, 2014
    Posts:
    64
    Yes i know
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then why do you make a PluginTask implement a Listener?
  9. Sensej
    Offline

    Sensej New Member

    Joined:
    Aug 5, 2014
    Posts:
    64
    Cause the PluginTask include the $this->getOwner() methode
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    -_-" I want to throw my phone out of the window, but the window is shut.

    You don't extend/implement a class/interface to get its functions... Why can't you just use $this at the main class?
    64FF00 likes this.
  11. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    No, but if I have an AsyncTask which is not yet running but has to do something (like schedule itself). I don't want to have to cleanup the reference to the PluginBase or Server when it decides to run.
    PEMapModder and 64FF00 like this.
  12. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    THANK U SENSEI

Share This Page

Advertisement