Перейти к основному содержимому

Protocol: System

Scheduler in QuestScript's final server-thread scripting phase.

class System(Protocol)

Related API: SystemAfterEvents, SystemBeforeEvents

Properties

current_tick

@property
def current_tick(self) -> int:

Current Minecraft server tick.

before_events

@property
def before_events(self) -> SystemBeforeEvents:

Synchronous lifecycle events fired before teardown completes.

Related API: SystemBeforeEvents

after_events

@property
def after_events(self) -> SystemAfterEvents:

Observational system event streams.

Related API: SystemAfterEvents

Methods

run

def run(self, callback: Callable[[], None]) -> int:

Schedule a callback for the next available final scripting phase.

The callback result is ignored. A returned Promise or awaitable is detached from this run handle.

run_timeout

def run_timeout(self, callback: Callable[[], None], timeout: Optional[int]=1) -> int:

Schedule a one-shot callback after at least a number of ticks.

A timeout of zero is eligible again in the current final scripting phase. Soft tick-budget exhaustion may defer execution. The callback result is ignored; returned asynchronous work is detached from this run handle.

run_interval

def run_interval(self, callback: Callable[[], None], interval: Optional[int]=20) -> int:

Run a callback on a fixed Minecraft-tick interval.

A schedule point is skipped when the previous invocation is still queued or running. A returned Promise or awaitable is not part of the invocation and does not delay the next schedule point.

clear_run

def clear_run(self, run_id: int) -> None:

Cancel a callback scheduled by run, run_timeout, or run_interval.

A queued callback that has not entered guest code is skipped. An invocation already executing and detached asynchronous work already started by a callback are not interrupted.

run_job

def run_job(self, generator: Generator[Any, Any, Any]) -> int:

Advance a generator cooperatively in budgeted steps.

clear_job

def clear_job(self, job_id: int) -> None:

Cancel a cooperative generator job.

A queued step that has not accessed the generator is skipped. A generator step already executing is not preempted.

wait_ticks

def wait_ticks(self, ticks: int) -> Awaitable[None]:

Return an awaitable resolved no earlier than the selected server tick.