This commit is contained in:
Madeline 2024-11-08 23:17:54 -05:00
parent fb3328b669
commit b02f7156a5
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:oO39knK4Ms3Sk93ZEui6XuFW9LnLbXsy5kQ8I1GT9j8

View file

@ -45,7 +45,7 @@ for (const plugin of bpl) {
}
export default function defaultad (b) {
export default function load (b) {
b.messageCount = 0
b.chatDisabledUntil = 0
b.interval.antiSpam = setInterval(() => {
@ -65,7 +65,12 @@ export default function defaultad (b) {
}
})
b._client.on('profileless_chat', (data) => {
let messageType = b.messageTypes[data.type]
let messageType;
if(data.type.registryIndex){
messageType = b.messageTypes[data.type.registryIndex-1]
} else {
messageType = b.messageTypes[data.type]
}
if (messageType === undefined) messageType = { translation_key: '%s', parameters: ['content'] }
const json = { translate: messageType.translation_key, with: [] }
messageType.parameters.forEach((item, i) => {
@ -96,7 +101,12 @@ export default function defaultad (b) {
})
b._client.on('player_chat', (data) => {
let messageType = b.messageTypes[data.type]
let messageType;
if(data.type.registryIndex){
messageType = b.messageTypes[data.type.registryIndex-1]
} else {
messageType = b.messageTypes[data.type]
}
if (messageType === undefined) messageType = { translation_key: '%s', parameters: ['content'] }
const json = { translate: messageType.translation_key, with: [] }
messageType.parameters.forEach((item, i) => {
@ -108,7 +118,7 @@ export default function defaultad (b) {
}
} else if (item === 'sender') {
json.with[i] = parse1204(data.networkName)
} else if (item === 'target') {
} else if (item === 'target' && data.networkTargetName) {
json.with[i] = parse1204(data.networkTargetName)
}
})
@ -195,4 +205,4 @@ export default function defaultad (b) {
b.emit('plainchat', msgPlain, data.type, data.subtype)
b.displayChat(data.type, data.subtype, `${msgConsole}\x1b[0m`)
})
}
}