88 lines
No EOL
2.5 KiB
JavaScript
88 lines
No EOL
2.5 KiB
JavaScript
// 1.3 chatparser
|
|
|
|
const mc = require('minecraft-protocol');
|
|
const ChatParse = require("./chatparser.js");
|
|
const bot = mc.createClient({
|
|
// host: '95.216.192.50', // kaboom
|
|
// host: 'chipmunk.land',
|
|
// host: '168.100.225.224', // Neko
|
|
port: 25565,
|
|
username: 'catparser', // cat
|
|
version: "1.20.4", // Not support 1.21
|
|
});
|
|
|
|
ChatParse.inject(bot); // load chatparser function
|
|
|
|
bot.on('custom_playerchat', (message, playerchat, packet) => {
|
|
console.log(`[PlayerChat] ${message}`);
|
|
});
|
|
|
|
bot.on('custom_profilelesschat', (message, profilelesschat, packet) => {
|
|
console.log(`[ProfilelessChat] ${message}`);
|
|
});
|
|
bot.on('custom_systemchat', (message, systemchat, packet) => {
|
|
if (systemchat?.jsonMsg?.translate === "advMode.setCommand.success") return; // if you have core and dont want see "Command set: %s"
|
|
console.log(`[SystemChat] ${message}`);
|
|
});
|
|
|
|
bot.on('custom_actionbar', (message, actionbar, packet) => {
|
|
console.log(`[ActionBar] ${message}`);
|
|
});
|
|
|
|
bot.on('custom_bossbar', (message, bossbar, packet) => {
|
|
switch (bossbar.action) {
|
|
case 1:
|
|
console.log(`[BossBar Removed] ${bossbar.uuid}`);
|
|
break;
|
|
case 0:
|
|
console.log(`[BossBar Added] ${bossbar.message}\n${bossbar.health}\n${bossbar.color}\n${bossbar.dividers}\n${bossbar.flags}`);
|
|
break;
|
|
|
|
case 2:
|
|
console.log(`[BossBar Health] ${bossbar.health}`)
|
|
break;
|
|
|
|
case 3:
|
|
console.log(`[BossBar Message] ${bossbar.message}`)
|
|
// console.log(`[BossBar NoColor Message] ${bossbar.nocolor_message}`)
|
|
break;
|
|
|
|
case 4:
|
|
console.log(`[BossBar Color] ${bossbar.color}`)
|
|
console.log(`[BossBar Style] ${bossbar.dividers}`)
|
|
break;
|
|
|
|
case 5:
|
|
console.log(`[BossBar Flags] ${bossbar.flags}`)
|
|
break;
|
|
}
|
|
});
|
|
|
|
bot.on('custom_title', (message, title, packet) => {
|
|
console.log(`[Title] ${message}`)
|
|
});
|
|
|
|
bot.on('custom_subtitle', (message, title, packet) => {
|
|
console.log(`[SubTitle] ${message}`)
|
|
});
|
|
|
|
bot.on('custom_timetitle', (_, title, packet) => {
|
|
console.log(`[TitleTimes] fadeIn: ${title.fadeIn}\nstay: ${title.stay}\nfadeOut: ${title.fadeOut}`);
|
|
});
|
|
|
|
/*
|
|
bot.on('custom_allchat', (chatType, message, messagePacket, packet) => {
|
|
if (chatType === "actionbar" || chatType === "bossbar" || chatType === "title" || chatType === "subtitle" || chatType === "timetitle") return;
|
|
if (chatType === "systemchat" && messagePacket?.jsonMsg?.translate === "advMode.setCommand.success") return; // if you have core and dont want see "Command set: %s"
|
|
console.log(`${chatType}: ${message}`)
|
|
})
|
|
|
|
*/
|
|
|
|
bot.on('login', () => {
|
|
console.log(`Bot Joined!`);
|
|
});
|
|
|
|
bot.on('error', (err) => {
|
|
console.error(err);
|
|
}); |