-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加对事件过滤参数ScriptEventMessageFilterOptions的适配
- Loading branch information
1 parent
87f17fd
commit 000d026
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
src/yoni/event/adapting/eventOptions/MinecraftEventOptionResolvers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/yoni/event/adapting/eventOptions/ScriptEventMessageFilterOptions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
})(); | ||
|
||
} |