Scheduler
endstone.scheduler
¶
Classes relating to letting plugins run code at specific time intervals.
Classes:
| Name | Description |
|---|---|
Scheduler |
Represents a scheduler that executes various tasks. |
Task |
Represents a task being executed by the scheduler. |
Scheduler
¶
Represents a scheduler that executes various tasks.
Methods:
| Name | Description |
|---|---|
cancel_task |
Removes task from scheduler. |
cancel_tasks |
Removes all tasks associated with a particular plugin from the scheduler. |
get_pending_tasks |
Returns a list of all pending tasks. |
is_queued |
Check if the task is queued to be run later. |
is_running |
Check if the task is currently running. |
run_task |
Returns a task that will be executed repeatedly (and synchronously) until cancelled, starting after the |
cancel_task
¶
cancel_task(id: int) -> None
Removes task from scheduler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Id number of task to be removed. |
required |
cancel_tasks
¶
cancel_tasks(plugin: Plugin) -> None
Removes all tasks associated with a particular plugin from the scheduler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin
|
Plugin
|
Owner of tasks to be removed. |
required |
get_pending_tasks
¶
Returns a list of all pending tasks.
The ordering of the tasks is NOT related to their order of execution.
is_queued
¶
is_running
¶
run_task
¶
Returns a task that will be executed repeatedly (and synchronously) until cancelled, starting after the specified number of server ticks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin
|
Plugin
|
The reference to the plugin scheduling the task. |
required |
task
|
Callable[[], None]
|
The task to be run. |
required |
delay
|
int
|
The ticks to wait before running the task. |
0
|
period
|
int
|
The ticks to wait between runs. |
0
|
Returns:
| Type | Description |
|---|---|
Task
|
A |
Task
¶
Represents a task being executed by the scheduler.
Methods:
| Name | Description |
|---|---|
cancel |
Attempts to cancel this task. |
Attributes:
| Name | Type | Description |
|---|---|---|
is_cancelled |
bool
|
|
is_sync |
bool
|
|
owner |
Plugin
|
The |
task_id |
int
|
The task id number. |