Source code for bedrock.events

from collections.abc import Callable, Coroutine
from typing import TypeVar

from attrs import define

from .context import Context

ContextType = TypeVar("ContextType", bound=Context)
EventHandler = Callable[[ContextType], Coroutine]  # TODO: specify coro types


[docs]@define class Event: name: str handler: EventHandler
[docs] async def __call__(self, ctx: Context, /) -> None: return await self.handler(ctx)
[docs]@define class GameEvent(Event): pass
[docs]@define class ServerEvent(Event): pass