Info in chatparser.js
This commit is contained in:
parent
82576a1bea
commit
e645c7193b
2 changed files with 439 additions and 223 deletions
|
@ -1,21 +1,22 @@
|
|||
/**
|
||||
* Minecraft-protocol version: 1.50.0
|
||||
*
|
||||
* Minecraft Version: 1.20.4 (Basically should support 1.20.5 and 1.20.6)
|
||||
* Minecraft Version: 1.20.4 (Basically support 1.20.5 and 1.20.6)
|
||||
*
|
||||
* Language File Version: 1.21.1
|
||||
*
|
||||
* Version: 1.44
|
||||
* ChatParser Version: 1.47 (Test)
|
||||
*
|
||||
* Update:
|
||||
* - Add 0 type player chat and profileless chat, uh useless
|
||||
* Update:
|
||||
* - Fix Color and format
|
||||
* - ADDED CURSED CODE
|
||||
* - Rewrite something
|
||||
*
|
||||
* Knowns Issues:
|
||||
* - Invalid Emojis
|
||||
* - Invalid Emojis
|
||||
* - Spawnpoint Number
|
||||
*
|
||||
* Report Issue: https://code.chipmunk.land/Yaode_owo/Minecraft-protocol-1.20.4-chat-parser/issues/new
|
||||
* Report Issue: https://code.chipmunk.land/Yaode_owo/Minecraft-protocol-1.20.4-chat-parser/issues/new
|
||||
*/
|
||||
|
||||
|
||||
|
@ -23,7 +24,7 @@ const lang = require("./en_us.json"); // translate message
|
|||
|
||||
function simplify(data) {
|
||||
try {
|
||||
if (data === undefined || data === null) return '\x1B[91m*** Component is undefined or missing ***\x1B[0m';
|
||||
if (data === undefined || data === null) return undefined;
|
||||
if (typeof data !== "object") return data;
|
||||
function transform(value, type) {
|
||||
if (type === 'compound') {
|
||||
|
@ -42,11 +43,40 @@ function simplify(data) {
|
|||
return transform(data.value, data.type);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return '\x1B[91m*** An unexpected error occurred while processing the component ***\x1B[0m';
|
||||
// return '\x1B[90m*** When is component is sus ***\x1B[0m';
|
||||
return '*** An unexpected error occurred while processing the component ***';
|
||||
// return '*** When is component is sus ***';
|
||||
}
|
||||
}
|
||||
|
||||
function FixEmptyKeys(obj) {
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(FixEmptyKeys);
|
||||
} else if (typeof obj === 'object' && obj !== null) {
|
||||
const newObj = {};
|
||||
for (const key in obj) {
|
||||
const newKey = key === '' ? 'text' : key;
|
||||
newObj[newKey] = FixEmptyKeys(obj[key]);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function processNBTComponent(data) {
|
||||
try {
|
||||
if (data === undefined || data === null) return undefined;
|
||||
if (typeof data !== "object") return data;
|
||||
return FixEmptyKeys(simplify(data));
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return '*** An unexpected error occurred while processing the component ***';
|
||||
}
|
||||
}
|
||||
|
||||
function VaildText(comp) {
|
||||
if ((comp || comp !== "") && (comp.text || comp.text !== "") && (comp.keybind || comp.keybind !== "") && (comp.translate || comp.translate !== "")) return true
|
||||
return false;
|
||||
}
|
||||
|
||||
function parseMinecraftColor(color) {
|
||||
if (typeof color === 'string' && ansiMap[color] && !color.startsWith('#')) {
|
||||
|
@ -77,92 +107,168 @@ function parseMinecraftFormat(format) {
|
|||
}
|
||||
|
||||
function inject(bot) {
|
||||
|
||||
let playerchat = {};
|
||||
let systemchat = {};
|
||||
let profilelesschat = {};
|
||||
/*
|
||||
let actionbar = {};
|
||||
let bossbar = {};
|
||||
let title = {};
|
||||
*/
|
||||
let title = {
|
||||
type: NaN, // This is custom
|
||||
fadeIn: NaN,
|
||||
stay: NaN,
|
||||
fadeOut: NaN,
|
||||
jsonMsg: {
|
||||
message: undefined,
|
||||
subMessage: undefined
|
||||
},
|
||||
withColor: {
|
||||
message: undefined,
|
||||
subMessage: undefined
|
||||
},
|
||||
withoutColor: {
|
||||
message: undefined,
|
||||
subMessage: undefined
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
bot.on('end', () => {
|
||||
playerChat = {};
|
||||
systemChat = {};
|
||||
profilelessChat = {};
|
||||
/*
|
||||
actionbar = {};
|
||||
bossbar = {};
|
||||
title = {};
|
||||
*/
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
bot.on('set_title_text', (packet) => {
|
||||
title.message = parseMinecraftMessage(simplify(packet.text));
|
||||
title.noColor_message = parseMinecraftMessageNoColor(simplify(packet.text));
|
||||
|
||||
bot.emit('custom_title', title.message, title, packet);
|
||||
bot.emit('custom_allmessage', 'Title', title.message, title, packet);
|
||||
const parsedTitleText = processNBTComponent(packet.text);
|
||||
title = {
|
||||
...title,
|
||||
type: 0,
|
||||
jsonMsg: {
|
||||
message: parsedTitleText
|
||||
},
|
||||
withColor: {
|
||||
message: parseMinecraftMessage(parsedTitleText)
|
||||
},
|
||||
withoutColor: {
|
||||
message: parseMinecraftMessageNoColor(parsedTitleText)
|
||||
},
|
||||
}
|
||||
|
||||
title.message = undefined;
|
||||
title.noColor_message = undefined;
|
||||
bot.emit('custom_title', title.withColor.message, title, packet);
|
||||
bot.emit('custom_allMessage', 'title', title.message, title, packet);
|
||||
|
||||
title = {
|
||||
...title,
|
||||
type: NaN,
|
||||
jsonMsg: {
|
||||
message: undefined
|
||||
},
|
||||
withColor: {
|
||||
message: undefined
|
||||
},
|
||||
withoutColor: {
|
||||
message: undefined
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
bot.on('set_title_subtitle', (packet) => {
|
||||
title.subMessage = parseMinecraftMessage(simplify(packet.text));
|
||||
title.noColor_subMessage = parseMinecraftMessageNoColor(simplify(packet.text));
|
||||
const parsedSubTitleText = processNBTComponent(packet.text);
|
||||
title = {
|
||||
...title,
|
||||
type: 1,
|
||||
jsonMsg: {
|
||||
subMessage: parsedSubTitleText
|
||||
},
|
||||
withColor: {
|
||||
subMessage: parseMinecraftMessage(parsedSubTitleText)
|
||||
},
|
||||
withoutColor: {
|
||||
subMessage: parseMinecraftMessageNoColor(parsedSubTitleText)
|
||||
},
|
||||
}
|
||||
|
||||
bot.emit('custom_subtitle', title.subMessage, title, packet);
|
||||
bot.emit('custom_allmessage', 'subtitle', title.subMessage, title, packet);
|
||||
bot.emit('custom_title', title.withColor.subMessage, title, packet);
|
||||
bot.emit('custom_allMessage', 'title', title.withColor.subMessage, title, packet);
|
||||
|
||||
title.subMessage = undefined;
|
||||
title.noColor_subMessage = undefined;
|
||||
title = {
|
||||
...title,
|
||||
type: NaN,
|
||||
jsonMsg: {
|
||||
subMessage: undefined
|
||||
},
|
||||
withColor: {
|
||||
subMessage: undefined
|
||||
},
|
||||
withoutColor: {
|
||||
subMessage: undefined
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
bot.on('set_title_time', (packet) => {
|
||||
title.fadeIn = packet.fadeIn;
|
||||
title.stay = packet.stay;
|
||||
title.fadeOut = packet.fadeOut;
|
||||
title = {
|
||||
...title,
|
||||
type: 2,
|
||||
fadeIn: packet.fadeIn,
|
||||
stay: packet.stay,
|
||||
fadeOut: packet.fadeOut,
|
||||
}
|
||||
|
||||
bot.emit('custom_timetitle', undefined, title, packet);
|
||||
bot.emit('custom_allmessage', 'timetitle', undefined, title, packet);
|
||||
bot.emit('custom_title', undefined, title, packet);
|
||||
bot.emit('custom_allMessage', 'title', undefined, title, packet);
|
||||
});
|
||||
|
||||
bot.on('boss_bar', (packet) => {
|
||||
const bossBar = {
|
||||
uuid: packet.entityUUID,
|
||||
action: packet.action,
|
||||
health: NaN,
|
||||
color: NaN,
|
||||
dividers: NaN,
|
||||
flags: NaN,
|
||||
|
||||
bossbar.uuid = packet.entityUUID;
|
||||
bossbar.action = packet.action;
|
||||
jsonMsg: {
|
||||
message: undefined
|
||||
},
|
||||
withColor: {
|
||||
message: undefined
|
||||
},
|
||||
withoutColor: {
|
||||
message: undefined
|
||||
},
|
||||
}
|
||||
|
||||
switch (bossbar.action) {
|
||||
case 1: // bossbar remove || bossbar visible false || bossbar player !botName
|
||||
switch (bossBar.action) {
|
||||
case 0: { // bossBar visible true || bossBar player botName
|
||||
const parsedBossBarMessage = processNBTComponent(packet.title)
|
||||
bossBar.withoutColor.message = parseMinecraftMessageNoColor(parsedBossBarMessage);
|
||||
bossBar.withColor.message = parseMinecraftMessage(parsedBossBarMessage);
|
||||
bossBar.jsonMsg.message = parsedBossBarMessage;
|
||||
|
||||
bossBar.health = packet.health;
|
||||
bossBar.color = packet.color;
|
||||
bossBar.dividers = packet.dividers;
|
||||
bossBar.flags = packet.flags;
|
||||
}
|
||||
break;
|
||||
case 0: // bossbar visible true || bossbar player botName
|
||||
bossbar.message = parseMinecraftMessage(simplify(packet.title));
|
||||
bossbar.nocolor_title = parseMinecraftMessageNoColor(simplify(packet.title));
|
||||
bossbar.health = packet.health;
|
||||
bossbar.color = packet.color;
|
||||
bossbar.dividers = packet.dividers;
|
||||
bossbar.flags = packet.flags;
|
||||
|
||||
case 1: // bossBar remove || bossBar visible false || bossBar player !botName
|
||||
break;
|
||||
|
||||
case 2: // bossbar set max || bossbar set value, 1 mean full
|
||||
bossbar.health = packet.health;
|
||||
case 2: // bossBar set max || bossBar set value, 1 mean full
|
||||
bossBar.health = packet.health;
|
||||
break;
|
||||
|
||||
case 3: // bossbar set name
|
||||
bossbar.message = parseMinecraftMessage(simplify(packet.title));
|
||||
bossbar.nocolor_message = parseMinecraftMessageNoColor(simplify(packet.title));
|
||||
case 3: { // bossBar set name
|
||||
const parsedBossBarMessage = processNBTComponent(packet.title)
|
||||
bossBar.withoutColor.message = parseMinecraftMessageNoColor(parsedBossBarMessage);
|
||||
bossBar.withColor.message = parseMinecraftMessage(parsedBossBarMessage);
|
||||
bossBar.jsonMsg.message = parsedBossBarMessage;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
bossbar.color = packet.color; // bossbar set color
|
||||
bossbar.dividers = packet.dividers; // bossbar set style
|
||||
bossBar.color = packet.color; // bossBar set color
|
||||
bossBar.dividers = packet.dividers; // bossBar set style
|
||||
break;
|
||||
|
||||
case 5: // wither, ender dragon etc... , chayapak found it
|
||||
bossbar.flags = packet.flags;
|
||||
bossBar.flags = packet.flags;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -170,154 +276,211 @@ bot.on('boss_bar', (packet) => {
|
|||
break;
|
||||
}
|
||||
|
||||
bot.emit('custom_bossbar', bossbar.message, bossbar, packet);
|
||||
bot.emit('custom_allmessage', 'bossbar', bossbar.message, bossbar, packet);
|
||||
bot.emit('custom_bossBar', bossBar.withColor.message, bossBar, packet);
|
||||
bot.emit('custom_allMessage', 'bossBar', bossBar.withColor.message, bossBar, packet);
|
||||
});
|
||||
|
||||
bot.on('action_bar', (packet) => {
|
||||
actionbar = {};
|
||||
actionbar.message = parseMinecraftMessage(simplify(packet.text));
|
||||
actionbar.nocolor_message = parseMinecraftMessageNoColor(simplify(packet.text))
|
||||
bot.emit('custom_actionbar', actionbar.message, actionbar, packet);
|
||||
bot.emit('custom_allmessage', 'actionbar', actionbar.message, actionbar, packet);
|
||||
});
|
||||
*/
|
||||
|
||||
bot.on('system_chat', (packet) => { // system
|
||||
if (packet.isActionBar) return; // useless i guess
|
||||
systemchat = {};
|
||||
systemchat.jsonMsg = simplify(packet.content);
|
||||
systemchat.message = parseMinecraftMessage(simplify(packet.content));
|
||||
systemchat.nocolor_message = parseMinecraftMessageNoColor(simplify(packet.content));
|
||||
bot.emit('custom_systemchat', systemchat.message, systemchat, packet);
|
||||
bot.emit('custom_allmessage', 'systemchat', systemchat.message, systemchat, packet);
|
||||
const parsedText = processNBTComponent(packet.text);
|
||||
|
||||
const actionBar = {
|
||||
jsonMsg: {
|
||||
message: parsedText
|
||||
},
|
||||
withColor: {
|
||||
message: parseMinecraftMessage(parsedText)
|
||||
},
|
||||
withoutColor: {
|
||||
message: parseMinecraftMessageNoColor(parsedText)
|
||||
},
|
||||
};
|
||||
|
||||
bot.emit('custom_actionBar', actionBar.withColor.message, actionBar, packet);
|
||||
bot.emit('custom_allMessage', 'actionBar', actionBar.message, actionBar, packet);
|
||||
});
|
||||
|
||||
|
||||
bot.on('system_chat', (packet) => {
|
||||
if (packet.isActionBar) return;
|
||||
const parsedContent = processNBTComponent(packet.content);
|
||||
|
||||
const systemChat = {
|
||||
jsonMsg: {
|
||||
message: parsedContent
|
||||
},
|
||||
withColor: {
|
||||
message: parseMinecraftMessage(parsedContent)
|
||||
},
|
||||
withoutColor: {
|
||||
message: parseMinecraftMessageNoColor(parsedContent)
|
||||
},
|
||||
};
|
||||
|
||||
bot.emit('custom_systemChat', systemChat.withColor.message, systemChat, packet);
|
||||
bot.emit('custom_allMessage', 'systemChat', systemChat.withColor.message, systemChat, packet);
|
||||
});
|
||||
|
||||
bot.on('profileless_chat', (packet) => { // kinda player_chat
|
||||
const parsedMessage = processNBTComponent(packet.message);
|
||||
const parsedName = processNBTComponent(packet.name);
|
||||
const parsedTarget = processNBTComponent(packet.target);
|
||||
|
||||
profilelesschat = {};
|
||||
|
||||
profilelesschat.type = packet.type;
|
||||
|
||||
profilelesschat.formattedMessage = simplify(packet.message);
|
||||
profilelesschat.senderName = simplify(packet.name);
|
||||
profilelesschat.targetName = simplify(packet.target);
|
||||
const profilelessChat = {
|
||||
type: packet.type,
|
||||
|
||||
profilelesschat.nocolor_formattedMessage = parseMinecraftMessageNoColor(simplify(packet.message));
|
||||
profilelesschat.nocolor_senderName = parseMinecraftMessageNoColor(simplify(packet.name));
|
||||
profilelesschat.nocolor_targetName = parseMinecraftMessageNoColor(simplify(packet.target));
|
||||
jsonMsg: {
|
||||
message: undefined,
|
||||
formattedMessage: parsedMessage,
|
||||
senderName: parsedName,
|
||||
targetName: parsedTarget
|
||||
},
|
||||
withColor: {
|
||||
message: undefined,
|
||||
formattedMessage: parseMinecraftMessage(parsedMessage),
|
||||
senderName: parseMinecraftMessage(parsedName),
|
||||
targetName: parseMinecraftMessage(parsedTarget)
|
||||
},
|
||||
withoutColor: {
|
||||
message: undefined,
|
||||
formattedMessage: parseMinecraftMessageNoColor(parsedMessage),
|
||||
senderName: parseMinecraftMessageNoColor(parsedName),
|
||||
targetName: parseMinecraftMessageNoColor(parsedTarget)
|
||||
},
|
||||
};
|
||||
|
||||
switch (profilelesschat.type) {
|
||||
switch (profilelessChat.type) {
|
||||
case 0: // normal profileless chat message
|
||||
profilelesschat.message = parseMinecraftMessage({ "translate": "chat.type.text", "with": [ profilelesschat.senderName, playerchat.formattedMessage ]});
|
||||
profilelesschat.nocolor_message = parseMinecraftMessageNoColor({ "translate": "chat.type.text", "with": [ profilelesschat.senderName, profilelesschat.plainMessage ]});
|
||||
profilelessChat.withColor.message = parseMinecraftMessage({ "translate": "chat.type.text", "with": [ parsedName, parsedMessage ]});
|
||||
profilelessChat.withoutColor.message = parseMinecraftMessageNoColor({ "translate": "chat.type.text", "with": [ parsedName, parsedMessage ]});
|
||||
profilelessChat.jsonMsg.message = { "translate": "chat.type.text", "with": [ parsedName, parsedMessage ]};
|
||||
break;
|
||||
case 1: // /me
|
||||
profilelesschat.message = parseMinecraftMessage({ "translate": "chat.type.emote", "with": [ profilelesschat.senderName, profilelesschat.formattedMessage ]});
|
||||
profilelesschat.nocolor_message = parseMinecraftMessageNoColor({ "translate": "chat.type.emote", "with": [ profilelesschat.senderName, profilelesschat.formattedMessage ]});
|
||||
profilelessChat.withColor.message = parseMinecraftMessage({ "translate": "chat.type.emote", "with": [ parsedName, parsedMessage ]});
|
||||
profilelessChat.withoutColor.message = parseMinecraftMessageNoColor({ "translate": "chat.type.emote", "with": [ parsedName, parsedMessage ]});
|
||||
profilelessChat.jsonMsg.message = { "translate": "chat.type.emote", "with": [ parsedName, parsedMessage ]}
|
||||
break;
|
||||
case 2: // player /tell
|
||||
profilelesschat.message = parseMinecraftMessage({ translate: "commands.message.display.incoming", with: [ profilelesschat.senderName, profilelesschat.formattedMessage ], color: "gray", italic: true });
|
||||
profilelesschat.nocolor_message = parseMinecraftMessageNoColor({ translate: "commands.message.display.incoming", with: [ profilelesschat.senderName, profilelesschat.formattedMessage ], color: "gray", italic: true });
|
||||
profilelessChat.withColor.message = parseMinecraftMessage({ translate: "commands.message.display.incoming", with: [ parsedName, parsedMessage ], color: "gray", italic: true });
|
||||
profilelessChat.withoutColor.message = parseMinecraftMessageNoColor({ translate: "commands.message.display.incoming", with: [ parsedName, parsedMessage ], color: "gray", italic: true });
|
||||
profilelessChat.jsonMsg.message = { translate: "commands.message.display.incoming", with: [ parsedName, parsedMessage ], color: "gray", italic: true }
|
||||
break;
|
||||
case 3: // you /tell
|
||||
profilelesschat.message = parseMinecraftMessage({ translate: "commands.message.display.outgoing", with: [ profilelesschat.targetName, profilelesschat.formattedMessage ], color: "gray", italic: true });
|
||||
profilelesschat.nocolor_message = parseMinecraftMessageNoColor({ translate: "commands.message.display.outgoing", with: [ profilelesschat.targetName, profilelesschat.formattedMessage ], color: "gray", italic: true });
|
||||
profilelessChat.withColor.message = parseMinecraftMessage({ translate: "commands.message.display.outgoing", with: [ parsedTarget, parsedMessage ], color: "gray", italic: true });
|
||||
profilelessChat.withoutColor.message = parseMinecraftMessageNoColor({ translate: "commands.message.display.outgoing", with: [ parsedTarget, parsedMessage ], color: "gray", italic: true });
|
||||
profilelessChat.jsonMsg.message = { translate: "commands.message.display.outgoing", with: [ parsedTarget, parsedMessage ], color: "gray", italic: true }
|
||||
break;
|
||||
case 4: // player chat
|
||||
profilelesschat.message = parseMinecraftMessage(profilelesschat.formattedMessage);
|
||||
profilelesschat.nocolor_message = parseMinecraftMessageNoColor(profilelesschat.formattedMessage);
|
||||
profilelessChat.withColor.message = parseMinecraftMessage(parsedMessage);
|
||||
profilelessChat.withoutColor.message = parseMinecraftMessageNoColor(parsedMessage);
|
||||
profilelessChat.jsonMsg.message = parsedMessage
|
||||
break;
|
||||
case 5: // /say
|
||||
profilelesschat.message = parseMinecraftMessage({ translate: 'chat.type.announcement', with: [ profilelesschat.senderName, profilelesschat.formattedMessage ]});
|
||||
profilelesschat.nocolor_message = parseMinecraftMessageNoColor({ translate: 'chat.type.announcement', with: [ profilelesschat.senderName, profilelesschat.formattedMessage ]});
|
||||
profilelessChat.withColor.message = parseMinecraftMessage({ translate: 'chat.type.announcement', with: [ parsedName, parsedMessage ]});
|
||||
profilelessChat.withoutColor.message = parseMinecraftMessageNoColor({ translate: 'chat.type.announcement', with: [ parsedName, parsedMessage ]});
|
||||
profilelessChat.jsonMsg.message = { translate: 'chat.type.announcement', with: [ parsedName, parsedMessage ]}
|
||||
break;
|
||||
case 6: // player /teammsg
|
||||
profilelesschat.message = parseMinecraftMessage({ translate: 'chat.type.team.text', with: [ profilelesschat.targetName, profilelesschat.senderName, profilelesschat.formattedMessage ]});
|
||||
profilelesschat.nocolor_message = parseMinecraftMessageNoColor({ translate: 'chat.type.team.text', with: [ profilelesschat.targetName, profilelesschat.senderName, profilelesschat.formattedMessage ]});
|
||||
profilelessChat.withColor.message = parseMinecraftMessage({ translate: 'chat.type.team.text', with: [ parsedTarget, parsedName, parsedMessage ]});
|
||||
profilelessChat.withoutColor.message = parseMinecraftMessageNoColor({ translate: 'chat.type.team.text', with: [ parsedTarget, parsedName, parsedMessage ]});
|
||||
profilelessChat.jsonMsg.message = { translate: 'chat.type.team.text', with: [ parsedTarget, parsedName, parsedMessage ]}
|
||||
break;
|
||||
case 7: // you /teammsg
|
||||
profilelesschat.message = parseMinecraftMessage({ translate: 'chat.type.team.sent', with: [ profilelesschat.targetName, profilelesschat.senderName, profilelesschat.formattedMessage ]});
|
||||
profilelesschat.nocolor_message = parseMinecraftMessageNoColor({ translate: 'chat.type.team.sent', with: [ profilelesschat.targetName, profilelesschat.senderName, profilelesschat.formattedMessage ]});
|
||||
profilelessChat.withColor.message = parseMinecraftMessage({ translate: 'chat.type.team.sent', with: [ parsedTarget, parsedName, parsedMessage ]});
|
||||
profilelessChat.withoutColor.message = parseMinecraftMessageNoColor({ translate: 'chat.type.team.sent', with: [ parsedTarget, parsedName, parsedMessage ]});
|
||||
profilelessChat.jsonMsg.message = { translate: 'chat.type.team.sent', with: [ parsedTarget, parsedName, parsedMessage ]}
|
||||
break;
|
||||
default:
|
||||
console.log(`Unknown profilelesschat packet. Type: ${profilelesschat.type}`);
|
||||
console.log(`Unknown profilelessChat packet. Type: ${profilelessChat.type}`);
|
||||
console.log(packet);
|
||||
break;
|
||||
}
|
||||
|
||||
bot.emit('custom_profilelesschat', profilelesschat.message, profilelesschat, packet)
|
||||
bot.emit('custom_allmessage', 'profilelesschat', profilelesschat.message, profilelesschat, packet)
|
||||
bot.emit('custom_profilelessChat', profilelessChat.withColor.message, profilelessChat, packet);
|
||||
bot.emit('custom_allMessage', 'profilelessChat', profilelessChat.withColor.message, profilelessChat, packet);
|
||||
})
|
||||
|
||||
|
||||
bot.on('player_chat', (packet) => { // player
|
||||
playerchat = {};
|
||||
bot.on('player_chat', (packet) => { // player chat
|
||||
const parsedMessage = processNBTComponent(packet.unsignedChatContent);
|
||||
const parsedName = processNBTComponent(packet.networkName);
|
||||
const parsedTarget = processNBTComponent(packet.networkTargetName);
|
||||
|
||||
playerchat.plainMessage = packet.plainMessage;
|
||||
playerchat.type = packet.type;
|
||||
playerchat.sender = packet.senderUuid;
|
||||
|
||||
playerchat.unsignedContent = simplify(packet.unsignedChatContent);
|
||||
playerchat.senderName = simplify(packet.networkName);
|
||||
playerchat.targetName = simplify(packet.networkTargetName);
|
||||
const playerChat = {
|
||||
type: packet.type,
|
||||
plainMessage: packet.plainMessage,
|
||||
senderUuid: packet.senderUuid,
|
||||
|
||||
jsonMsg: {
|
||||
message: undefined,
|
||||
unsignedChatContent: parsedMessage,
|
||||
senderName: parsedName,
|
||||
targetName: parsedTarget
|
||||
},
|
||||
withColor: {
|
||||
message: undefined,
|
||||
unsignedChatContent: parseMinecraftMessage(parsedMessage),
|
||||
senderName: parseMinecraftMessage(parsedName),
|
||||
targetName: parseMinecraftMessage(parsedTarget)
|
||||
},
|
||||
withoutColor: {
|
||||
message: undefined,
|
||||
unsignedChatContent: parseMinecraftMessageNoColor(parsedMessage),
|
||||
senderName: parseMinecraftMessageNoColor(parsedName),
|
||||
targetName: parseMinecraftMessageNoColor(parsedTarget)
|
||||
},
|
||||
};
|
||||
|
||||
playerchat.nocolor_unsignedContent = parseMinecraftMessageNoColor(simplify(packet.unsignedChatContent));
|
||||
playerchat.nocolor_senderName = parseMinecraftMessageNoColor(simplify(packet.networkName));
|
||||
playerchat.nocolor_targetName = parseMinecraftMessageNoColor(simplify(packet.networkTargetName));
|
||||
|
||||
switch (playerchat.type) { // vanish off
|
||||
switch (playerChat.type) { // vanish off
|
||||
case 0: // normal vanilla chat message
|
||||
playerchat.message = parseMinecraftMessage({ "translate": "chat.type.text", "with": [ playerchat.senderName, playerchat.plainMessage ]});
|
||||
playerchat.nocolor_message = parseMinecraftMessageNoColor({ "translate": "chat.type.text", "with": [ playerchat.senderName, playerchat.plainMessage ]});
|
||||
playerchat.jsonMsg = { "translate": "chat.type.text", "with": [ playerchat.senderName, playerchat.plainMessage ]};
|
||||
playerChat.withColor.message = parseMinecraftMessage({ "translate": "chat.type.text", "with": [ parsedName, playerChat.plainMessage ]});
|
||||
playerChat.withoutColor.message = parseMinecraftMessageNoColor({ "translate": "chat.type.text", "with": [ parsedName, playerChat.plainMessage ]});
|
||||
playerChat.jsonMsg.message = { "translate": "chat.type.text", "with": [ parsedName, playerChat.plainMessage ]};
|
||||
break;
|
||||
case 1: // /minecraft:me
|
||||
playerchat.message = parseMinecraftMessage({ "translate": "chat.type.emote", "with": [ playerchat.senderName, playerchat.plainMessage ]});
|
||||
playerchat.nocolor_message = parseMinecraftMessageNoColor({ "translate": "chat.type.emote", "with": [ playerchat.senderName, playerchat.plainMessage ]});
|
||||
playerchat.jsonMsg = { "translate": "chat.type.emote", "with": [ playerchat.senderName, playerchat.plainMessage ]}
|
||||
playerChat.withColor.message = parseMinecraftMessage({ "translate": "chat.type.emote", "with": [ parsedName, playerChat.plainMessage ]});
|
||||
playerChat.withoutColor.message = parseMinecraftMessageNoColor({ "translate": "chat.type.emote", "with": [ parsedName, playerChat.plainMessage ]});
|
||||
playerChat.jsonMsg.message = { "translate": "chat.type.emote", "with": [ parsedName, playerChat.plainMessage ]}
|
||||
break;
|
||||
case 2: // player /minecraft:tell
|
||||
playerchat.message = parseMinecraftMessage({ translate: "commands.message.display.incoming", with: [ playerchat.senderName, playerchat.plainMessage ], color: "gray", italic: true });
|
||||
playerchat.nocolor_message = parseMinecraftMessageNoColor({ translate: "commands.message.display.incoming", with: [ playerchat.senderName, playerchat.plainMessage ], color: "gray", italic: true });
|
||||
playerchat.jsonMsg = { translate: "commands.message.display.incoming", with: [ playerchat.senderName, playerchat.plainMessage ], color: "gray", italic: true }
|
||||
playerChat.withColor.message = parseMinecraftMessage({ translate: "commands.message.display.incoming", with: [ parsedName, playerChat.plainMessage ], color: "gray", italic: true });
|
||||
playerChat.withoutColor.message = parseMinecraftMessageNoColor({ translate: "commands.message.display.incoming", with: [ parsedName, playerChat.plainMessage ], color: "gray", italic: true });
|
||||
playerChat.jsonMsg.message = { translate: "commands.message.display.incoming", with: [ parsedName, playerChat.plainMessage ], color: "gray", italic: true }
|
||||
break;
|
||||
case 3: // you /minecraft:tell
|
||||
playerchat.message = parseMinecraftMessage({ translate: "commands.message.display.outgoing", with: [ playerchat.targetName, playerchat.plainMessage ], color: "gray", italic: true });
|
||||
playerchat.nocolor_message = parseMinecraftMessageNoColor({ translate: "commands.message.display.outgoing", with: [ playerchat.targetName, playerchat.plainMessage ], color: "gray", italic: true });
|
||||
playerchat.jsonMsg = { translate: "commands.message.display.outgoing", with: [ playerchat.targetName, playerchat.plainMessage ], color: "gray", italic: true }
|
||||
playerChat.withColor.message = parseMinecraftMessage({ translate: "commands.message.display.outgoing", with: [ parsedTarget, playerChat.plainMessage ], color: "gray", italic: true });
|
||||
playerChat.withoutColor.message = parseMinecraftMessageNoColor({ translate: "commands.message.display.outgoing", with: [ parsedTarget, playerChat.plainMessage ], color: "gray", italic: true });
|
||||
playerChat.jsonMsg.message = { translate: "commands.message.display.outgoing", with: [ parsedTarget, playerChat.plainMessage ], color: "gray", italic: true }
|
||||
break;
|
||||
case 4: // player chat
|
||||
playerchat.message = parseMinecraftMessage(playerchat.unsignedContent);
|
||||
playerchat.nocolor_message = parseMinecraftMessageNoColor(playerchat.unsignedContent);
|
||||
playerchat.jsonMsg = playerchat.unsignedContent
|
||||
playerChat.withColor.message = parseMinecraftMessage(parsedMessage);
|
||||
playerChat.withoutColor.message = parseMinecraftMessageNoColor(parsedMessage);
|
||||
playerChat.jsonMsg.message = parsedMessage
|
||||
break;
|
||||
case 5: // /say
|
||||
playerchat.message = parseMinecraftMessage({ translate: 'chat.type.announcement', with: [ playerchat.senderName, playerchat.plainMessage ]});
|
||||
playerchat.nocolor_message = parseMinecraftMessageNoColor({ translate: 'chat.type.announcement', with: [ playerchat.senderName, playerchat.plainMessage ]});
|
||||
playerchat.jsonMsg = { translate: 'chat.type.announcement', with: [ playerchat.senderName, playerchat.plainMessage ]}
|
||||
playerChat.withColor.message = parseMinecraftMessage({ translate: 'chat.type.announcement', with: [ parsedName, playerChat.plainMessage ]});
|
||||
playerChat.withoutColor.message = parseMinecraftMessageNoColor({ translate: 'chat.type.announcement', with: [ parsedName, playerChat.plainMessage ]});
|
||||
playerChat.jsonMsg.message = { translate: 'chat.type.announcement', with: [ parsedName, playerChat.plainMessage ]}
|
||||
break;
|
||||
case 6: // player /minecraft:teammsg || /teammsg
|
||||
playerchat.message = parseMinecraftMessage({ translate: 'chat.type.team.text', with: [ playerchat.targetName, playerchat.senderName, playerchat.plainMessage ]});
|
||||
playerchat.nocolor_message = parseMinecraftMessageNoColor({ translate: 'chat.type.team.text', with: [ playerchat.targetName, playerchat.senderName, playerchat.plainMessage ]});
|
||||
playerchat.jsonMsg = { translate: 'chat.type.team.text', with: [ playerchat.targetName, playerchat.senderName, playerchat.plainMessage ]}
|
||||
playerChat.withColor.message = parseMinecraftMessage({ translate: 'chat.type.team.text', with: [ parsedTarget, parsedName, playerChat.plainMessage ]});
|
||||
playerChat.withoutColor.message = parseMinecraftMessageNoColor({ translate: 'chat.type.team.text', with: [ parsedTarget, parsedName, playerChat.plainMessage ]});
|
||||
playerChat.jsonMsg.message = { translate: 'chat.type.team.text', with: [ parsedTarget, parsedName, playerChat.plainMessage ]}
|
||||
break;
|
||||
case 7: // you /minecraft:teammsg || /teammsg
|
||||
playerchat.message = parseMinecraftMessage({ translate: 'chat.type.team.sent', with: [ playerchat.targetName, playerchat.senderName, playerchat.plainMessage ]});
|
||||
playerchat.nocolor_message = parseMinecraftMessageNoColor({ translate: 'chat.type.team.sent', with: [ playerchat.targetName, playerchat.senderName, playerchat.plainMessage ]});
|
||||
playerchat.jsonMsg = { translate: 'chat.type.team.sent', with: [ playerchat.targetName, playerchat.senderName, playerchat.plainMessage ]}
|
||||
playerChat.withColor.message = parseMinecraftMessage({ translate: 'chat.type.team.sent', with: [ parsedTarget, parsedName, playerChat.plainMessage ]});
|
||||
playerChat.withoutColor.message = parseMinecraftMessageNoColor({ translate: 'chat.type.team.sent', with: [ parsedTarget, parsedName, playerChat.plainMessage ]});
|
||||
playerChat.jsonMsg.message = { translate: 'chat.type.team.sent', with: [ parsedTarget, parsedName, playerChat.plainMessage ]}
|
||||
break;
|
||||
default:
|
||||
console.log(`Unknown player_chat packet. Type: ${playerchat.type}`);
|
||||
console.log(`Unknown player_chat packet. Type: ${playerChat.type}`);
|
||||
console.log(packet);
|
||||
break;
|
||||
}
|
||||
bot.emit('custom_playerchat', playerchat.message, playerchat, packet);
|
||||
bot.emit('custom_allmessage', 'playerchat', playerchat.message, playerchat, packet)
|
||||
|
||||
bot.emit('custom_playerChat', playerChat.withColor.message, playerChat, packet);
|
||||
bot.emit('custom_allMessage', 'playerChat', playerChat.withColor.message, playerChat, packet)
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const ansiMap = {
|
||||
'§0': '\x1B[30m',
|
||||
|
@ -368,7 +531,7 @@ const ansiMap = {
|
|||
};
|
||||
|
||||
function parseMinecraftMessage(component) {
|
||||
if (component === undefined || component === null) return '\x1B[91m*** Component is undefined or missing ***\x1B[0m';
|
||||
if (component === undefined || component === null) return undefined;
|
||||
if (typeof component !== "object") return component;
|
||||
function extractText(comp, prevColor = { color: '', have: false }, prevFormat = { format: '', have: false }) {
|
||||
let text = '';
|
||||
|
@ -377,19 +540,16 @@ function parseMinecraftMessage(component) {
|
|||
let NowColor = parseMinecraftColor(comp?.color);
|
||||
let NowFormat = parseMinecraftFormat(comp);
|
||||
|
||||
if ((comp || comp !== "") && (comp.text || comp.text !== "") && (comp[""] || comp[""] !== "") && (comp.keybind || comp.keybind !== "") && (comp.translate || comp.translate !== "")) {
|
||||
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;
|
||||
shouldReset = true;
|
||||
};
|
||||
text += NowFormat.have ? NowFormat.format : prevFormat.format;
|
||||
}
|
||||
shouldReset = true;
|
||||
}
|
||||
|
||||
|
||||
if (typeof comp.text === 'string' || typeof comp.text === 'number') {
|
||||
text += comp.text;
|
||||
}
|
||||
if (typeof comp[""] === 'string' || typeof comp[""] === 'number') {
|
||||
text += comp[""];
|
||||
}
|
||||
if (typeof comp === 'string' || typeof comp === 'number') {
|
||||
text += comp;
|
||||
|
@ -406,7 +566,7 @@ function parseMinecraftMessage(component) {
|
|||
if (comp.fallback && !lang[comp.translate]) fallbackMsg = true;
|
||||
|
||||
if (comp.with && !fallbackMsg) {
|
||||
const withArgs = comp.with.map(arg => extractText(arg, NowColor.have ? NowColor : prevColor, NowFormat.have ? NowFormat : prevFormat));
|
||||
const withArgs = comp.with.map(arg => extractText(arg, NowColor.have ? NowColor : prevColor, NowFormat.have ? NowFormat : prevFormat) + `${VaildText(comp) ? NowFormat.have ? NowFormat.format : "" : ""}${VaildText(comp) ? NowColor.have ? NowColor.color : "" : ""}`);
|
||||
let usedReplacements = 0;
|
||||
translateString = translateString.replace(/thing__placeholder__/g, 'default_thing__placeholder__');
|
||||
|
||||
|
@ -461,26 +621,21 @@ function parseMinecraftMessage(component) {
|
|||
if (comp.extra) {
|
||||
if (!Array.isArray(comp.extra)) comp.extra = [comp.extra]
|
||||
comp.extra.forEach(subComp => {
|
||||
text += extractText(subComp, NowColor.have ? NowColor : prevColor, NowFormat.have ? NowFormat : prevFormat);
|
||||
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']
|
||||
} else {
|
||||
text += prevColor.color || ansiMap['white'];
|
||||
text += prevFormat.format || '';
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
return extractText(component);
|
||||
// return extractText(component) + ansiMap['reset']; ye if you need
|
||||
}
|
||||
|
||||
function parseMinecraftMessageNoColor(component) {
|
||||
if (component === undefined || component === null) return '*** Component is undefined or missing ***';
|
||||
if (component === undefined || component === null) return undefined;
|
||||
if (typeof component !== "object") return component;
|
||||
|
||||
function extractText(comp) {
|
||||
|
@ -488,9 +643,6 @@ function parseMinecraftMessageNoColor(component) {
|
|||
|
||||
if (typeof comp.text === 'string' || typeof comp.text === 'number') {
|
||||
text += comp.text;
|
||||
}
|
||||
if (typeof comp[""] === 'string' || typeof comp[""] === 'number') {
|
||||
text += comp[""];
|
||||
}
|
||||
if (typeof comp === 'string' || typeof comp === 'number') {
|
||||
return comp;
|
||||
|
@ -574,7 +726,7 @@ function parseMinecraftMessageNoColor(component) {
|
|||
}
|
||||
|
||||
function cboutput(component) {
|
||||
if (component === undefined || component === null) return '\x1B[91m*** Component is undefined or missing ***\x1B[0m';
|
||||
if (component === undefined || component === null) return undefined;
|
||||
if (typeof component !== "object") return component;
|
||||
|
||||
function extractText(comp, prevColor = { color: '', have: false }, prevFormat = { format: '', have: false }) {
|
||||
|
@ -620,7 +772,7 @@ function cboutput(component) {
|
|||
}
|
||||
|
||||
function cboutputNoColor(component) {
|
||||
if (component === undefined || component === null) return '*** Component is undefined or missing ***';
|
||||
if (component === undefined || component === null) return undefined;
|
||||
if (typeof component !== "object") return component;
|
||||
|
||||
function extractText(comp) {
|
||||
|
@ -645,4 +797,4 @@ function cboutputNoColor(component) {
|
|||
return extractText(component);
|
||||
}
|
||||
|
||||
module.exports = { inject, parseMinecraftMessage, parseMinecraftMessageNoColor, cboutput, simplify };
|
||||
module.exports = { inject, parseMinecraftMessage, parseMinecraftMessageNoColor, cboutput, simplify, FixEmptyKeys, processNBTComponent, ansiMap };
|
156
main/main.js
156
main/main.js
|
@ -1,101 +1,165 @@
|
|||
/**
|
||||
* Minecraft Version:
|
||||
* - 1.20.4
|
||||
* - 1.20.5
|
||||
* - 1.20.6
|
||||
* Minecraft Version: *Info in chat parser*
|
||||
*
|
||||
* ChatParser Version:
|
||||
* - 1.44
|
||||
* ChatParser Version: 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.
|
||||
*
|
||||
* Example:
|
||||
* Old: playerChat.message
|
||||
* New: playerChat.withColor.message
|
||||
*
|
||||
* In version 1.47 and newer, playerChat.message no longer exists.
|
||||
*
|
||||
* TODO: i guess:
|
||||
* - Kick parser
|
||||
* - Reconnect?
|
||||
* - Should i make lightweight version of 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: 'chipmunk.land', // Chipmunk
|
||||
// host: '168.100.225.224', // Neko
|
||||
host: 'chayapak.chipmunk.land',
|
||||
port: 25565,
|
||||
username: 'catparser', // cat
|
||||
version: "1.20.4", // Not support 1.21
|
||||
version: "1.20.4", // 1.20.5, 1.20.6, Not support 1.21 or higher
|
||||
});
|
||||
|
||||
ChatParse.inject(bot); // load catparser function
|
||||
|
||||
bot.on('custom_playerchat', (message, playerchat, packet) => {
|
||||
bot.on('error', (e) => {
|
||||
if (bot !== undefined) bot.end(e.message);
|
||||
});
|
||||
|
||||
bot.on('end', (reason) => {
|
||||
console.log(`Bot disconnect: ${reason}`);
|
||||
return;
|
||||
});
|
||||
|
||||
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_profilelessChat', (message, profilelessChat, packet) => {
|
||||
console.log(`[ProfilelessChat] ${message}`);
|
||||
});
|
||||
|
||||
bot.on('custom_systemchat', (message, systemchat, packet) => {
|
||||
bot.on('custom_systemChat', (message, systemChat, packet) => {
|
||||
console.log(`[SystemChat] ${message}`);
|
||||
});
|
||||
|
||||
/*
|
||||
// Kick message and disconnect message
|
||||
bot.on('kick_disconnect', (kick) => {
|
||||
console.log(ChatParse.parseMinecraftMessage(kicked.reason));
|
||||
})
|
||||
bot.on('disconnect', (kick) => {
|
||||
console.log(ChatParse.parseMinecraftMessage(kicked.reason));
|
||||
})
|
||||
|
||||
/*
|
||||
bot.on('custom_actionbar', (message, actionbar, packet) => {
|
||||
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;
|
||||
/*
|
||||
bot.on('custom_bossBar', (message, bossBar, packet) => {
|
||||
switch (bossBar.action) {
|
||||
case 0:
|
||||
console.log(`[BossBar Added] ${bossbar.message}\n${bossbar.health}\n${bossbar.color}\n${bossbar.dividers}\n${bossbar.flags}`);
|
||||
console.log(`[BossBar Added] Name: ${bossBar.withColor.message}\nHealth: ${bossBar.health}\nColor: ${bossBar.color}\nDividers: ${bossBar.dividers}\nFlags: ${bossBar.flags}`);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
console.log(`[BossBar Removed] ${bossBar.uuid}`);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
console.log(`[BossBar Health] ${bossbar.health}`)
|
||||
console.log(`[BossBar Health] ${bossBar.health}`)
|
||||
break;
|
||||
|
||||
case 3:
|
||||
console.log(`[BossBar Message] ${bossbar.message}`)
|
||||
// console.log(`[BossBar NoColor Message] ${bossbar.nocolor_message}`)
|
||||
console.log(`[BossBar Message] ${bossBar.withColor.message}`)
|
||||
break;
|
||||
|
||||
case 4:
|
||||
console.log(`[BossBar Color] ${bossbar.color}`)
|
||||
console.log(`[BossBar Style] ${bossbar.dividers}`)
|
||||
console.log(`[BossBar Color] ${bossBar.color}`)
|
||||
console.log(`[BossBar Style] ${bossBar.dividers}`)
|
||||
break;
|
||||
|
||||
case 5:
|
||||
console.log(`[BossBar Flags] ${bossbar.flags}`)
|
||||
console.log(`[BossBar Flags] ${bossBar.flags}`)
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
bot.on('custom_title', (message, title, packet) => {
|
||||
console.log(`[Title] ${message}`)
|
||||
switch (title.type) {
|
||||
case 0:
|
||||
console.log(`[Title] ${message}`)
|
||||
break;
|
||||
case 1:
|
||||
console.log(`[SubTitle] ${message}`)
|
||||
break;
|
||||
case 2:
|
||||
console.log(`[TitleSettings] fadeIn: ${title.fadeIn}\nstay: ${title.stay}\nfadeOut: ${title.fadeOut}`);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
bot.on('custom_subtitle', (message, title, packet) => {
|
||||
console.log(`[SubTitle] ${message}`)
|
||||
});
|
||||
bot.on('custom_allMessage', (chatType, message, messagePacket, packet) => {
|
||||
switch (chatType) {
|
||||
case "playerChat":
|
||||
case "profilelessChat":
|
||||
case "actionBar":
|
||||
console.log(`[${chatType}] ${message}`)
|
||||
break;
|
||||
case "systemChat":
|
||||
if (messagePacket.jsonMsg?.message?.translate === "advMode.setCommand.success" || messagePacket.jsonMsg?.message?.translate === "multiplayer.message_not_delivered") return; // Command set: %s OR Can't deliver chat message, check server logs: %s
|
||||
console.log(`[${chatType}] ${message}`)
|
||||
break;
|
||||
case "bossBar": {
|
||||
switch (messagePacket.action) {
|
||||
case 0:
|
||||
console.log(`[BossBar Added] Name: ${messagePacket.withColor.message}\nHealth: ${messagePacket.health}\nColor: ${messagePacket.color}\nDividers: ${messagePacket.dividers}\nFlags: ${messagePacket.flags}`);
|
||||
break;
|
||||
|
||||
bot.on('custom_timetitle', (_, title, packet) => {
|
||||
console.log(`[TitleTimes] fadeIn: ${title.fadeIn}\nstay: ${title.stay}\nfadeOut: ${title.fadeOut}`);
|
||||
});
|
||||
case 1:
|
||||
console.log(`[BossBar Removed] ${messagePacket.uuid}`);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
console.log(`[BossBar Health] ${messagePacket.health}`)
|
||||
break;
|
||||
|
||||
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}`)
|
||||
case 3:
|
||||
console.log(`[BossBar Message] ${messagePacket.withColor.message}`)
|
||||
break;
|
||||
|
||||
case 4:
|
||||
console.log(`[BossBar Color] ${messagePacket.color}\n[messagePacket Style] ${messagePacket.dividers}`)
|
||||
break;
|
||||
case 5:
|
||||
console.log(`[BossBar Flags] ${messagePacket.flags}`)
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "title": {
|
||||
switch (messagePacket.type) {
|
||||
case 0:
|
||||
console.log(`[Title] ${message}`)
|
||||
break;
|
||||
case 1:
|
||||
console.log(`[SubTitle] ${message}`)
|
||||
break;
|
||||
case 2:
|
||||
console.log(`[TitleSettings] fadeIn: ${messagePacket.fadeIn}\nstay: ${messagePacket.stay}\nfadeOut: ${messagePacket.fadeOut}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
})
|
||||
|
||||
*/
|
||||
|
||||
bot.on('error', (err) => {
|
||||
console.error(err);
|
||||
});
|
||||
*/
|
Loading…
Reference in a new issue