mirror of
https://code.chipmunk.land/Yaode_owo/Object.git
synced 2026-12-02 13:06:51 +02:00
60 lines
2.3 KiB
JavaScript
60 lines
2.3 KiB
JavaScript
// no one gonna see this.
|
|
|
|
// process.env.DEBUG = 'minecraft-protocol';
|
|
const mc = require('minecraft-protocol');
|
|
const ChatParse = require("./chatparser.js");
|
|
|
|
let cat = null
|
|
|
|
function createBot() {
|
|
|
|
const bot = mc.createClient({
|
|
host: 'kaboom.pw',
|
|
port: 25565,
|
|
username: 'catparser', // 0
|
|
version: "1.21.11",
|
|
hideErrors: true
|
|
});
|
|
|
|
let chatParser = new ChatParse(bot.version).inject(bot); // load catparser function
|
|
|
|
bot.on('error', (e) => { if (bot !== undefined) bot.end(e.message) });
|
|
|
|
bot.on('end', (reason) => { // Memory leak 100%.
|
|
console.log(`Bot disconnect: ${reason}\nReconnect in 6 seconds...`);
|
|
chatParser = null;
|
|
setTimeout(() => {
|
|
createBot();
|
|
}, 6000);
|
|
});
|
|
|
|
bot.on('custom_playerChat', (message, playerChat, packet) => {
|
|
console.log(`[PlayerChat] ${message}`);
|
|
});
|
|
|
|
bot.on('custom_disguisedChat', (message, disguisedChat, packet) => {
|
|
console.log(`[DisguisedChat] ${message}`);
|
|
});
|
|
|
|
bot.on('custom_systemChat', (message, systemChat, packet) => {
|
|
console.log(`[SystemChat] ${message}`);
|
|
console.log(JSON.stringify(systemChat.jsonMsg.message))
|
|
});
|
|
|
|
// Kick message and disconnect message
|
|
bot.on('kick_disconnect', (kicked) => {
|
|
console.log(chatParser.parseChatComponent(chatParser.processNBTComponent(kicked.reason)));
|
|
})
|
|
bot.on('disconnect', (kicked) => {
|
|
console.log(chatParser.parseChatComponent(chatParser.processNBTComponent(kicked.reason)));
|
|
})
|
|
|
|
}
|
|
|
|
createBot();
|
|
|
|
|
|
/*
|
|
/minecraft:tellraw @a {"text":"root ","extra":[{"text":"child 1 ","color":"red","extra":[{"text":"sub ","color":"aqua","underlined":true}," sub 2 "]},{"text":"child 2 ","underlined":true,"italic":true,"color":"yellow","extra":["some thing ",{"text":"without underline","underlined":false,"italic":false}," more thing ",{"translate":"translate %s %s %s","color":"light_purple","italic":true,"with":["normal",{"text":"forced","italic":false},"back"]}]}]}
|
|
tellraw @a [ {text:"root (white)",extra:[{text:" child 1 (red)",color:red,extra:["§e sub (yellow)"]},"§5§rchild 2 (white)"]}, "\n", {translate:"translation.test.complex",with:["1","2","3","shouldnt see this"]}, "\n", {translate:"translation.test.escape",with:["a","b","shouldnt see this"]}, "§c\n", "white ", {text:"§eroot ",extra:[{text:"child 1",color:green}]}, "\n", "§9blue §rreset §c§nred§r reset (§mwhite§r)"]
|
|
*/ |