UNPKG

yoni-mcscripts-lib

Version:

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

25 lines (24 loc) 887 B
import { Minecraft } from "../../../basis.js"; import { EventRegistry } from "../../EventRegistry.js"; export function conditionScriptEventMessageFilterOptions(namespaces, options) { for (const namespace of namespaces) { if (options.namespaces.includes(namespace)) return true; } return false; } export function registerMinecraftEventOptionResolvers() { (function () { let registry = EventRegistry.getRegistry(Minecraft.ScriptEventCommandMessageAfterEvent); registry.extraOption = true; registry.extraOptionResolver = (event, options) => { const { id } = event; let namespace = ""; for (const c of id) { if (c !== ":") namespace += c; } return conditionScriptEventMessageFilterOptions([namespace], options); }; })(); }