Class TaskPlugin

All Implemented Interfaces:
com.google.inject.Module, org.pf4j.ExtensionPoint
Direct Known Subclasses:
TaskPlugin

public abstract class TaskPlugin extends LoopedPlugin
Abstract base class for task-based plugins.

TaskPlugin extends LoopedPlugin and provides a task-driven execution model. Instead of implementing a single loop method, you define an array of Task objects. Each loop iteration, the plugin validates which tasks should run and executes them in order.

Tasks are executed based on their validation result and blocking status:

  • Non-blocking tasks are collected and all executed in sequence
  • Blocking tasks stop further task collection when validated
  • The delay returned by a blocking task determines the next loop delay

Example usage:


 @PluginDescriptor(
     name = "My Task Plugin",
     description = "A task-based automation plugin"
 )
 public class MyTaskPlugin extends TaskPlugin {
     private final Task[] tasks = {
         new EatFoodTask(this),
         new DrinkPotionTask(this),
         new CombatTask(this)
     };

     @Override
     public Task[] getTasks() {
         return tasks;
     }
 }
 

See Also:
  • Constructor Details

    • TaskPlugin

      public TaskPlugin()
  • Method Details

    • loop

      public int loop()
      Executes the task loop.

      This method iterates through all tasks returned by getTasks(), validates each task, and executes those that pass validation. Blocking tasks will stop further task collection and their returned delay will be used for the next loop iteration.

      Specified by:
      loop in class LoopedPlugin
      Returns:
      the delay in milliseconds before the next loop iteration. Returns the delay from the last blocking task, or 1000ms if no blocking task was executed.
    • getTasks

      public abstract Task[] getTasks()
      Returns the array of tasks that this plugin should execute.

      Tasks are evaluated in the order they appear in the array. Override this method to provide your plugin's task list.

      Returns:
      an array of Task objects to be executed by this plugin