v6.1.3, build: 1210, 12/06/24

refratured the core.

fixed reconnect spam.

added coresettings so that the core can be configured via command.

added team selfcare.
This commit is contained in:
Parker2991
2024-12-06 11:04:23 -05:00
parent ad4f35bb4c
commit 572e09989c
23 changed files with 425 additions and 166 deletions
+95 -82
View File
@@ -1,4 +1,5 @@
const mcData = require('minecraft-data')('1.20.2');
const nbt = require('prismarine-nbt');
function core (context) {
const bot = context.bot;
@@ -12,9 +13,13 @@ function core (context) {
position: null,
itemPosition: null,
currentBlockRelative: { x: 0, y: 0, z: 0 },
refill () {
usePlacedCommandBlock: false,
chatRefill () {
const pos = bot.core.position
const { start, end } = bot.core.area
@@ -30,45 +35,62 @@ function core (context) {
instead of tping to a set cords cuz fuck you im not doing that
*/
const 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} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'} destroy`
if (config.core.method === 'chat') {
bot.chat.command(`${command}`)
} else if (config.core.method === 'item') {
bot._client.write('set_creative_slot', {
slot: 36,
item: {
present: true,
itemId: mcData.itemsByName.command_block.id,
itemCount: 1,
nbtData: { }
}
});
bot.chat.command(`${command}`)
},
bot._client.write('block_dig', {
status: 0,
location: {
x: bot.position.x,
y: bot.position.y,
z: bot.position.z
},
face: 0
});
itemRefill () {
const pos = bot.core.position;
const { start, end } = bot.core.area;
const itemPosition = bot.core.itemPosition;
bot._client.write('block_place', {
hand: 0,
location: {
x: bot.position.x,
y: bot.position.y,
z: bot.position.z
},
direction: 0,
cursorX: 0.1,
cursorY: 0,
cursorZ: 0.1,
insideBlock: false
});
if (!pos) return;
if (bot.options.useChat || bot.options.isCreayun || bot.options.isSavage) return;
if (isNaN(pos.x + pos.x)) {
bot.chat.command('spawn');
return
}
/*^^^
for checking is the core pos is null and if so
it will not refill core until the pos is not NaN
instead of tping to a set cords cuz fuck you im not doing that
*/
const 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} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'} destroy`
bot._client.write('set_creative_slot', {
slot: 36,
item: {
present: true,
itemId: mcData.itemsByName.repeating_command_block.id,
itemCount: 1,
nbtData: nbt.comp({
BlockEntityTag: nbt.comp({
CustomName: nbt.string(JSON.stringify(config.core.itemName))
})
})
}
});
bot._client.write('block_dig', {
status: 0,
location: itemPosition,
face: 0
});
bot._client.write('block_place', {
hand: 0,
location: itemPosition,
direction: 0,
cursorX: 0.1,
cursorY: 0,
cursorZ: 0.1,
insideBlock: false
});
if (bot.core.usePlacedCommandBlock) {
return
} else {
bot._client.write('update_command_block', {
location: bot.position,
location: itemPosition,
command,
flags: 5,
mode: 1
@@ -81,8 +103,19 @@ function core (context) {
x: Math.floor(pos.x / 16) * 16,
y: 0,
z: Math.floor(pos.z / 16) * 16
};
bot.core.itemPosition = {
x: pos.x,
y: pos.y -1,
z: pos.z
}
if (config.core.itemRefill === true) {
bot.core.itemRefill();
} else {
bot.core.chatRefill();
}
bot.core.refill()
},
currentBlock () {
@@ -116,54 +149,34 @@ function core (context) {
},
run (command) {
const eee = Math.floor(Math.random() * 10000)
const location = bot.core.currentBlock()
if (!location) return
const location = bot.core.currentBlock();
const itemPosition = bot.core.itemPosition;
if (!location) return;
if (bot.options.isSavage || bot.options.isCreayun || bot.options.useChat) {
return
} else {
bot._client.write('update_command_block', { command: command.substring(0, 32767), location, mode: 1, flags: 0b100 });
bot._client.write('query_block_nbt', ({ location: location, transactionId: eee}));
bot.core.incrementCurrentBlock();
if (bot.core.usePlacedCommandBlock) {
bot._client.write('update_command_block', {
command: command.substring(0, 32767),
location: itemPosition,
mode: 1,
flags: 5,
});
bot.core.incrementCurrentBlock();
} else {
bot._client.write('update_command_block', {
command: command.substring(0, 32767),
location,
mode: 1,
flags: 5
});
bot.core.incrementCurrentBlock();
}
}
},
runTracked (command) {
const transactionId = Math.floor(Math.random() * 1000);
const location = bot.core.currentBlock();
if (!location) return;
if (bot.position.y !== bot.core.position.y) {
bot.chat.command(`minecraft:tp ${bot.core.position.x} ${bot.core.position.y} ${bot.core.position.z}`)
}
bot._client.write('update_command_block', {
command: command.substring(0, 32767),
location,
flags: 5,
mode: 1,
// LastOutput: true,
});
bot.core.incrementCurrentBlock();
bot._client.write('query_block_nbt', {
location,
transactionId
});
bot.on('packet.nbt_query_response', (data) => {
// transactionId,
try {
if (data.transactionId === transactionId) {
bot.tellraw("@a", require('util').inspect(data.value))
bot.tellraw("@a", JSON.stringify(data.value))
}
} catch (e) {
bot.tellraw("@a", require("util").inspect(e.stack));
}
})
}
}
if (bot.options.isSavage || bot.options.isCreayun) return
@@ -174,11 +187,11 @@ function core (context) {
bot.on('packet.block_change', (data) => {
// console.log('data pos ' + JSON.stringify(data.location))
// console.log('core pos ' +JSON.stringify(bot.core.position));
if (data.type === 0) {
// if (data.type === 0) {
// console.log('data pos ' + JSON.stringify(data.location));
// console.log('core position ' + JSON.stringify(bot.core.position));
// bot.core.refill();
}
//}
})
}
module.exports = core;
+3 -3
View File
@@ -57,7 +57,7 @@ async function command_manager (context) {
break;
case 1:
if (source?.sources?.discord) {
const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.admin}` || role.name === `${config.discord.roles.owner}`)
const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.admin}` || role.name === `${config.discord.roles.fullAccess}` || role.name === `${config.discord.roles.owner}`)
if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!', color: "dark_red" })
} else if (!source?.sources.console) {
if (args.length === 0) throw new CommandError({ text: "Please provide a trusted, admin or owner hash", color: "dark_red" });
@@ -66,7 +66,7 @@ async function command_manager (context) {
break;
case 2:
if (source?.sources?.discord) {
const hasRole = roles?.some(role => role.name === `${config.discord.roles.admin}` || role.name === `${config.discord.roles.owner}`)
const hasRole = roles?.some(role => role.name === `${config.discord.roles.admin}` || role.name === `${config.discord.roles.fullAccess}` ||role.name === `${config.discord.roles.owner}`)
if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!', color: "dark_red" })
} else if (!source?.sources?.console) {
if (args.length === 0) throw new CommandError({ text: "Please provide an admin or owner hash", color: 'dark_red' })
@@ -75,7 +75,7 @@ async function command_manager (context) {
break;
case 3:
if (source?.sources?.discord) {
const hasRole = roles?.some(role => role.name === `${config.discord.roles.owner}`)
const hasRole = roles?.some(role => role.name === `${config.discord.roles.owner}` || role.name === `${config.discord.roles.fullAccess}`)
if (!hasRole) throw new CommandError({ translate: 'You are not the owner!', color: "dark_red" })
} else if (!source?.sources?.console) {
if (args.length === 0 && bot.validation.owner) throw new CommandError({ text: "Please provide an owner hash", color: "dark_red" })
+1 -1
View File
@@ -93,7 +93,7 @@ function Console (context) {
bot.console.fileLogger(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ${bot.getMessageAsPrismarine(message)?.toString()}`);
ratelimit++
})
// console.log(ratelimit)
bot.on('bossBar', (message) => {
if (!options.logging) return;
if (ratelimit > 10) return;
+1 -1
View File
@@ -42,7 +42,7 @@ function discord (context) {
try {
bot?.discord?.channel?.send(`\`\`\`ansi\n${discordQueue.join('\n').substring(0, 1984)}\n\`\`\``)
} catch (error) {
bot.console.warn(error.toString())
console.error(error.toString())
}
discordQueue = []
}, 2000)
+11 -5
View File
@@ -18,19 +18,20 @@ function player_list (context) {
action(entry)
}
}
bot.emit("player_info", packet);
})
bot.on('packet.player_remove', async ({players}) => { // players has uuids of the players
let player_completion = (await bot.tab_complete('scoreboard players add ')).filter(_ => _.tooltip == undefined) // exclude @a, @r, @s, @e, @p -aaa
bot.players.forEach(async player => {
if(!players.includes(player.uuid)) return
if (!players.includes(player.uuid)) return
const a = player_completion.filter(_ => _.match == player.profile.name)
if(a.length >= 1) {
player.vanished = true
if (a.length >= 1) {
player.vanished = true;
} else {
bot.players = bot.players.filter(_ => _.uuid != player.uuid)
bot.players = bot.players.filter(_ => _.uuid != player.uuid);
bot.emit("player_left", player);
}
})
})
@@ -47,6 +48,11 @@ function player_list (context) {
displayName: undefined,
vanished: false
})
if (entry.vanished) {
bot.emit("player_vanished", entry);
} else {
bot.emit("player_joined", entry);
}
}
function initializeChat (entry) {
+2 -3
View File
@@ -1,14 +1,13 @@
function position (context) {
const bot = context.bot;
bot.position = null
bot.position = null;
bot.on('packet.position', packet => {
bot.position = {
x: packet.flags & 1 ? (this.x + packet.x) : packet.x,
y: packet.flags & 2 ? (this.y + packet.y) : packet.y,
z: packet.flags & 4 ? (this.z + packet.z) : packet.z
}
};
bot._client.write('teleport_confirm', { teleportId: packet.teleportId })
+38 -24
View File
@@ -1,3 +1,5 @@
const sleep = require('../util/sleep');
function selfcare (context) {
const bot = context.bot;
const config = context.config;
@@ -17,8 +19,6 @@ function selfcare (context) {
let register = false;
let positionCount = 0;
bot.vanished = true
// You now have the tag: &8[&bPrefix&8: &3~&8]
// You no longer have a tag
bot.on('systemChat', (message) => {
const stringMessage = bot.getMessageAsPrismarine(message)?.toString();
if (options.isSavage) {
@@ -32,17 +32,8 @@ function selfcare (context) {
else if (stringMessage === "You're already logged in!") register = false;
else if (stringMessage === "Successful login!") register = false;
/*
You're already logged in!
Please, register to the server with the command: /register <password> <ConfirmPassword>
Please, login with the command: /login <password>
Successfully registered!
Successful login!
You already have registered this username!
*/
} else if (options.isKaboom) {
// const stringMessage = bot.getMessageAsPrismarine(message)?.toString();
if (stringMessage === "Successfully enabled CommandSpy") commandSpy = true;
else if (stringMessage === "Successfully enabled CommandSpy.") commandSpy = true;
else if (stringMessage === "Successfully disabled CommandSpy") commandSpy = false;
@@ -96,31 +87,54 @@ You already have registered this username!
}
}, 1000)
})
bot.on("packet.teams", (data) => {
/*
bot.on("packet.teams", async (data) => {
if (options.isSavage || options.isCreayun) return;
try {
/*
if (data.team !== "FNFBoyfriendBot") {
bot.chat.command(`minecraft:team add FNFBoyfriendBot`);
// console.log(data);
// bot.chat.command('minecraft:team add FNFBoyfriendBot');
// if (data.team === "FNFBoyfriendBot") return;
if (data.team === "FNFBoyfriendBot" && data.mode === 1) {
bot.core.run("minecraft:team add FNFBoyfriendBot");
}
if (data.mode > 1 && !data.team === "FNFBoyfriendBot") {
bot.chat.command(`minecraft:team add FNFBoyfriendBot`);
for (const eachPlayer of data?.players) {
if (eachPlayer !== bot.options.username) {
bot.core.run("minecraft:team empty FNFBoyfriendBot");
await sleep(100);
bot.core.run("minecraft:team join FNFBoyfriendBot");
}
}
if (data.team === "FNFBoyfriendBot") {
console.log(data);
}
*/
} catch (e) {
console.log(e.stack)
}
})
})*/
/*
{
team: 'FNFBoyfriendBot',
mode: 3,
name: undefined,
friendlyFire: undefined,
nameTagVisibility: undefined,
collisionRule: undefined,
formatting: undefined,
prefix: undefined,
suffix: undefined,
players: [ 'Parker2991' ]
}
*/
let timer;
bot.on('packet.login', (packet) => {
bot.on('packet.login', async (packet) => {
entityId = packet.entityId;
gameMode = packet.gameMode;
clientLock = packet.gameMode;
/* if (bot.options.isKaboom) {
bot.core.run('minecraft:team add FNFBoyfriendBot');
await sleep(100);
bot.core.run('minecraft:team join FNFBoyfriendBot');
}*/
timer = setInterval(() => {
if (bot.options.isSavage && !bot.options.isKaboom && !bot.options.isCreayun) {
if (login) bot.chat.command('login amogusissus');
+4 -4
View File
@@ -9,9 +9,9 @@ module.exports = (context) => {
})
const tab_completeH = (packet) => {
bot._client.removeListener('tab_complete', tab_completeH)
resolve(packet.matches)
}
bot._client.once('tab_complete', tab_completeH)
})
resolve(packet.matches)
}
bot._client.once('tab_complete', tab_completeH)
})
}
}
+52
View File
@@ -0,0 +1,52 @@
const sleep = require('../util/sleep');
module.exports = (context) => {
const bot = context.bot;
const options = context.options;
const config = context.config;
bot.on("packet.login", async () => {
if (options.isKaboom) {
await sleep(100);
bot.chat.command(`minecraft:team add ${config.team.name}`);
await sleep(100);
bot.core.run(`minecraft:team join ${config.team.name} @a[name="${bot.options.username}"]`);
}
})
bot.on("packet.teams", async (data) => {
if (options.isSavage || options.isCreayun) return;
try {
if (data.team === config.team.name) {
// console.log(data);
data?.players?.map(async (player) => {
if (player !== bot.options.username) {
await sleep(100);
bot.core.run(`minecraft:team empty ${config.team.name}`);
await sleep(100);
bot.core.run(`minecraft:team join ${config.team.name} @a[name="${bot.options.username}"]`);
// this removes players who are not the bot
}
});
if (data.mode == 1) {
// this is checking if the team has been deleted
bot.core.run(`minecraft:team add ${config.team.name}`);
await sleep(100);
bot.core.run(`minecraft:team join ${config.team.name} @a[name="${bot.options.username}"]`);
} if (data.name !== JSON.stringify(config.team.displayName)) {
// this checks if the team displayName matches the one set in the config
bot.core.run(`minecraft:team modify ${config.team.name} displayName ${JSON.stringify(config.team.displayName)}`);
} if (data.prefix !== JSON.stringify(config.team.prefix)) {
// this checks if the team prefix matches the one set in the config
bot.core.run(`minecraft:team modify ${config.team.name} prefix ${JSON.stringify(config.team.prefix)}`);
} if (data.suffix !== JSON.stringify(config.team.suffix)) {
// this checks if the team suffix matches the one set in the config
bot.core.run(`minecraft:team modify ${config.team.name} suffix ${JSON.stringify(config.team.suffix)}`)
}
}
} catch (e) {
console.log(e.stack)
}
})
}