Add use chat mode

This commit is contained in:
7cc5c4f330d47060 2024-09-11 23:38:34 -04:00
parent d6db8547a3
commit 284ebf488e
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:e+4tcZut1nBpe10PqjaO+Rvie0Q7W4qIvFzcUw+7riA

View file

@ -1,4 +1,6 @@
const uuidToInt = require('../util/uuidtoint.js')
const plainParser = require('../util/chatparse_plain.js')
const mcParser = require('../util/chatparse_mc.js')
const cs = {
x: 4,
y: 6,
@ -17,6 +19,7 @@ module.exports = {
b.refillCoreCmd = `/fill ~ 55 ~ ~${cs.x - 1} ${54 + cs.y} ~${cs.z - 1} command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`
b.advanceccq = function () {
if(b.host.options.useChat) return
if (b.ccq[0] && b.ccq[0].length !== 0) {
b._client.write('update_command_block', {
command: '/',
@ -63,12 +66,14 @@ module.exports = {
skinParts: 127, // Allow the second layer of the skin, when the bot is sudoed to do /skin
mainHand: 1 // Right hand
})
if (!b.host.options.useChat){
b.add_sc_task('cc', () => {
b.chat(b.refillCoreCmd)
}, true)
b.add_sc_task('cc_size', () => {
b.chat('/gamerule commandModificationBlockLimit 32768')
})
}
})
b.on('ccstart', () => {
setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 2) }, 1000)
@ -107,6 +112,13 @@ module.exports = {
b.tellraw = (uuid, message) => {
let finalname = ''
if(b.host.options.useChat){
if(b.host.options.useAmpersandColorCodes){
b.chat(mcParser(message).replaceAll("§", "&"))
} else {
b.chat(plainParser(message))
}
} else {
if (uuid === '@a') {
finalname = '@a'
} else if (uuid.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)) {
@ -123,4 +135,5 @@ module.exports = {
b.ccq.push(`/${tellrawCommand} ${finalname} ${JSON.stringify(message)}`)
}
}
}
}