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,21 +117,47 @@ module.exports = {
b._client.on('system_chat', (data) => { b._client.on('system_chat', (data) => {
const json = parse1204(data.content) const json = parse1204(data.content)
const parsed = parsePlain(json) if(json.translate == '%s %s %s'){ // ChipmunkMod format
const split = parsed.split(': ') if(json.with && json.with[1] && json.with[2]){
const chatName = split.splice(0, 1)[0] const username = parsePlain(json.with[1])
const chatNameSplit = chatName.split(' ') const uuid = b.findUUID(username)
const nickname = chatNameSplit[chatNameSplit.length - 1] const nickname = b.findDisplayName(uuid)
const username = b.findRealName(chatName) const message = parsePlain(json.with[2].extra)
const uuid = b.findUUID(username) b.emit('chat', {
b.emit('chat', { json,
json, type: 'system',
type: 'system', uuid,
uuid, message,
message: split.join(': '), nickname,
nickname, username
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]
const chatNameSplit = chatName.split(' ')
const nickname = chatNameSplit[chatNameSplit.length - 1]
const username = b.findRealName(chatName)
const uuid = b.findUUID(username)
b.emit('chat', {
json,
type: 'system',
uuid,
message: split.join(': '),
nickname,
username
})
}
}) })
b._client.on('chat', (data) => { // Legacy chat for versions <1.19 b._client.on('chat', (data) => { // Legacy chat for versions <1.19
@ -142,7 +168,14 @@ module.exports = {
let username let username
let message let message
let uuid 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) { if (json.with && json.with.length >= 2) {
message = parsePlain(json.with[1]) message = parsePlain(json.with[1])
username = parsePlain(json.with[0]) username = parsePlain(json.with[0])