UNPKG

yoni-mcscripts-lib

Version:

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

14 lines (13 loc) 588 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) { if (hasInstance(value, VanillaEvent)) return true; return VanillaEvent.vanillaEventClassList.some(Class => value instanceof Class); } static vanillaEventClassList = Object.getOwnPropertyNames(Minecraft) .filter(name => name.endsWith("Event") && typeof Minecraft[name] === "function") .map(name => Minecraft[name]); }