- RuntimeError – When event_function is None.
- TypeError – When event_function is not a callable function.
- AssertionError – When the event_function is missing the event_data argument, when the event_function contains a self or cls argument, or when more than one argument is found.
Determine if this event handler can handle the type of the event.
Parameters: event (CommonEvent) – The event to check. Returns: True, if this handler can handle the event. False, if not. Return type: bool
The action to take upon receiving an event.
Returns: The function that handles events. Return type: Callable[[CommonEvent], Any]
The class type of events this Event Handler will handle.
Returns: The types of events the handler handles. Return type: type
Handle the event data.
Parameters: event (CommonEvent) – The event to handle. Returns: True, if the event was successful. False, if not. Return type: bool
The name of the mod this event handler was created for.
Returns: The name of the Mod that owns this handler. Return type: str
Register event listeners and dispatch events to any that are registered.
Dispatch an event to any event handlers listening for it.
If any listeners return False or None when they handle the event, the total result of dispatch will be False as well.
Parameters: event (CommonEvent) – An instance of an Event to dispatch to listeners. Returns: True, if the Event was dispatched to all listeners successfully. False, if any listeners failed to handle the event. Return type: bool
Decorate functions with this static method to register that function to handle an event.
Warning:: Event functions MUST be decorated with staticmethod and must only have a single argument with the name ‘event_data’ (Errors will be thrown upon loading the game otherwise) Parameters: mod_identifier (Union[str, CommonModIdentity]) – The name or identity of the mod the class is being registered for. Returns: A callable function wrapped to handle events. Return type: Callable[[Callable[[CommonEvent], bool]], Callable[[CommonEvent], bool]]