diff --git a/cmds/liter-server/globals.go b/cmds/liter-server/globals.go index 9f718b0..76e508a 100644 --- a/cmds/liter-server/globals.go +++ b/cmds/liter-server/globals.go @@ -543,11 +543,11 @@ type ServerIns struct { Target string `json:"target" yaml:"target"` ServerNames []string `json:"names" yaml:"names"` // HandlePing is useful if you want to hide online players from others who won't join the server - HandlePing bool `json:"handle-ping" yaml:"handle-ping"` + HandlePing bool `json:"handlePing" yaml:"handle-ping"` // Motd only use when HandlePing is true Motd string `json:"motd" yaml:"motd"` // MotdFailed will be send back when the ping connection failed on the server - MotdFailed string `json:"motd-failed" yaml:"motd-failed"` + MotdFailed string `json:"motdFailed" yaml:"motd-failed"` } func getServers()(servers []*ServerIns, listHash string){ diff --git a/cmds/liter-server/handler.go b/cmds/liter-server/handler.go index 2bf571d..9a024ed 100644 --- a/cmds/liter-server/handler.go +++ b/cmds/liter-server/handler.go @@ -65,7 +65,7 @@ func (s *Server)handle(c *liter.Conn, cfg *Config){ noforward := <-s.scripts.Emit(script.NewEvent("handshake", Map{ "client": wc.Exports(), "handshake": hp, - "target": &svr, // to allow changes to the target + "target": *svr, // do not allow changes })) if wc.Closed() { return diff --git a/script/types/lib/index.d.ts b/script/types/lib/index.d.ts index 75733b8..0f9ccb7 100644 --- a/script/types/lib/index.d.ts +++ b/script/types/lib/index.d.ts @@ -32,12 +32,12 @@ declare global { error(...args: any[]): void } - function setInterval(handler: Function, timeout?: number, ...arguments: any[]): Object - function setTimeout(handler: Function, timeout?: number, ...arguments: any[]): Object - function setImmediate(handler: Function, ...arguments: any[]): Object - function clearInterval(id: Object | undefined): void - function clearTimeout(id: Object | undefined): void - function clearImmediate(id: Object | undefined): void + function setInterval(handler: Function, timeout?: number, ...arguments: any[]): Readonly + function setTimeout(handler: Function, timeout?: number, ...arguments: any[]): Readonly + function setImmediate(handler: Function, ...arguments: any[]): Readonly + function clearInterval(id: Readonly | undefined): void + function clearTimeout(id: Readonly | undefined): void + function clearImmediate(id: Readonly | undefined): void type Event = _Event & T @@ -105,17 +105,34 @@ declare global { json(): T } + interface HandshakePkt { + protocol: number + addr: string + addition: string + port: number + nextState: number + } + + interface ServerIns { + id: string + target: string + serverNames: string[] + handlePing: boolean + motd: string + motdFailed: string + } + + type HandshakeEvent = Event<{ + client: Conn + handshake: Readonly + target: Readonly + }> + type ServeEvent = Event<{ - player?: PlayerInfo + player?: PlayerInfo // undefined means serve for ping connection client: Conn server: Conn - handshake: { - protocol: number - addr: string - addition: string - port: number - nextState: number - } + handshake: Readonly }> type PacketEvent = Event<{ diff --git a/script/types/package.json b/script/types/package.json index 3ef996a..51b7ab0 100644 --- a/script/types/package.json +++ b/script/types/package.json @@ -1,6 +1,6 @@ { "name": "go-liter-plugin", - "version": "1.0.2", + "version": "1.0.3", "description": "Typescript definitions for Go Liter script", "types": "./lib/index.d.ts", "scripts": {