added fallback partically to commands *yes i know its shit*, made the prefix selfcare check the display and more

This commit is contained in:
Parker2991
2025-09-24 07:57:50 -05:00
parent 872cf09c6a
commit b71f4a2ab0
36 changed files with 1092 additions and 509 deletions
+4 -2
View File
@@ -74,8 +74,10 @@ class chat {
tryParsingMessage(parsed, { senderName: sender, players: bot.players, getMessageAsPrismarine: bot.getMessageAsPrismarine, chatType: "minecraft:diguised_chat" })
});
bot.on("packet.player_chat", (packet, data) => {
bot.on("packet.player_chat", (packet) => {
const unsigned = convertNbtComponentToJson(null, packet.unsignedChatContent);
const networkName = convertNbtComponentToJson(null, packet.networkName)
bot.emit('message', {
type: "minecraft:player_chat",
message: unsigned
@@ -104,13 +106,13 @@ class chat {
if (message.translate === "advMode.notAllowed") return;
// console.log(JSON.stringify(message))
bot.emit("message", {
type: "minecraft:system_chat",
message: message
});
bot.emit("system_chat", message);
//if (bot.options.mode !== "savageFriends") return;
tryParsingMessage(message, {
players: bot.players,
getMessageAsPrismarine: bot.getMessageAsPrismarine,
-1
View File
@@ -149,7 +149,6 @@ class command_core {
},
run(command) {
if (!bot.loggedIn) return;
const location = bot.core.currentBlock();
const itemPosition = bot.core.itemPosition;
+1 -1
View File
@@ -28,7 +28,7 @@ class command_handler {
);
source.sendFeedback = (message) => {
if (options.mode === "savageFriends") bot.tellraw(`@a[name=${source.player.profile.name}]`, [
if (options.mode === "savageFriends") bot.tellraw(`@a`, [
message
])
else bot.tellraw(`@a[name="${source.player.profile.name}"]`, message)
+40 -8
View File
@@ -1,10 +1,10 @@
const fs = require("fs");
const path = require("path");
const CommandError = require("../command_util/command_error.js");
const CommandError = require("../command_util/command_error");
const CommandSource = require("../command_util/command_source");
const CommandArguments = require('../command_util/command_arguments')
const fixansi = require("../util/ansi");
const sleep = require("../util/sleep.js");
const trustLevels = require('../command_util/command_trust_level.js')
function unknownCommand(commandName, bot) {
return {
@@ -25,6 +25,7 @@ class command_manager {
const config = context.config;
const discordClient = context.discordClient;
const options = context.options;
const translations = bot.translations;
bot.commandManager = {
commands: {},
@@ -34,11 +35,21 @@ class command_manager {
try {
const authFind = bot.auth.list.find((e) => e.player === source.player.uuid)
if (!command) {
source.sendFeedback(
throw new CommandError(
unknownCommand(commandName, bot),
);
}
if (args.length > command.data.args) throw new CommandError({
translate: "fnfboyfriendbot.arguments",
fallback: translations["fnfboyfriendbot.arguments"],
color: "red",
with: [
{ text: `${command.data.args}` },
{ text: `${args.length}`}
]
})
if (authFind) {
source.player.validateBypass = true
if (authFind.trustLevel === "trusted") source.player.trustLevel = 1;
@@ -46,7 +57,7 @@ class command_manager {
else if (authFind.trustLevel === "owner") source.player.trustLevel = 3;
}
if (command?.data?.trustLevel !== 0) {
if (command?.data?.trustLevel !== 0 && command?.data.trustLevel < 4) {
if (!source.player.validateBypass && !source.sources.console && !source.sources.discord) {
if (args[0] === bot.validation.trusted)
source.player.trustLevel = 1
@@ -54,10 +65,24 @@ class command_manager {
source.player.trustLevel = 2
else if (args[0] === bot.validation.owner)
source.player.trustLevel = 3
if (args[0] === bot.validation.discord.trusted) {
source.player.trustLevel = 1
bot.validation.discord.trusted = undefined;
} else if (args[0] === bot.validation.discord.admin) {
source.player.trustLevel = 2;
bot.validation.discord.admin = undefined;
} else if (args[0] === bot.validation.discord.owner) {
console.log(args[0])
console.log(bot.validation.discord.owner)
source.player.trustLevel = 3
bot.validation.discord.owner = undefined
}
args = args.slice(1)
if (source.player.trustLevel < command?.data?.trustLevel && !source.sources.console) {
throw new CommandError({
text: "Invalid Hash",
translate: "fnfboyfriendbot.commandManager.validation.invalid_hash",
fallback: translations["fnfboyfriendbot.commandManager.validation.invalid_hash"],
color: "red"
})
}
@@ -72,11 +97,17 @@ class command_manager {
if (source.player.trustLevel < command?.data?.trustLevel)
throw new CommandError({
text: "Invalid Role",
translate: "fnfboyfriendbot.commandManager.validation.invalid_role",
fallback: translations["fnfboyfriendbot.commandManager.validation.invalid_role"],
color: "red"
})
}
}
} if (command?.data?.trustLevel === 4 && !source.sources.console)
throw new CommandError({
translate: "fnfboyfriendbot.commandManager.trustLevel.consoleOnly",
fallback: translations["fnfboyfriendbot.commandManager.trustLevel.consoleOnly"],
color: "red"
})
if (
command?.data.playerChat
@@ -86,6 +117,8 @@ class command_manager {
!source.sources.console
&&
!source.sources.discord
&&
bot.options.mode === 'kaboom'
) return
return command?.execute({
bot,
@@ -97,7 +130,6 @@ class command_manager {
} catch (error) {
if (error instanceof CommandError) {
source.sendFeedback(error._message);
} else {
bot.console.error(error.stack)
-1
View File
@@ -10,7 +10,6 @@ class command_spy {
?.name === message.text;
if (!child || !message.text || !message.color || !sender) return;
const command = child[1].substring("/".length);
if (
(message.color === "yellow" &&
child[0] === ": " &&
+5 -14
View File
@@ -17,6 +17,9 @@ class Console {
serverName = `§1${bot.options.host}:§9${bot.options.port}`;
}
/*
process.stdin.on('keypress', (str, key) => {
*/
bot.console = {
readline: null,
server: "all",
@@ -33,15 +36,12 @@ class Console {
} else if (args.startsWith("")) {
bot.chat.send(args);
}
rl.on("close", () => {
this.readline = null;
});
});
},
/*
data.trustLevel,
data.validateBypass
*/
source: new CommandSource(
{
profile: {
@@ -58,7 +58,7 @@ class Console {
),
refreshLine(...args) {
this.readline.output.write("\x1b[2K\r");
this?.readline.output.write("\x1b[2K\r");
console.log.apply(console, arguments);
this.readline._refreshLine();
},
@@ -98,15 +98,6 @@ class Console {
?.toAnsi() + message,
);
},
debug(message) {
console.log(
prismarineChat
.fromNotch(
`§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO" })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })} §6debug§8] §8[${serverName}§8] `,
)
?.toAnsi() + message,
);
},
command(message) {
console.log(
prismarineChat
+6 -4
View File
@@ -22,7 +22,7 @@ class discord {
invite: config.discord.invite || undefined,
prefix: config.discord.prefix,
};
discordClient.once("ready", (context) => {
discordClient.once("clientReady", (context) => {
bot.discord.channel = discordClient.channels.cache.get(options.channelId);
discordClient.user.setPresence({
activities: [
@@ -89,8 +89,10 @@ class discord {
false,
message,
);
sendComponent(message);
source.sendFeedback = input => {
message?.reply(`\`\`\`ansi\n${fixansi(bot.getMessageAsPrismarine(input)?.toAnsi()?.replaceAll('`', '`\u200b').substring(0, 1780))}\`\`\``);
}
bot.commandManager.executeString(
source,
@@ -134,7 +136,7 @@ class discord {
: undefined,
hover_event: {
action: "show_text",
contents: "Click to join the discord",
value: [ "Click to join the discord" ],
},
},
{
+6 -1
View File
@@ -47,9 +47,10 @@ class player_list {
function addPlayer(entry) {
bot.players = bot.players.filter((_entry) => _entry.uuid !== entry.uuid);
//console.log(convertNbtComponentToJson(null, entry.displayName).extra[0])
bot.players.push({
uuid: entry.uuid,
mcUUID: "",
// mcUUID: "",
profile: {
name: entry.player.name,
properties: entry.player.properties,
@@ -59,8 +60,10 @@ class player_list {
listed: undefined,
latency: undefined,
displayName: undefined,
prefix: undefined,
vanished: false,
});
bot.emit('player_info', entry)
}
@@ -92,12 +95,14 @@ class player_list {
try {
target.displayName = convertNbtComponentToJson(null, entry.displayName);
if (bot.options.mode === "kaboom") target.prefix = convertNbtComponentToJson(null, entry.displayName).extra[0]
} catch {
// do nothing
}
}
bot.on("end", () => (bot.players = []));
}
}
module.exports = player_list;
+25 -55
View File
@@ -23,64 +23,30 @@ class selfcare {
position_count: 0,
};
let selfcare = [];
for (const file of fs.readdirSync(
path.join(__dirname, "../selfcare/extras"),
)) {
try {
const extrasSelfcare = require(
path.join(__dirname, "../selfcare/extras", file),
);
selfcare.push(extrasSelfcare);
} catch (e) {
console.error(e.stack);
}
}
const messageSelfcare = [
require('../selfcare/extras/command_spy'),
require('../selfcare/essentials/god'),
require('../selfcare/essentials/mute'),
require('../selfcare/auth/login'),
require('../selfcare/auth/register'),
require('../selfcare/essentials/vanish')
]
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);
}
}
for (const file of fs.readdirSync(
path.join(__dirname, "../selfcare/auth"),
)) {
try {
const authSelfcare = require(
path.join(__dirname, "../selfcare/auth", file),
);
selfcare.push(authSelfcare);
} catch (e) {
console.error(e.stack);
}
}
for (const file of fs.readdirSync(
path.join(__dirname, "../selfcare/entity"),
)) {
try {
const loadEntitySelfcare = require(
path.join(__dirname, "../selfcare/entity", file),
);
new loadEntitySelfcare({ bot, config, options });
} catch (e) {
console.error(e.stack);
}
}
const entitySelfcare = [
require('../selfcare/entity/gamemode'),
require('../selfcare/entity/icu'),
require('../selfcare/entity/op'),
require('../selfcare/extras/prefix'),
require('../selfcare/extras/username'),
require('../selfcare/entity/death')
//require('../selfcare/essentials/vanish')
]
for (const entity of entitySelfcare) new entity({ bot, config, options });
bot.on("system_chat", (message) => {
const stringMessage = bot.getMessageAsPrismarine(message)?.toString();
for (const file of selfcare)
for (const file of messageSelfcare)
new file({ bot, config, options, stringMessage });
});
let timer;
@@ -108,7 +74,10 @@ class selfcare {
if (bot.options.mode === "savageFriends") {
if (bot.selfcare.register) bot.chat.command('register amogusissus amogusissus')
else if (bot.selfcare.login) bot.chat.command('login amogusissus')
else if (bot.selfcare.permissionLevel < 2)
bot.chat.command(`minecraft:op ${bot._client.username}`);
else if (bot.selfcare.gameMode !== 1)
bot._client.write('change_gamemode', { mode: 1 })
} else if (bot.options.mode === "kaboom") {
if (!bot.selfcare.prefix)
bot.chat.command(
@@ -118,7 +87,8 @@ class selfcare {
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");
if (bot.options.chatGamemodeChange) bot.chat.command("minecraft:gamemode creative")
else bot._client.write("change_gamemode", { mode: 1 })
else if (!bot.selfcare.commandSpy)
bot.core.run(`commandspy ${bot.uuid} on`);
else if (!bot.selfcare.vanished)
+11 -18
View File
@@ -4,25 +4,18 @@ class validation {
constructor(context) {
const bot = context.bot;
const config = context.config;
bot.validation = {
discord: {}
}
setInterval(() => {
bot.validation = {
trusted: crypto
.createHash("sha512")
.update(Math.floor(Date.now() / 2000) + config.keys.trusted)
.digest("hex")
.substring(0, 16),
admin: crypto
.createHash("sha512")
.update(Math.floor(Date.now() / 2000) + config.keys.admin)
.digest("hex")
.substring(0, 16),
owner: crypto
.createHash("sha512")
.update(Math.floor(Date.now() / 2000) + config.keys.owner)
.digest("hex")
.substring(0, 16),
};
}, 100);
bot.validation.trusted = crypto.createHash("sha512").update(Math.floor(Date.now() / 2000) + config.keys.trusted).digest("hex").substring(0, 16)
bot.validation.admin = crypto.createHash("sha512").update(Math.floor(Date.now() / 2000) + config.keys.admin).digest("hex").substring(0, 16)
bot.validation.owner = crypto.createHash("sha512").update(Math.floor(Date.now() / 2000) + config.keys.owner).digest("hex").substring(0, 16)
}, 100)
setInterval(() => {
bot.validation.discord = {} // to clear discord hashes if they were sent and not used
}, 10000)
}
}
module.exports = validation;