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

Solved Difference between DelayedTask and RepeatingTask

Comments in 'Plugin Development' started by AndrewBit, May 7, 2016.

  1. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I think that the title says all.
    I usually use RepeatingTask and AsyncTasks, but I never used a delayed task, and that's why Idk at all how it works..
  2. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    A repeating task repeats the onRun function within the Task class after the set amount of ticks have passed, this is usually used for mini-games and timers as a task running every 20 ticks (every second) is easier to manage. Delayed tasks are only executed once after the set amount of ticks have passed and are usually used for clearing data from arrays or other delayed actions.
    Primus and AndrewBit like this.
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    It's a 'delayed' task.
    Primus likes this.
  4. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Wow, so useful.
    Thanks!
  5. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Well it is kinda useful:p
    The tasks get executed once with a delay of x ticks
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Names of of the classes isn't self-explanatory already?
    Legoboy0215 and Thunder33345 like this.
  7. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    A PluginTask is a subclass of Task. A Task object can always be scheduled with the scheduleDelayedTask or the scheduleRepeatingTask function, but there doesn't exist something called "DelayedTask" or "RepeatingTask". A Task can be scheduled repeating after it is scheduled delayed.
    However, an AsyncTask is totally different. An AsyncTask is not a Task. There is a function scheduleAsyncTask with a similar name, but scheduleAsyncTask has totally no relationship with scheduleDelayedTask or scheduleRepeatingTask, and AsyncTask has totally no hierarchical relationship with Task.
    An AsyncTask is an object that is passed to the AsyncPool for running on another thread later. You can't do this with a Task. Similarly, you can't schedule a delayed task with an AsyncTask. A Task is synchronous, and an AsyncTask is asynchronous.
    You already have doubleplusungood understanding on tasks if you consider "RepeatingTask" and "AsyncTask" as similar things. The former is nonexistent, and the latter is totally irrelevant.

    Also refer to this post: https://forums.pocketmine.net/threa...-is-the-alternative-for-it.17331/#post-164782
    AndrewBit likes this.
  8. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    No, that is why I asked. I don't want have an idea of how it works, I want know how it works as well.
    This is explanatory:

Share This Page

Advertisement