more overhauls

This commit is contained in:
Parker2991
2025-08-14 10:13:54 -05:00
parent 28be25d2e6
commit dc08bcad37
39 changed files with 924 additions and 491 deletions
+2
View File
@@ -25,6 +25,7 @@ class Bot {
client.on("login", (data) => {
bot.uuid = client.uuid;
bot.username = client.username;
bot.loggedIn = true;
});
client.on("disconnect", (data) => {
@@ -43,6 +44,7 @@ class Bot {
client.on("end", (reason) => {
bot.emit("end", reason);
bot.loggedIn = false;
disconnectCount++;
});
+27
View File
@@ -0,0 +1,27 @@
function chipmunkmod (message, data, context, bot) {
try {
if (message === null || typeof message !== 'object') return
if (message.with?.length < 3 || (message.translate !== '[%s] %s › %s' && message.translate !== '%s %s › %s')) return
const senderComponent = message.with[1]
const contents = message.with[2]
let sender
const hoverEvent = senderComponent.hoverEvent
if (hoverEvent?.action === 'show_entity') {
const id = hoverEvent.contents.id
sender = data.players.find(player => player.uuid === id)
} else {
const stringUsername = data.getMessageAsPrismarine(senderComponent).toString() // TypeError: data.getMessageAsPrismarine is not a function
sender = data.players.find(player => player.profile.name === stringUsername)
}
if (!sender) return null;
return { sender, contents, type: 'minecraft:chat', chatType: ["system"], senderComponent }
} catch(e) {
console.error(e)
}
}
module.exports = chipmunkmod
+2 -10
View File
@@ -10,17 +10,9 @@ function parseMessage(messageobj, data) {
const playerWithoutPrefix = /^(\S*?) » (.*?)$/;
if (playerWithPrefix.test(message)) {
match = message.match(playerWithPrefix);
// console.log(match[2])
// console.log(data.players.find(player => player.profile.name.toString().replaceAll('§','') === match[2]))
// console.log(data.players)
// console.log(match[0])
// console.log(match[2])
// console.log(data.players.find(player => player.profile.name === match[2]))
sender = data.players.find((player) => player.profile.name === match[2]);
// sender = data.players.find(player => util.isDeepStrictEqual(player.displayName, playerListDisplayName))
// if (!sender) return;
// console.log(sender)
return { sender, contents: match[3], type: "minecraft:chat" };
return { sender, contents: match[3], chatType: "player", type: "minecraft:chat" };
}
} catch (e) {
console.log(e.stack);
+6 -4
View File
@@ -4,7 +4,7 @@ function kaboom (message, data) {
if (message === null || typeof message !== 'object') return
if (message.text !== '' || !Array.isArray(message.extra) || message.extra.length < 3) return
const children = message.extra
const prefix = children[0]
@@ -22,16 +22,18 @@ function kaboom (message, data) {
const playerListDisplayName = { extra: [prefix, displayName], text: '' }
let sender
if (data.uuid) {
sender = data.players.find(player => player.uuid === data.senderUuid)
} else {
const playerListDisplayName = { extra: [prefix, displayName], text: '' }
sender = data.players.find(player => util.isDeepStrictEqual(player.displayName, playerListDisplayName))
}
if (!sender) return undefined
return { sender, contents, type: 'minecraft:chat', displayName }
return { sender, contents, type: 'minecraft:chat', chatType: ["player", "profileless"], displayName }
}
function isSeparatorAt (children, start) {
+1 -1
View File
@@ -23,7 +23,7 @@ function parseMessage(message, data, context) {
);
}
if (!sender) return; //stringUsername
return { sender, contents, type: "minecraft:chat", senderComponent };
return { sender, contents, type: "minecraft:chat", chatType: ["player", "profileless"], senderComponent };
} catch (e) {
console.error(`${e.stack}`);
}
+2 -1
View File
@@ -1,11 +1,12 @@
class CommandContext {
constructor(name, aliases, description, trustLevel, usages) {
constructor(name, aliases, description, trustLevel, usages, playerOnly) {
this.data = {};
this.data.name = name;
this.data.aliases = aliases;
this.data.description = description;
this.data.trustLevel = trustLevel;
this.data.usages = usages;
this.data.playerOnly = playerOnly
}
}
module.exports = CommandContext;
+3 -2
View File
@@ -1,8 +1,9 @@
class CommandSource {
constructor(player, sources, hash) {
constructor(player, sources, ChatType) {
this.player = player;
this.sources = sources;
this.player.hash = hash;
this.ChatType = ChatType
this.player.hash = null;
}
}
module.exports = CommandSource;
+3 -1
View File
@@ -9,7 +9,9 @@ class kick extends CommandContext {
"invalidstring",
"item",
"te",
]);
],
false
);
}
execute(context) {
const bot = context.bot;
+3 -1
View File
@@ -11,7 +11,9 @@ class console extends CommandContext {
"say <message>",
"validate/validation/val <owner/o/admin/a/trusted/t>",
"logging/togglelogging/logtoconsole <on/true/enable/off/false/disable>",
]);
],
false
);
}
execute(context) {
const bot = context.bot;
+1 -1
View File
@@ -4,7 +4,7 @@ const trustLevel = new CommandTrustLevel()
class kill extends CommandContext {
constructor() {
super("kill", ["suicide", "quit"], "kill the bots process", trustLevel.owner, [""]);
super("kill", ["suicide", "quit"], "kill the bots process", trustLevel.owner, [""], false);
}
execute(context) {
const bot = context.bot;
+2 -1
View File
@@ -17,7 +17,8 @@ class core extends CommandContext {
"$username <message>",
"$uuid <message>",
"<message>",
]
],
false
);
}
execute(context) {
+4 -2
View File
@@ -5,8 +5,10 @@ const trustLevel = new CommandTrustLevel()
class echo extends CommandContext {
constructor() {
super("echo", ["say", "botsay"], "make me say something!", trustLevel.public, [
"<message>",
]);
'',
],
true
);
}
execute(context) {
+1
View File
@@ -11,6 +11,7 @@ class help extends CommandContext {
"see a list of commands",
trustLevel.public,
["<command>"],
false
);
}
+3 -1
View File
@@ -36,7 +36,9 @@ class info extends CommandContext {
"uptimes/uptime <bot, server, all>",
"server",
"version/ver",
]);
],
false
);
}
execute(context) {
+23
View File
@@ -0,0 +1,23 @@
const CommandContext = require("../../command_util/command_context");
const CommandTrustLevel = require('../../command_util/command_trust_level')
const trustLevel = new CommandTrustLevel()
class refillcore extends CommandContext {
constructor() {
super("rc", ["refill", "refillcore"], "refill the bots core", trustLevel.public, [
'',
],
true
);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
bot.core.move(bot.position)
bot.tellraw("@a", 'refilling core')
}
}
module.exports = refillcore;
+111
View File
@@ -0,0 +1,111 @@
const CommandError = require("../../command_util/command_error");
const fixAnsi = require("../../util/ansi");
const CommandContext = require("../../command_util/command_context");
const CommandTrustLevel = require('../../command_util/command_trust_level')
const trustLevel = new CommandTrustLevel()
class cloop extends CommandContext {
constructor() {
super("cloop", ["commandloop", "loop"], "loops commands", trustLevel.trusted, [
"add <interval> <command>",
"remove <index>",
"list",
"clear",
]);
}
execute(context) {
const bot = context.bot;
const config = context.config;
const source = context.source;
let args
let component = [];
if (!source.sources.console && !source.sources.discord) {
args = context.arguments.slice(16)
} else {
args = context.arguments
}
if (
!args &&
!args[0] &&
!args[1] &&
!args[2] &&
!args[3] &&
!args[4] &&
!args[5]
)
return;
switch (args[0]?.toLowerCase()) {
case "add":
if (isNaN(args[1])) throw new CommandError("invalid interval");
const interval = parseInt(args[1]);
const command = args.slice(2).join(" ");
bot.cloop.add(command, interval);
component.push(
`added ${command} to the cloops with the interval ${interval}`,
);
break;
case "clear":
bot.cloop.clear();
component.push("cleared the cloops");
break;
case "remove":
if (isNaN(args[1]))
throw new CommandError("argument must be an integer!");
const index = parseInt(args[1]);
bot.cloop.remove(index);
component.push(`removed ${index} from cloops`);
break;
case "list":
let listComponent = [];
let i = 0;
for (const cloop of bot.cloop.list) {
listComponent.push({
translate: "%s \u203a %s (%s)",
color: config.colors.commands.primary,
with: [
{ text: `${i}`, color: config.colors.integer },
cloop.command,
{ text: `${cloop.interval}`, color: config.colors.integer },
],
});
listComponent.push("\n");
i++;
}
listComponent.pop();
component.push({
translate: "Cloops (%s):",
color: config.colors.commands.primary,
with: [
{ text: `${bot.cloop.list.length}`, color: config.colors.integer },
],
});
component.push("\n");
if (bot.cloop.list.length > 0) {
component.push(listComponent);
}
break;
default:
throw new CommandError("invalid argument");
}
if (source.sources.discord) {
} else if (source.sources.console) {
bot.console.info(component)
} else {
bot.tellraw("@a", component);
}
}
}
module.exports = cloop
+19
View File
@@ -0,0 +1,19 @@
const CommandContext = require("../../command_util/command_context");
const CommandTrustLevel = require('../../command_util/command_trust_level')
const trustLevel = new CommandTrustLevel()
class reconnect extends CommandContext {
constructor() {
super("reconnect", ["end"], "reconnect the bot", trustLevel.trusted, [""], false);
}
execute(context) {
const bot = context.bot;
const args = context.arguments;
const source = context.source;
const config = context.config;
bot._client.end()
}
}
module.exports = reconnect
+1 -1
View File
@@ -4,7 +4,7 @@ const trustLevel = new CommandTrustLevel()
class validate extends CommandContext {
constructor() {
super("validate", ["val"], "validate through the bot", trustLevel.trusted, [""]);
super("validate", ["val"], "validate through the bot", trustLevel.trusted, [""], false);
}
execute(context) {
const bot = context.bot;
+94 -185
View File
@@ -1,6 +1,8 @@
const loadPrismarineChat = require("prismarine-chat");
const KaboomChatParser = require("../chat_parsers/kaboom");
const CreayunChatParser = require("../chat_parsers/creayun");
const ChipmunkModChatParser = require("../chat_parsers/chipmunkmod")
const VanilaChatParser = require("../chat_parsers/vanilla")
const convertNbtComponentToJson = require("../util/nbt_parser");
function tryParse(json) {
@@ -23,224 +25,125 @@ class chat {
if (options.mode === "savageFriends") {
bot.chatParsers = [CreayunChatParser];
} else {
bot.chatParsers = [KaboomChatParser];
bot.chatParsers = [KaboomChatParser, ChipmunkModChatParser, VanilaChatParser];
}
bot.on("packet.profileless_chat", (packet) => {
let message
let sender
if (bot._client.version === "1.21" || bot.options.version === "1.21.1") {
message = convertNbtComponentToJson(null, packet.message);
sender = convertNbtComponentToJson(null, packet.name);
} else {
message = tryParse(packet.message);
sender = tryParse(packet.name);
}
message = tryParse(packet.message);
sender = tryParse(packet.name);
if (bot.options.version === "1.21" || bot._client.version === "1.21.1") {
switch (packet.type.registryIndex) {
case 6:
bot.emit("message", {
translate: "chat.type.announcement",
with: [sender, message],
});
break;
case 5:
bot.emit("message", message);
break;
case 4:
bot.emit("message", {
switch (packet.type) {
case 1:
bot.emit("message", {
translate: "chat.type.emote",
with: [sender, message],
});
break;
case 2:
bot.emit("message", {
translate: "commands.message.display.incoming",
with: [sender, message],
color: "gray",
italic: true,
});
break;
case 3:
bot.emit("message", [
{
translate: "commands.message.display.outgoing",
with: [sender, message],
color: "gray",
italic: true,
});
break;
case 3:
bot.emit("message", {
translate: "commands.message.display.incoming",
with: [sender, message],
color: "gray",
italic: true,
});
break;
case 2:
bot.emit("message", {
translate: "chat.type.emote",
with: [sender, message],
});
break;
}
} else {
switch (packet.type) {
case 1:
bot.emit("message", {
translate: "chat.type.emote",
with: [sender, message],
});
break;
case 2:
bot.emit("message", {
translate: "commands.message.display.incoming",
with: [sender, message],
color: "gray",
italic: true,
});
break;
case 3:
bot.emit("message", [
{
translate: "commands.message.display.outgoing",
with: [sender, message],
color: "gray",
italic: true,
},
]);
break;
case 4:
bot.emit("message", [message]);
break;
case 5:
bot.emit("message", [
{ translate: "chat.type.announcement", with: [sender, message] },
]);
break;
}
},
]);
break;
case 4:
bot.emit("message", [message]);
break;
case 5:
bot.emit("message", [
{ translate: "chat.type.announcement", with: [sender, message] },
]);
break;
}
tryParsingMessage(message, { senderName: sender, players: bot.players, chatType: "profileless", getMessageAsPrismarine: bot.getMessageAsPrismarine })
});
bot.on("packet.player_chat", (packet, data) => {
let unsigned;
if (bot.options.version === "1.21" || bot.options.version === "1.21.1") {
unsigned = convertNbtComponentToJson(null, packet.unsignedChatContent);
} else {
unsigned = tryParse(packet.unsignedChatContent);
}
unsigned = tryParse(packet.unsignedChatContent);
if (bot.options.version === "1.21" || bot.options.version === "1.21.1") {
switch (packet.type.registryIndex) {
case 6:
bot.emit("message", {
translate: "chat.type.announcement",
with: [
bot.players.find((player) => player.uuid === packet.senderUuid)
.profile.name,
switch (packet.type) {
case 5:
bot.emit("message", {
translate: "chat.type.announcement",
with: [
bot.players.find((player) => player.uuid === packet.senderUuid)
.profile.name,
packet.plainMessage,
],
});
break;
case 4:
bot.emit("message", unsigned);
break;
case 3:
bot.emit("message", {
translate: "commands.message.display.outgoing",
with: [
bot.players.find((player) => player.uuid === packet.senderUuid)
.profile.name,
packet.plainMessage,
],
color: "gray",
italic: true,
});
break;
case 2:
bot.emit("message", {
translate: "commands.message.display.incoming",
with: [
bot.players.find((player) => player.uuid === packet.senderUuid)
.profile.name,
packet.plainMessage,
],
});
break;
case 5:
bot.emit("message", unsigned);
break;
case 4:
bot.emit("message", {
translate: "commands.message.display.outgoing",
with: [
bot.players.find((player) => player.uuid === packet.senderUuid)
.profile.name,
packet.plainMessage,
],
color: "gray",
italic: true,
});
break;
case 3:
bot.emit("message", {
translate: "commands.message.display.incoming",
with: [
bot.players.find((player) => player.uuid === packet.senderUuid)
.profile.name,
packet.plainMessage,
],
color: "gray",
italic: true,
});
break;
case 2:
bot.emit("message", {
translate: "chat.type.emote",
with: [
bot.players.find((player) => player.uuid === packet.senderUuid)
.profile.name,
packet.plainMessage,
],
});
break;
}
} else {
switch (packet.type) {
case 5:
bot.emit("message", {
translate: "chat.type.announcement",
with: [
bot.players.find((player) => player.uuid === packet.senderUuid)
.profile.name,
packet.plainMessage,
],
});
break;
case 4:
bot.emit("message", unsigned);
break;
case 3:
bot.emit("message", {
translate: "commands.message.display.outgoing",
with: [
bot.players.find((player) => player.uuid === packet.senderUuid)
.profile.name,
packet.plainMessage,
],
color: "gray",
italic: true,
});
break;
case 2:
bot.emit("message", {
translate: "commands.message.display.incoming",
with: [
bot.players.find((player) => player.uuid === packet.senderUuid)
.profile.name,
packet.plainMessage,
],
color: "gray",
italic: true,
});
break;
case 1:
bot.emit("message", {
translate: "chat.type.emote",
with: [
bot.players.find((player) => player.uuid === packet.senderUuid)
.profile.name,
packet.plainMessage,
],
});
break;
}
],
color: "gray",
italic: true,
});
break;
case 1:
bot.emit("message", {
translate: "chat.type.emote",
with: [
bot.players.find((player) => player.uuid === packet.senderUuid)
.profile.name,
packet.plainMessage,
],
});
break;
}
tryParsingMessage(unsigned, {
senderUuid: packet.senderUuid,
players: bot.players,
getMessageAsPrismarine: bot.getMessageAsPrismarine,
chatType: "player"
});
});
bot.on("packet.system_chat", (packet) => {
let message;
if (bot.options.version === "1.21" || bot.options.version === "1.21.1") {
message = convertNbtComponentToJson(null, packet.content);
} else {
message = tryParse(packet.content);
}
message = tryParse(packet.content);
if (
message.translate === "advMode.setCommand.success" &&
config?.debug?.commandSetMessage === false
)
return;
return;
if (message.translate === "multiplayer.message_not_delivered") return;
if (packet.isActionBar) {
@@ -250,14 +153,17 @@ class chat {
if (message.translate === "advMode.notAllowed") return;
bot.emit("message", message);
bot.emit("system_chat", message)
tryParsingMessage(message, {
players: bot.players,
getMessageAsPrismarine: bot.getMessageAsPrismarine,
chatType: "system"
});
});
function tryParsingMessage(message, data) {
try {
let parsed;
for (const parser of bot.chatParsers) {
@@ -267,6 +173,9 @@ class chat {
if (!parsed) return;
bot.emit("parsed_message", parsed);
} catch (e) {
console.log(e.stack)
}
}
bot.getMessageAsPrismarine = (message) => {
+19 -7
View File
@@ -25,7 +25,7 @@ class command_core {
usePlacedCommandBlock: false,
refill() {
chatRefill() {
const pos = bot.core.position;
const { start, end } = bot.core.area;
const itemPosition = bot.core.itemPosition;
@@ -35,10 +35,18 @@ class command_core {
if (bot.options.mode === "savageFriends") {
command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} command_block`;
} else {
command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} command_block{CustomName:'${JSON.stringify(config.core.name)}'}`;
command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} command_block{CustomName:${JSON.stringify(config.core.name)}}`;
}
bot.chat.command(command)
},
if (config.core.itemRefill && bot.options.mode !== "savageFriends") {
itemRefill () {
const pos = bot.core.position;
const { start, end } = bot.core.area;
const itemPosition = bot.core.itemPosition;
command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} command_block{CustomName:${JSON.stringify(config.core.name)}}`;
if (bot.options.mode !== "savageFriends") {
bot._client.write("set_creative_slot", {
slot: 36,
item: Item.toNotch(
@@ -71,8 +79,6 @@ class command_core {
} else {
bot.core.commandBlock(command, itemPosition, 1, 5)
}
} else {
bot.chat.command(`${command}`);
}
},
@@ -89,7 +95,11 @@ class command_core {
z: Math.floor(pos.z),
};
bot.core.refill();
if (bot.options.itemRefill) {
bot.core.itemRefill();
} else {
bot.core.chatRefill()
}
},
currentBlock() {
@@ -127,8 +137,9 @@ class command_core {
},
commandBlock (command, location, mode, flags) {
if (!bot.loggedIn) return;
bot._client.write("update_command_block", {
command: command.substring(0, 32767),
command: command?.substring(0, 32767),
location: location,
mode: mode,
flags: flags,
@@ -136,6 +147,7 @@ class command_core {
},
run(command) {
if (!bot.loggedIn) return;
const location = bot.core.currentBlock();
const itemPosition = bot.core.itemPosition;
+2 -1
View File
@@ -14,7 +14,7 @@ class command_handler {
prefixes.map((prefix) => {
const plainMessage = bot
.getMessageAsPrismarine(data.contents)
?.toMotd();
?.toString();
if (!plainMessage?.startsWith(prefix)) return;
const command = plainMessage.substring(prefix.length);
@@ -22,6 +22,7 @@ class command_handler {
const source = new CommandSource(
data.sender,
{ discord: false, console: false },
data.chatType,
null
);
+2 -2
View File
@@ -12,7 +12,7 @@ class command_loop {
};
this.list.push(timer);
bot.on("end", () => {
/* bot.on("end", () => {
this.clear();
});
@@ -24,7 +24,7 @@ class command_loop {
interval,
};
this.list.push(timer);
});
});*/
},
remove(index) {
+8 -4
View File
@@ -32,7 +32,6 @@ class command_manager {
const options = context.options;
const { MessageBuilder } = require('prismarine-chat')(bot._client.version)
bot.commandManager = {
commands: {},
commandlist: [],
@@ -46,9 +45,11 @@ class command_manager {
)
else source.sendFeedback(unknownCommand(MessageBuilder, commandName, bot))
}
const event = bot.discord.message;
const roles = event?.member?.roles?.cache;
// console.log(command)
// console.log(source)
switch (command?.data?.trustLevel) {
case 0:
@@ -163,7 +164,7 @@ class command_manager {
break
}
if (source.sources.discord) {
/* if (source.sources.discord) {
discordClient.channels.cache
.get("1361739286113685534")
.send(
@@ -175,8 +176,11 @@ class command_manager {
.send(
`User: ${source.player.profile.name}, Command: ${command?.data?.name}, Args: ${args.join(" ")}, Time/Date: ${new Date().toLocaleString("en-us", { TimeZone: "America/Chicago" })}, Source: Minecraft, Server: ${bot.options.host}:${bot.options.port}`,
);
}
}*/
// if (command.playerOnly === true && source.ChatType.find((e) => e)) return;
return command?.execute({
bot,
source,
+46
View File
@@ -0,0 +1,46 @@
class command_spy {
constructor (context) {
const bot = context.bot
bot.on('system_chat', (message) => {
try {
const child = message.extra
const sender = bot.players.find((e) => e?.profile?.name === message.text)?.profile?.name === message.text
if (!child || !message.text || !message.color || !sender) return
const command = child[1].text.substring('/'.length)
if (
(
message.color === 'yellow'
&&
child[0].text === ': '
&&
child[1].text === `/${command}`
&&
sender
)
||
(
message.color === 'aqua'
&&
child[0].text === ': '
&&
child[1].text === `/${command}`
&&
sender
)
) bot.emit('parsed_message', {
sender: bot.players.find((e) => e.profile.name === message.text),
contents: { text: command },
type: "minecraft:chat",
chatType: "command_spy",
displayName: bot.players.find((e) => e.profile.name === message.text).displayName
})
} catch (e) {
console.log(e.stack)
}
})
}
}
module.exports = command_spy;
+7
View File
@@ -0,0 +1,7 @@
class database {
constructor (context) {
}
}
module.exports = database
+8 -18
View File
@@ -9,12 +9,12 @@ class player_list {
bot.on("packet.player_info", async (packet) => {
const actions = [];
if (packet.action & 0b000001) actions.push(addPlayer);
if (packet.action & 0b000010) actions.push(initializeChat);
if (packet.action & 0b000100) actions.push(updateGamemode);
if (packet.action & 0b001000) actions.push(updateListed);
if (packet.action & 0b010000) actions.push(updateLatency);
if (packet.action & 0b100000) actions.push(updateDisplayName);
if (packet.action._value & 0b000001) actions.push(addPlayer);
if (packet.action._value & 0b000010) actions.push(initializeChat);
if (packet.action._value & 0b000100) actions.push(updateGamemode);
if (packet.action._value & 0b001000) actions.push(updateListed);
if (packet.action._value & 0b010000) actions.push(updateLatency);
if (packet.action._value & 0b100000) actions.push(updateDisplayName);
for (const entry of packet.data) {
for (const action of actions) {
@@ -44,6 +44,7 @@ class player_list {
});
function addPlayer(entry) {
console.log
bot.players = bot.players.filter((_entry) => _entry.uuid !== entry.uuid);
bot.players.push({
uuid: entry.uuid,
@@ -59,7 +60,6 @@ class player_list {
displayName: undefined,
vanished: false,
});
// console.log(entry)
}
function initializeChat(entry) {}
@@ -90,17 +90,7 @@ class player_list {
if (!target) return;
try {
if (
bot.options.version === "1.21" ||
bot.options.version === "1.21.1"
) {
target.displayName = convertNbtComponentToJson(
null,
entry.displayName,
);
} else {
target.displayName = JSON.parse(entry.displayName);
}
target.displayName = JSON.parse(entry.displayName);
} catch {
// do nothing
}
+1 -1
View File
@@ -5,7 +5,7 @@ class registry {
const bot = context.bot;
bot.on("packet.login", (packet) => {
bot.registry = createRegistry(bot._client.version);
bot.registry.language = require("../data/language.json");
// bot.registry.language = require("../data/language.json");
bot.emit("registry_ready", bot.registry);
});
}
+53 -33
View File
@@ -6,19 +6,37 @@ class selfcare {
const bot = context.bot
const config = context.config
const options = context.options
let messageSelfcare
let loadMessageSelfcare
bot.selfcare = {
permissionLevel: 2,
entityId: undefined,
gameMode: undefined,
commandSpy: undefined
commandSpy: undefined,
prefix: undefined,
vanished: undefined,
mute: undefined,
username: undefined,
nickname: undefined,
god: undefined,
position_count: 0,
}
for (const file of fs.readdirSync(path.join(__dirname, '../selfcare/message'))) {
let selfcare = [];
for (const file of fs.readdirSync(path.join(__dirname, '../selfcare/extras'))) {
try {
loadMessageSelfcare = require(path.join(__dirname, '../selfcare/message', file))
const extrasSelfcare = require(path.join(__dirname, '../selfcare/extras', file))
selfcare.push(extrasSelfcare)
} catch (e) {
console.error(e.stack)
}
}
for (const file of fs.readdirSync(path.join(__dirname, '../selfcare/essentials'))) {
try {
const essentialsSelfcare = require(path.join(__dirname, '../selfcare/essentials', file))
selfcare.push(essentialsSelfcare)
} catch (e) {
console.error(e.stack)
}
@@ -27,50 +45,52 @@ class selfcare {
for (const file of fs.readdirSync(path.join(__dirname, '../selfcare/entity'))) {
try {
const loadEntitySelfcare = require(path.join(__dirname, '../selfcare/entity', file))
const entitySelfcare = new loadEntitySelfcare({ bot, config, options })
new loadEntitySelfcare({ bot, config, options })
} catch (e) {
console.error(e.stack)
}
} // how the fuck do i want to implement this...
}
bot.on('message', (message) => {
bot.on('system_chat', (message) => {
const stringMessage = bot.getMessageAsPrismarine(message)?.toString()
//new loadMessageSelfcare({ bot, options, config, stringMessage })
for (const file of selfcare) new file({ bot, config, options, stringMessage })
})
let timer;
bot.on('packet.login', (data) => {
bot.selfcare.entityId = data.entityId;
if (bot.options.version === "1.21" || bot.options.version === "1.21.1") {
switch (data.worldState.gamemode) {
case "survival":
bot.selfcare.gameMode = 0;
break;
case "creative":
gameMode = 1;
break;
case "adventure":
bot.selfcare.gameMode = 2;
break;
case "spectator":
bot.selfcare.gameMode = 3;
break;
default:
bot.selfcare.gameMode = 0;
break;
}
} else {
bot.selfcare.gameMode = data.gameMode;
}
bot.selfcare.gameMode = data.gameMode;
timer = setInterval(() => {
if (bot.selfcare.permissionLevel < 2) bot.chat.command('minecraft:op @s[type=player]')
else if (bot.selfcare.gameMode !== 1) bot.chat.command('minecraft:gamemode creative')
//else if (!bot.selfcare.commandSpy) bot.core.run(`commandspy ${bot.uuid} on`)
if (bot.options.mode === "savageFriends") {
} else {
if (!bot.selfcare.prefix) bot.chat.command(`extras:prefix &8[&bPrefix&8: &3${config.prefixes[0]}&8]`);
else if (bot.selfcare.permissionLevel < 2) bot.chat.command('minecraft:op @s[type=player]')
else if (bot.selfcare.username) bot.chat.command(`extras:username ${bot._client.username}`)
else if (bot.selfcare.gameMode !== 1) bot.chat.command('minecraft:gamemode creative')
else if (!bot.selfcare.commandSpy) bot.core.run(`commandspy ${bot.uuid} on`)
else if (!bot.selfcare.vanished) bot.core.run(`essentials:vanish ${bot._client.username} on`)
else if (!bot.selfcare.god) bot.core.run(`essentials:god ${bot._client.username} on`)
else if (bot.selfcare.mute) bot.core.run(`essentials:mute ${bot._client.uuid}`)
else if (bot.selfcare.nickname) bot.core.run(`essentials:nickname ${bot._client.username} off`)
}
}, options.selfcareInterval)
})
bot.on('end', () => {
if (timer) clearInterval(timer)
bot.selfcare.commandSpy = false
bot.selfcare.prefix = false
bot.selfcare.vanished = false
bot.selfcare.mute = false
bot.selfcare.username = false
bot.selfcare.nickname = false
bot.selfcare.god = false
})
}
}
+20
View File
@@ -0,0 +1,20 @@
class icuSelfcare {
constructor (context) {
const bot = context.bot;
const config = context.config
const options = context.options
bot.on("packet.position", (packet, position) => {
if (options.mode === "savageFriends" || options.mode === "creayun") return;
bot.selfcare.position_count++
setTimeout(() => {
bot.selfcare.position_count--
if (bot.selfcare.position_count > 4) {
bot._client.end('anti icu')
}
}, 1000)
})
}
}
module.exports = icuSelfcare
+13
View File
@@ -0,0 +1,13 @@
class godSelfcare {
constructor (context) {
const bot = context.bot;
const options = context.options;
const stringMessage = context.stringMessage;
if (stringMessage === "God mode disabled.") bot.selfcare.god = false;
else if (stringMessage === "God mode enabled.") bot.selfcare.god = true;
}
}
module.exports = godSelfcare
+13
View File
@@ -0,0 +1,13 @@
class muteSelfcare {
constructor (context) {
const bot = context.bot;
const options = context.options;
const stringMessage = context.stringMessage;
if (stringMessage?.startsWith("You have been muted")) bot.selfcare.mute = true;
else if (stringMessage?.startsWith("You have been unmuted")) bot.selfcare.mute = false;
else if (stringMessage?.startsWith("Your voice has been silenced")) bot.selfcare.mute = true;
}
}
module.exports = muteSelfcare
+12
View File
@@ -0,0 +1,12 @@
class nicknameSelfcare {
constructor (context) {
const bot = context.bot;
const options = context.options;
const stringMessage = context.stringMessage;
if (stringMessage === `You no longer have a nickname.`) bot.selfcare.nickname = false;
else if (stringMessage?.startsWith('Your nickname is now ')) bot.selfcare.nickname = true;
}
}
module.exports = nicknameSelfcare
+12
View File
@@ -0,0 +1,12 @@
class vanishSelfcare {
constructor (context) {
const bot = context.bot;
const options = context.options;
const stringMessage = context.stringMessage;
if (stringMessage === `Vanish for ${bot._client.username}: enabled`) bot.selfcare.vanished = true;
else if (stringMessage === `Vanish for ${bot._client.username}: disabled`) bot.selfcare.vanished = false;
}
}
module.exports = vanishSelfcare
@@ -2,15 +2,14 @@ class commandSpySelfcare {
constructor (context) {
const bot = context.bot
const stringMessage = context.stringMessage
if (stringMessage === "Successfully enabled CommandSpy")
bot.selfcare.commandSpy = true;
if (stringMessage === "Successfully enabled CommandSpy") return bot.selfcare.commandSpy = true;
else if (stringMessage === "Successfully enabled CommandSpy.")
bot.selfcare.commandSpy = true;
return bot.selfcare.commandSpy = true;
else if (stringMessage === "Successfully disabled CommandSpy")
bot.selfcare.commandSpy = false;
return bot.selfcare.commandSpy = false;
else if (stringMessage === "Successfully disabled CommandSpy.")
bot.selfcare.commandSpy = false;
return bot.selfcare.commandSpy = false;
}
}
+17
View File
@@ -0,0 +1,17 @@
class prefixSelfcare {
constructor (context) {
const bot = context.bot
const options = context.options
const stringMessage = context.stringMessage
const config = context.config
if (options.mode === "savageFriends") {
} else {
if (stringMessage === `You now have the tag: &8[&bPrefix&8: &3${config.prefixes[0]}&8]` || stringMessage === "Something went wrong while saving the prefix. Please check console.") bot.selfcare.prefix = true;
else if (stringMessage?.startsWith("You now have the tag: ") || stringMessage === "You no longer have a tag") bot.selfcare.prefix = false
}
}
}
module.exports = prefixSelfcare
+17
View File
@@ -0,0 +1,17 @@
class usernameSelfcare {
constructor (context) {
const bot = context.bot
const options = context.options
const stringMessage = context.stringMessage
const config = context.config
if (stringMessage === `Successfully set your username to "${bot._client.username}"`) {
bot.selfcare.username = false
return
}
else if (stringMessage?.startsWith("Successfully set your username to ")) bot.selfcare.username = true
else if (stringMessage === `You already have the username "${bot._client.username}"`) bot.selfcare.username = false
}
}
module.exports = usernameSelfcare
-15
View File
@@ -1,15 +0,0 @@
class prefixSelfcare {
constructor (context) {
const bot = context.bot
const options = context.options
const stringMessage = context.stringMessage
if (options.mode === "savageFriends") {
} else {
}
}
}
module.exports = prefixSelfcare