Add prefix selfcare

This commit is contained in:
7cc5c4f330d47060 2024-09-19 23:27:00 -04:00
parent 084eb15db8
commit 86275ef8ed
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:e+4tcZut1nBpe10PqjaO+Rvie0Q7W4qIvFzcUw+7riA

View file

@ -1,3 +1,6 @@
const parsePlain = require('../util/chatparse_plain.js')
const parseMc = require('../util/chatparse_mc_withHex.js')
const settings = require('../settings.json')
class SCTask {
constructor (failTask, startFailed = false) {
/*
@ -77,11 +80,44 @@ module.exports = {
b._client.write('client_command', { actionId: 0 }) // Simulates respawning
b.sc_tasks.respawn.failed = 0
})
b.on('chat_unparsed', (data) => {
if (data.json.translate === 'chat.disabled.options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'chat.disabled.options') ||
data.json.translate === 'Chat disabled in client options' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'Chat disabled in client options')) {
b.sc_tasks.respawn.failed = 1
}
})
// Prefix tablist ads
if (!b.host.options.isVanilla) {
b.adPrefix = {
translate: '[%s]',
color: 'white',
with: [
{
translate: '%s: %s',
color: settings.colors.secondary,
with: [
{
text: 'Prefix'
},
{
text: b.prefix[0],
color: settings.colors.primary
}
]
}
]
}
b.add_sc_task('playerlist_ads', () => {
b.chat(`/prefix ${parseMc(b.adPrefix).replaceAll('§', '&')}`)
b.sc_tasks.playerlist_ads.failed = 0
})
b.on('playerdata', (uuid, displayName) => {
if (uuid === b._client.uuid && !displayName.startsWith(parsePlain(b.adPrefix))) {
b.sc_tasks.playerlist_ads.failed = 1
}
})
}
}
}