From aaf1b340723fa3c2e12d1b3a02101b883d84d588 Mon Sep 17 00:00:00 2001 From: PHIDIAS Date: Mon, 12 Oct 2026 14:55:02 +0900 Subject: [PATCH] Update index.ts --- index.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/index.ts b/index.ts index 5c5e615..fa311d7 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,5 @@ import type * as lib from '@clusterio/lib'; +import type {Instance, InstancePluginContext} from '@clusterio/host'; import {Type, Static} from '@sinclair/typebox'; export class ChatEvent { @@ -10,20 +11,14 @@ export class ChatEvent { static permission = null; constructor( - public instanceName: string, + public instance: Instance, public action: string, public content: string, - ) { - } + ) {} - static jsonSchema = Type.Object({ - 'instanceName': Type.String(), - 'action': Type.String(), - 'content': Type.String(), - }); - - static fromJSON(json: Static) { - return new this(json.instanceName, json.action, json.content); + static async fromContext(context: InstancePluginContext) { + const instance = context.instance; + return new InstancePlugin(context.instance, context.instanceName, context.action, context.content); } }