UNPKG

yoni-mcscripts-lib

Version:

为 Minecraft Script API 中的部分接口创建了 wrapper,并提供简单的事件管理器和任务管理器,另附有一些便于代码编写的一些小工具。

16 lines (13 loc) 655 B
import { Minecraft } from "../../basis.js"; import { hasInstance } from "../../lib/hasInstance.js"; import { Event } from "./Event.js"; export class VanillaEvent extends Event { static [Symbol.hasInstance](value: any){ if (hasInstance(value, VanillaEvent)) return true; return VanillaEvent.vanillaEventClassList.some(Class => value instanceof Class); } static vanillaEventClassList: Function[] = Object.getOwnPropertyNames(Minecraft) .filter(name => name.endsWith("Event") && typeof (Minecraft as any)[name] === "function") .map(name => (Minecraft as any)[name] as unknown as Function); }