refactor: remove some shit
This commit is contained in:
Vendored
+2
-2
@@ -13,7 +13,7 @@ declare class Event {
|
||||
) => boolean | void
|
||||
): boolean;
|
||||
|
||||
/** 客户端登录后事件 */
|
||||
/** 客户端登录后事件(不可以拦截) */
|
||||
static listen(
|
||||
/** 事件名 */
|
||||
event: "onClientLogin",
|
||||
@@ -27,7 +27,7 @@ declare class Event {
|
||||
serverXuid: string,
|
||||
/** 玩家在客户端的xuid */
|
||||
clientXuid: string
|
||||
) => bool
|
||||
) => void
|
||||
): boolean;
|
||||
|
||||
/** 天气改变事件事件 */
|
||||
|
||||
+8
-10
@@ -1,11 +1,11 @@
|
||||
/** 事件创建函数 @type {function(string,string):boolean} */
|
||||
const CallEvent = ll.import("GMLIB_API", "callCustomEvent");
|
||||
const CallEvent = ll.import("GMLIB_Event_API", "callCustomEvent");
|
||||
/** 获取事件ID函数 @type {function():string} */
|
||||
const getNextEventId = ll.import("GMLIB_Event_API", "getNextScriptEventId");
|
||||
|
||||
/** 事件类 */
|
||||
class Event {
|
||||
constructor() {
|
||||
throw new Error("Static class cannot be instantiated");
|
||||
}
|
||||
constructor() { throw new Error("Static class cannot be instantiated"); }
|
||||
|
||||
/**
|
||||
* 监听事件
|
||||
@@ -14,17 +14,15 @@ class Event {
|
||||
* @returns {boolean} 是否创建成功
|
||||
*/
|
||||
static listen(event, callback) {
|
||||
let eventId = "GMLIB_Event_" + Math.random().toString(16).slice(2);
|
||||
let eventId = getNextEventId();
|
||||
ll.export(callback, event, eventId);
|
||||
let result = CallEvent(event, eventId);
|
||||
if (!result) {
|
||||
logger.error(`Cannot listen event "${event}"!`);
|
||||
logger.error(`Event "${event}" No Found!`);
|
||||
logger.error(`Cannot listen event "${event}" !`);
|
||||
logger.error(`GMLIB Script Event "${event}" does not exist !`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Event
|
||||
};
|
||||
module.exports = {Event};
|
||||
Reference in New Issue
Block a user