Add support for message types other than 4 to chat parser

This commit is contained in:
7cc5c4f330d47060 2024-07-18 02:34:59 -04:00
parent 2992a3ba5d
commit bac639243a

View file

@ -1,6 +1,16 @@
const console2 = require("./console.js")
const parse = require("../util/chatparse.js")
const parse1204 = require("../util/chatparse_1204.js")
const messageTypes=[
"",
"chat.type.emote",
"commands.message.display.incoming",
"",
"",
"chat.type.announcement",
"",
""
]
module.exports={
load:()=>{
//console.log("Loaded on global")
@ -15,6 +25,7 @@ module.exports={
}
*/
b._client.on("profileless_chat",(data)=>{
console.log(data)
if(data.type==4){
const json=parse1204(data.message);
const parsed=parse(json)[1];
@ -23,12 +34,43 @@ module.exports={
const username=b.findRealName(chatName);
const uuid=b.findUUID(username)
b.emit("chat",{json,type:"profileless",uuid,message: split.join(": "), username})
} else {
b.emit("chat",{
json: {
translate: messageTypes[data.type],
color:data.type==2?"gray":"reset",
with:[
parse1204(data.name),
parse1204(data.message)
]
},
type:"profileless",
uuid:"00000000-0000-0000-0000-000000000000",
message: parse(parse1204(data.message))[1],
username:parse(parse1204(data.name))[1]
})
}
})
b._client.on("player_chat",(data)=>{
console.log(data)
if(data.type==4){
b.emit("chat",{json:parse1204(data.unsignedChatContent),type:"player",uuid:data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName))[1]})
} else {
b.emit("chat",{
json: {
translate: messageTypes[data.type],
color:data.type==2?"gray":"reset",
with:[
parse1204(data.networkName),
data.plainMessage
]
},
type:"player",
uuid:data.senderUuid,
message: parse(data.plainMessage)[1],
username:parse(parse1204(data.networkName))[1]
})
}
})
b._client.on("system_chat",(data)=>{