Skip to content

Commit

Permalink
增加对事件过滤参数ScriptEventMessageFilterOptions的适配
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvigarabis committed Oct 3, 2023
1 parent 87f17fd commit 000d026
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { registerMinecraftEventOptionResolvers as reg1 } from "./EntityEventOptions.js";
import { registerMinecraftEventOptionResolvers as reg2 } from "./EntityDataDrivenTriggerEventOptions.js";
import { registerMinecraftEventOptionResolvers as reg3 } from "./ScriptEventMessageFilterOptions.js";

export function registerMinecraftEventOptionResolvers(){
reg1();
reg2();
reg3();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Minecraft } from "../../../basis.js";
import { EventRegistry } from "../../EventRegistry.js";

export interface ScriptEventMessageFilterOptions extends Minecraft.ScriptEventMessageFilterOptions {
}

export function conditionScriptEventMessageFilterOptions(namespaces: string[], options: ScriptEventMessageFilterOptions): boolean {
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);
}

})();

}

0 comments on commit 000d026

Please sign in to comment.