Add chipmunk mod format

This commit is contained in:
7cc5c4f330d47060 2024-09-02 15:52:27 -04:00
parent 9658c63dcd
commit 4cf86f31c1
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:e+4tcZut1nBpe10PqjaO+Rvie0Q7W4qIvFzcUw+7riA

View file

@ -117,6 +117,31 @@ module.exports = {
b._client.on('system_chat', (data) => {
const json = parse1204(data.content)
if(json.translate == '%s %s %s'){ // ChipmunkMod format
if(json.with && json.with[1] && json.with[2]){
const username = parsePlain(json.with[1])
const uuid = b.findUUID(username)
const nickname = b.findDisplayName(uuid)
const message = parsePlain(json.with[2].extra)
b.emit('chat', {
json,
type: 'system',
uuid,
message,
nickname,
username
})
} else {
b.emit('chat', {
json,
type: 'system',
uuid: "00000000-0000-0000-0000-000000000000",
message: "",
nickname: "",
username: ""
})
}
} else { // Generic system chat format
const parsed = parsePlain(json)
const split = parsed.split(': ')
const chatName = split.splice(0, 1)[0]
@ -132,6 +157,7 @@ module.exports = {
nickname,
username
})
}
})
b._client.on('chat', (data) => { // Legacy chat for versions <1.19
@ -142,7 +168,14 @@ module.exports = {
let username
let message
let uuid
if (b.host.options.isVanilla && json.translate === 'chat.type.text') { // Servers without Extras chat
if(json.translate == '%s %s %s'){ // ChipmunkMod format
if(json.with && json.with[1] && json.with[2]){
username = parsePlain(json.with[1])
uuid = b.findUUID(username)
nickname = b.findDisplayName(uuid)
message = parsePlain(json.with[2].extra)
}
} else if (b.host.options.isVanilla && json.translate === 'chat.type.text') { // Servers without Extras chat
if (json.with && json.with.length >= 2) {
message = parsePlain(json.with[1])
username = parsePlain(json.with[0])