feat: update client support mcsso

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2020-09-24 10:33:38 +08:00
parent f8046e38be
commit df266905f2
2 changed files with 49 additions and 24 deletions

View File

@@ -3,12 +3,12 @@ import { $ } from './color'
export function attachEvents(client) {
client.on('chat', (packet) => {
// Listen for chat messages and echo them back.
var jsonMsg = JSON.parse(packet.message);
var jsonMsg = JSON.parse(packet.message)
console.log($(jsonMsg))
})
client.on('state', (newState, oldState) => {
console.log('Client Change State', oldState, 'to', newState)
let targetServer = process.argv[3]
let targetServer = process.argv[6]
if (newState == "play" && targetServer) {
setTimeout(() => {
client.write('chat', {
@@ -24,4 +24,10 @@ export function attachEvents(client) {
} else if (packet.health > 0) {
}
})
client.on('kick_disconnect', (packet) => {
console.log($(packet.reason))
})
client.on('disconnect', (packet) => {
console.log($(packet.reason))
})
}