From 2302716a8d1e2c454eb1ab31e2e514c4464c0d47 Mon Sep 17 00:00:00 2001 From: m_c_player Date: Sat, 26 Oct 2024 15:29:37 -0400 Subject: [PATCH] Upload files to "/" --- config.json | 8 +++ index.js | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 config.json create mode 100644 index.js diff --git a/config.json b/config.json new file mode 100644 index 0000000..e9e42ae --- /dev/null +++ b/config.json @@ -0,0 +1,8 @@ +{ + "core": { + "width": 3, + "height": 3, + "depth": 3, + "y": -35 + } +} \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..b461841 --- /dev/null +++ b/index.js @@ -0,0 +1,186 @@ +const mineflayer = require('mineflayer'); +const { CoreClass } = require('./util/core.js'); + +function random(length) { + let result = ''; + const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + const charactersLength = characters.length; + let counter = 0; + while (counter < length) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + counter += 1; + } + return result; +}; + +// Create the bot +const bot = mineflayer.createBot({ + host: 'chipmunk.land', // Your server IP + username: 'ibot', // Bot username, should be unique + version: '1.19.4' // version 1.19.4 for normal chat logging 1.19.2 for custom chat logging +}); + +// Define hash functions +function createHash(hashType) { + switch (hashType) { + case "trusted": + bot.trustedHash = random(Math.floor(Math.random() * (15 - 10) + 10)); + console.log(`\x1b[107m\x1b[30mTrusted Hash: ${bot.trustedHash}\x1b[0m`); + break; + + case "owner": + bot.ownerHash = random(Math.floor(Math.random() * (25 - 20) + 20)); + console.log(`\x1b[107m\x1b[30mOwner Hash: ${bot.ownerHash}\x1b[0m`); + break; + } +} + +// Call the hash functions +createHash("trusted"); +createHash("owner"); + +// Define the prefix +let prefix = "!"; + +// Log when the bot successfully connects +bot._client.on('login', () => { + console.log('/nick &4&lIbot'); + + // Init bot core + setTimeout(() => { + bot.pos = bot.entity.position; + bot.core = new CoreClass(bot); + setTimeout(() => { + bot.core.tellraw('Ibot: Core Ready'); + + // Delay execution of /op command to ensure bot is ready + setTimeout(() => { + bot.chat('/op ibot'); // Attempt to OP the bot + console.log('Executed /op ibot'); + }, 100); // Execute after 0.1 seconds + }, 350); + }, 150); +}); + +// Listen for chat messages +bot.on('messagestr', (message, username) => { + if (username === bot.username) return; + if (message.startsWith('Command set:') || message.startsWith('[ IBot ] > ')) return; + const args = message.split(" ").slice(1); + + // Log received message + console.log(`Received message from ${username}: ${message}`); + + // Respond to specific commands + if (message === `${prefix}help`) { + bot.core.tellraw(`Result:\n&f&lPublic &1Trusted &4&lOwner\n&f&l&r ${prefix}help ${prefix}tp ${prefix}credits ${prefix}refill &1${prefix}auth &4&l${prefix}cloop &7&l${prefix}prefix\n`); + } + if (message === `${prefix}tp`) { + bot.core.run('tp @e[type=player] itzrealviktor'); + } + if (message === `${prefix}credits`) { + bot.core.tellraw('&9By itzrealviktor&r\n'); + } + if (message === `${prefix}prefix`) { + bot.core.tellraw('/rank &7 {Prefix:!help}&r\n'); + } + if (message === `${prefix}auth`) { + bot.core.tellraw('&cSorry you don\'t have permission to use !auth&r\n'); + } + if (message === `${prefix}cloop`) { + bot.core.tellraw('&cSorry you don\'t have permission to use !cloop&r\n'); + } + // Respond to the !tp command + if (message === '!prefix') { + bot.chat('/rank &1Bot'); + setTimeout(() => bot.chat('/rank &7{Prefix:!help} '), 100); + setTimeout(() => bot.chat(''), 200); + setTimeout(() => bot.chat(''), 300); + setTimeout(() => bot.chat(''), 400); + setTimeout(() => bot.chat(''), 500); + } + if (message === `${prefix}refill`) { + bot.pos = bot.entity.position; + bot.core.refill(); + } + + // Respond to the !tp command + if (message === '!hbot') { + bot.chat('/rank &1Bot'); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 100); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 200); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 300); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 400); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 500); + } + + // Respond to the !tp command + if (message === '!hbot') { + bot.chat('/rank &1Bot'); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 100); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 200); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 300); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 400); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 500); + } + + // Respond to the !tp command + if (message === '!hbot') { + bot.chat('/rank &1Bot'); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 100); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 200); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 300); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 400); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 500); + } + + // Respond to the !tp command + if (message === '!hbot') { + bot.chat('/rank &1Bot'); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 100); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 200); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 300); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 400); + setTimeout(() => bot.chat('/sudo ** say hbot:orbit'), 500); + } + if (message === `${prefix}refill`) { + bot.pos = bot.entity.position; + bot.core.refill(); + } + + if (message === `${prefix}hashtest`) { + if (args == "" + bot.trustedHash + "") { + bot.core.tellraw("&7test"); + createHash("trusted"); + } else { + bot.core.tellraw("Invalid trusted hash."); + } + } +}) + +// Log errors +bot.on('error', (err) => { + console.error('Error:', err); +}); + +// Log when the bot disconnects +bot.on('end', () => { + console.log('Bot has disconnected.'); +}); + +// Log server messages +bot.on('message', (jsonMsg) => { + const msg = jsonMsg.toString(); + console.log(`Server Message: ${msg}`); +}); + +// Set up console input handling +const { stdin: input, stdout: output } = require('node:process'); +const readline = require('readline'); +const rl = readline.createInterface({ input, output }); + +rl.on('line', (input) => { + if (bot) { + bot.core.tellraw(`&8[&4&lIBot Console&8] &f${input}`); + } +});