Add hook system

+ Formatting
This commit is contained in:
magmaus3 2022-11-19 13:51:28 +01:00
parent 36dff3d99a
commit 5360b128e0
Signed by: magmaus3
GPG key ID: 966755D3F4A9B251
7 changed files with 350 additions and 206 deletions

View file

@ -0,0 +1,9 @@
# from . import *
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
for imp, module, ispackage in pkgutil.walk_packages(
path=__path__, prefix=__name__ + "."
):
__import__(module)

View file

@ -0,0 +1,18 @@
#
# Example module.
#
from .. import hook_system
hook = hook_system.hook
@hook.add_hook
class Login:
# Different hook types are executed at different places.
# In this case, the hook is executed when a user logs in.
# Check the documentation for more hook types.
hook_type = "player_login"
def __call__(self, *args, **kwargs):
print("LOGIN HOOK:", args, kwargs)