Package net.storm.api.plugins
Class TaskPlugin
java.lang.Object
net.storm.api.plugins.Plugin
net.storm.api.plugins.LoopedPlugin
net.storm.api.plugins.TaskPlugin
- All Implemented Interfaces:
com.google.inject.Module,org.pf4j.ExtensionPoint
- Direct Known Subclasses:
TaskPlugin
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:
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class net.storm.api.plugins.LoopedPlugin
stopMethods inherited from class net.storm.api.plugins.Plugin
configure, equals, getName, hashCode, isSdn, resetConfiguration, setToggleHidden, shutDown, startUp
-
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:
loopin classLoopedPlugin- 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
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
Taskobjects to be executed by this plugin
-