Add use chat mode
This commit is contained in:
parent
d6db8547a3
commit
284ebf488e
1 changed files with 31 additions and 18 deletions
|
@ -1,4 +1,6 @@
|
||||||
const uuidToInt = require('../util/uuidtoint.js')
|
const uuidToInt = require('../util/uuidtoint.js')
|
||||||
|
const plainParser = require('../util/chatparse_plain.js')
|
||||||
|
const mcParser = require('../util/chatparse_mc.js')
|
||||||
const cs = {
|
const cs = {
|
||||||
x: 4,
|
x: 4,
|
||||||
y: 6,
|
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.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 () {
|
b.advanceccq = function () {
|
||||||
|
if(b.host.options.useChat) return
|
||||||
if (b.ccq[0] && b.ccq[0].length !== 0) {
|
if (b.ccq[0] && b.ccq[0].length !== 0) {
|
||||||
b._client.write('update_command_block', {
|
b._client.write('update_command_block', {
|
||||||
command: '/',
|
command: '/',
|
||||||
|
@ -63,12 +66,14 @@ module.exports = {
|
||||||
skinParts: 127, // Allow the second layer of the skin, when the bot is sudoed to do /skin
|
skinParts: 127, // Allow the second layer of the skin, when the bot is sudoed to do /skin
|
||||||
mainHand: 1 // Right hand
|
mainHand: 1 // Right hand
|
||||||
})
|
})
|
||||||
b.add_sc_task('cc', () => {
|
if (!b.host.options.useChat){
|
||||||
b.chat(b.refillCoreCmd)
|
b.add_sc_task('cc', () => {
|
||||||
}, true)
|
b.chat(b.refillCoreCmd)
|
||||||
b.add_sc_task('cc_size', () => {
|
}, true)
|
||||||
b.chat('/gamerule commandModificationBlockLimit 32768')
|
b.add_sc_task('cc_size', () => {
|
||||||
})
|
b.chat('/gamerule commandModificationBlockLimit 32768')
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
b.on('ccstart', () => {
|
b.on('ccstart', () => {
|
||||||
setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 2) }, 1000)
|
setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 2) }, 1000)
|
||||||
|
@ -107,20 +112,28 @@ module.exports = {
|
||||||
|
|
||||||
b.tellraw = (uuid, message) => {
|
b.tellraw = (uuid, message) => {
|
||||||
let finalname = ''
|
let finalname = ''
|
||||||
if (uuid === '@a') {
|
if(b.host.options.useChat){
|
||||||
finalname = '@a'
|
if(b.host.options.useAmpersandColorCodes){
|
||||||
} else if (uuid.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)) {
|
b.chat(mcParser(message).replaceAll("§", "&"))
|
||||||
finalname = `@a[nbt={UUID:[I;${uuidToInt(uuid)}]}]`
|
} else {
|
||||||
|
b.chat(plainParser(message))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
finalname = uuid
|
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}/)) {
|
||||||
|
finalname = `@a[nbt={UUID:[I;${uuidToInt(uuid)}]}]`
|
||||||
|
} else {
|
||||||
|
finalname = uuid
|
||||||
|
}
|
||||||
|
let tellrawCommand
|
||||||
|
if (b.host.options.isVanilla) {
|
||||||
|
tellrawCommand = 'tellraw'
|
||||||
|
} else {
|
||||||
|
tellrawCommand = 'minecraft:tellraw'
|
||||||
|
}
|
||||||
|
b.ccq.push(`/${tellrawCommand} ${finalname} ${JSON.stringify(message)}`)
|
||||||
}
|
}
|
||||||
let tellrawCommand
|
|
||||||
if (b.host.options.isVanilla) {
|
|
||||||
tellrawCommand = 'tellraw'
|
|
||||||
} else {
|
|
||||||
tellrawCommand = 'minecraft:tellraw'
|
|
||||||
}
|
|
||||||
b.ccq.push(`/${tellrawCommand} ${finalname} ${JSON.stringify(message)}`)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue