From 46622be1822e4b15825c2827f6ebbc864881b0d6 Mon Sep 17 00:00:00 2001 From: student_2333 Date: Wed, 19 Apr 2023 17:59:04 +0800 Subject: [PATCH] refactor: #1200 (#1203) --- ScriptEngine/assets/BaseLib.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ScriptEngine/assets/BaseLib.py b/ScriptEngine/assets/BaseLib.py index 8d836306e1..9cb0702d29 100644 --- a/ScriptEngine/assets/BaseLib.py +++ b/ScriptEngine/assets/BaseLib.py @@ -1,4 +1,4 @@ -def _llse_python_base_lib_listener(event): +def _llse_python_base_lib_handle(event): def wrapper(func): __builtins__.mc.listen(event, func) return func @@ -6,10 +6,15 @@ def wrapper(func): return wrapper -def _llse_python_base_lib_command_callback(self, func): - self.setCallback(func) - return func +def _llse_python_base_lib_command_handle(self, func=None): + def wrapper(func): + self.setCallback(func) + return func + + if func: + return wrapper(func) + return wrapper -setattr(__builtins__, "listener", _llse_python_base_lib_listener) -setattr(__builtins__.LLSE_Command, "callback", _llse_python_base_lib_command_callback) +setattr(__builtins__, "handle", _llse_python_base_lib_handle) +setattr(__builtins__.LLSE_Command, "handle", _llse_python_base_lib_command_handle)