Info in chatparser.js

This commit is contained in:
Yaode_owo 2024-12-06 11:21:06 -05:00
parent e645c7193b
commit ac303c5fc6
2 changed files with 43 additions and 17 deletions

View file

@ -5,15 +5,13 @@
*
* Language File Version: 1.21.1
*
* ChatParser Version: 1.47 (Test)
* ChatParser Version: 1.47
*
* Update:
* - Fix Color and format
* - ADDED CURSED CODE
* - Rewrite something
*
* Knowns Issues:
* - Invalid Emojis
* - Invalid Emojis (as i know PrismarineJS fixing...)
* - Spawnpoint Number
*
* Report Issue: https://code.chipmunk.land/Yaode_owo/Minecraft-protocol-1.20.4-chat-parser/issues/new
@ -540,12 +538,25 @@ function parseMinecraftMessage(component) {
let NowColor = parseMinecraftColor(comp?.color);
let NowFormat = parseMinecraftFormat(comp);
if (VaildText(comp)) {
text += NowColor.have ? NowColor.color : prevColor.have ? prevColor.color : ansiMap['white'];
if (NowFormat.have || prevFormat.have) {
text += NowFormat.have ? NowFormat.format : prevFormat.format;
if (VaildText(comp)) { // Idk, but it work atleast.
if (NowColor.have || prevColor.have) {
if (NowColor.have) {
text += NowColor.color;
shouldReset = true;
} else if (prevColor.have) {
text += prevColor.color;
} else {
text += ansiMap['white'];
}
}
if (NowFormat.have || prevFormat.have) {
if (NowFormat.have) {
text += NowFormat.format
shouldReset = true;
} else if (prevFormat.have) {
prevFormat.format;
}
}
shouldReset = true;
}
if (typeof comp.text === 'string' || typeof comp.text === 'number') {
@ -624,6 +635,7 @@ function parseMinecraftMessage(component) {
text += extractText(subComp, NowColor.have ? NowColor : prevColor, NowFormat.have ? NowFormat : prevFormat) + `${VaildText(comp) ? NowFormat.have ? NowFormat.format : "" : ""}${VaildText(comp) ? NowColor.have ? NowColor.color : "" : ""}`;
});
}
if (shouldReset) {
text += ansiMap['reset']
}
@ -797,4 +809,4 @@ function cboutputNoColor(component) {
return extractText(component);
}
module.exports = { inject, parseMinecraftMessage, parseMinecraftMessageNoColor, cboutput, simplify, FixEmptyKeys, processNBTComponent, ansiMap };
module.exports = { inject, parseMinecraftMessage, parseMinecraftMessageNoColor, cboutput, cboutputNoColor, simplify, FixEmptyKeys, processNBTComponent, ansiMap };

View file

@ -1,7 +1,7 @@
/**
* Minecraft Version: *Info in chat parser*
*
* ChatParser Version: 1.47 (Test)
* ChatParser Version: 1.47, 1.47 (Test)
*
* If you are using a newer version of ChatParser but still using outdated methods from an old version,
* it may either throw an error or nothing happened.
@ -12,21 +12,24 @@
*
* In version 1.47 and newer, playerChat.message no longer exists.
*
* TODO: i guess:
* I guess:
* - Kick parser
* - Reconnect?
* - Should i make lightweight version of chatparser?
* - This is last chatparser of this version 1.20.4, if nothing wrong.
*/
const mc = require('minecraft-protocol');
const ChatParse = require("./chatparser.js");
function createBot() {
const bot = mc.createClient({
// host: '95.216.192.50', // kaboom
host: 'chipmunk.land', // Chipmunk
// host: 'chipmunk.land', // Chipmunk
// host: '168.100.225.224', // Neko
port: 25565,
username: 'catparser', // cat
version: "1.20.4", // 1.20.5, 1.20.6, Not support 1.21 or higher
version: "1.21.3", // 1.20.5, 1.20.6, Not support 1.21 or higher
});
ChatParse.inject(bot); // load catparser function
@ -36,12 +39,16 @@ bot.on('error', (e) => {
});
bot.on('end', (reason) => {
console.log(`Bot disconnect: ${reason}`);
console.log(`Bot disconnect: ${reason}\nReconnect in 6 seconds...`);
setTimeout(() => {
createBot();
}, 6e3);
return;
});
bot.on('custom_playerChat', (message, playerChat, packet) => {
console.log(`[PlayerChat] ${message}`);
console.log(JSON.stringify(playerChat.jsonMsg.message))
});
bot.on('custom_profilelessChat', (message, profilelessChat, packet) => {
@ -53,6 +60,7 @@ bot.on('custom_systemChat', (message, systemChat, packet) => {
});
/*
// Kick message and disconnect message
bot.on('kick_disconnect', (kick) => {
console.log(ChatParse.parseMinecraftMessage(kicked.reason));
@ -63,9 +71,11 @@ bot.on('disconnect', (kick) => {
bot.on('custom_actionBar', (message, actionBar, packet) => {
console.log(`[ActionBar] ${message}`);
});
*/
/*
bot.on('custom_bossBar', (message, bossBar, packet) => {
switch (bossBar.action) {
case 0:
@ -162,4 +172,8 @@ bot.on('custom_allMessage', (chatType, message, messagePacket, packet) => {
break;
}
})
*/
*/
}
createBot();