Skip to content

Instantly share code, notes, and snippets.

@Cheaterman
Created May 22, 2022 19:07
Show Gist options
  • Save Cheaterman/4defb0f806399023409a06c2a244ef09 to your computer and use it in GitHub Desktop.
Save Cheaterman/4defb0f806399023409a06c2a244ef09 to your computer and use it in GitHub Desktop.
mindbendies.py
@dataclass
class Event:
callback_name: str
def __call__(self, args_converter):
def register(cls, handler):
@functools.wraps(handler)
def wrapper(*args):
return handler(*args_converter(cls, *args))
registry.register_callback(
self.callback_name,
wrapper,
args_converter.__name__,
)
return classmethod(register)
class Player:
@Event('OnPlayerConnect')
def on_connect(cls, playerid: int):
return (cls(playerid),)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment