Vanilla server support

This commit is contained in:
7cc5c4f330d47060 2024-07-31 01:08:51 -04:00
parent 2b87fd14cc
commit 12391e8db4
3 changed files with 36 additions and 15 deletions

View file

@ -1,3 +1,4 @@
const settings = require('../settings.json')
const console2 = require('./console.js')
const parse = require('../util/chatparse.js')
const parse1204 = require('../util/chatparse_1204.js')
@ -72,14 +73,26 @@ module.exports = {
b._client.on('chat', (data) => { // Legacy chat
const json = parse1204(data.message)
const parsed = parse(json).plain
const split = parsed.split(': ')
const chatName = split.splice(0, 1)[0]
const username = b.findRealName(chatName)
const uuid = b.findUUID(username)
b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message: split.join(': '), username })
let chatName
let username
let message;
let uuid;
if(b.host.options.isVanilla && json.translate === "chat.type.text"){ // Servers without Extras chat
message = parse(json.with[1]).plain;
username = parse(json.with[0]).plain;
uuid = b.findUUID(username);
} else { // Servers with Extras chat, such as Kaboom
const split = parsed.split(': ')
message = split.join(': ')
uuid = b.findUUID(username)
chatName = split.splice(0, 1)[0]
username = b.findRealName(chatName)
}
b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message, username })
})
b.on('chat', (data) => {
const msg = parse(data.json)
if(settings.logJSONmessages) console.log(data.json)
if (msg.plain.endsWith('\n\n\n\n\nThe chat has been cleared')) return
if (msg.plain.startsWith('Command set: ')) return
b.emit('plainchat', msg.plain)

View file

@ -97,7 +97,13 @@ module.exports = {
} else {
finalname = uuid
}
b.ccq.push(`/minecraft:tellraw ${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)}`)
}
}
}

View file

@ -44,15 +44,17 @@ module.exports = {
})
// Commandspy
b.add_sc_task('cspy', '/cspy on', true, true)
b.on('plainchat', (msg) => {
if (msg === 'Successfully disabled CommandSpy') {
b.sc_tasks.cspy.failed = 1
} else if (msg === 'Successfully enabled CommandSpy') {
b.sc_tasks.cspy.failed = 0
}
})
if(!b.host.options.isVanilla){
b.add_sc_task('cspy', '/cspy on', true, true)
b.on('plainchat', (msg) => {
if (msg === 'Successfully disabled CommandSpy') {
b.sc_tasks.cspy.failed = 1
} else if (msg === 'Successfully enabled CommandSpy') {
b.sc_tasks.cspy.failed = 0
}
})
}
// Gamemode
b.add_sc_task('gamemode', '/minecraft:gamemode creative', true)
b._client.on('game_state_change', (p) => {