change file names to upper camel case (suggested by chayapak)

This commit is contained in:
Parker2991
2026-01-08 07:19:51 -06:00
parent 27a6b07845
commit c059edeb4e
34 changed files with 152 additions and 102 deletions
+4 -3
View File
@@ -1,11 +1,12 @@
import mc from "minecraft-protocol";
import FNFBoyfriendBot from "./FNFBoyfriendBot";
export class createBot extends FNFBoyfriendBot {
constructor (options: any, config: any) {
export class Bot extends FNFBoyfriendBot {
constructor (options: any, config: any, rl: any) {
super(options, config);
const bot = this;
bot?.console?.interface(rl)
bot.on("init_client", (client: any) => {
client?.on('packet', (data: any, meta: any) => {
bot.emit("packet", data, meta);
@@ -30,4 +31,4 @@ export class createBot extends FNFBoyfriendBot {
bot.bots = options.bots ?? [bot]
return bot;
}
}
}
+7 -30
View File
@@ -1,29 +1,16 @@
import { EventEmitter } from 'events';
import optionss from './options';
import { chat } from './modules/chat';
import { commandHandler } from './modules/commandHandler';
import { Console } from './modules/console';
import { memUsage } from './modules/memUsage';
import { players } from './modules/players';
import { registry } from './modules/registry';
import { selfcare } from './modules/selfcare';
import { tabComplete } from './modules/tabComplete';
import { position } from './modules/position';
import { core } from './modules/core';
import { reconnect } from './modules/reconnect';
import { commandManager } from './modules/commandManager';
import { sign } from './modules/sign';
import optionss from './Options';
import { LoadModules } from './util/LoadModules';
export default class FNFBoyfriendBot extends EventEmitter {
public _client: any
public _client: any;
public bots: any;
public chat: any;
public commandManager: any;
public core: any;
public console: any;
public entityId: number;
public modules: any;
public modules: [];
public options: any;
public players: any;
public position: any;
@@ -31,6 +18,8 @@ export default class FNFBoyfriendBot extends EventEmitter {
public registry: any;
public selfcare: any;
public tabcomplete: any;
public world: any;
constructor (options: any, config: any) {
super();
const defaultOptions = new optionss()
@@ -46,18 +35,6 @@ export default class FNFBoyfriendBot extends EventEmitter {
this.options = options;
new chat({ bot: this, config });
new commandManager({ bot: this, config })
new Console({ bot: this, config });
new players({ bot: this, config });
new registry({ bot: this, config });
new selfcare({ bot: this, config });
new tabComplete({ bot: this, config });
new memUsage({ bot: this, config });
new reconnect({ bot: this, config });
new position({ bot: this, config });
new core({ bot: this, config });
new commandHandler({ bot: this, config });
new sign({ bot: this, config })
LoadModules({ bot: this, config: config })
}
}
+7 -7
View File
@@ -1,9 +1,9 @@
import fs from "fs";
import path from "path"
import readline from 'readline';
import { createBot } from "./bot";
import { parseToml } from './util/parseToml';
import version from './resources/version.json';
import { Bot } from "./Bot";
import { ParseToml } from './util/ParseToml';
import version from './resources/Version.json';
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
@@ -18,12 +18,12 @@ if (process.argv[2] === "--debug"?.toLowerCase()) {
if (debugEnabled) console.log(`Starting FNFBoyfriendBot ${version.codename} ${version.version} Build: ${version.build}`)
else console.log('Starting FNFBoyfriendBot....');
const config = parseToml('./config.toml');
const config = ParseToml('./config.toml');
const bots = [];
for (const options of config.bots) {
let bot = new createBot(options, config);
let bot = new Bot(options, config, rl);
bots.push(bot);
bot.bots = bots;
bot.console.interface(rl)
}
// bot?.console?.interface(rl)
}
+3 -3
View File
@@ -1,12 +1,12 @@
import { usernameGen } from './util/usernameGen';
import { UsernameGen } from './util/UsernameGen';
export default class options {
public host: string = "localhost"
public port: number = 25565;
public username = usernameGen();
public username = UsernameGen();
public serverName: string = "localhost";
public hideErrors: boolean = true;
public scInterval: number = 1000;
public version: '1.21.8';
public reconnectDelay: number = 3000
}
}
+2 -2
View File
@@ -1,4 +1,4 @@
import translations from '../../resources/translations.json';
import translations from '../../resources/Translations.json';
export default function format (
bot: any,
@@ -35,4 +35,4 @@ export default function format (
bot.getMessageAsPrismarine(message)?.toAnsi()
]
return component;
}
}
+5 -5
View File
@@ -1,7 +1,7 @@
import convertNbtComponentToJson from "../util/convertNbtComponentToJson";
import convertNbtComponentToJson from "../util/ConvertNbtComponentToJson";
import loadPrismarineChat from 'prismarine-chat';
import kaboom from '../chatParsers/kaboom';
import chipmunkmod from '../chatParsers/chipmunkmod';
import kaboom from '../chatParsers/Kaboom';
import chipmunkmod from '../chatParsers/ChipmunkMod';
// taken from FNFBoyfriendBot v8.0.0
@@ -26,7 +26,7 @@ function parseChatType (chatTypes: any, type: any, sender: any, target: any, mes
return json
}
export class chat {
export default class Chat {
constructor (context: any) {
const bot = context.bot;
const config = context.config;
@@ -187,4 +187,4 @@ export class chat {
bot.core.run(`minecraft:tellraw ${selector} ` + JSON.stringify(message))
}
}
}
}
@@ -1,6 +1,6 @@
import { CommandSource } from '../command/CommandSource';
export class commandHandler {
export default class CommandHandler {
constructor (context: any) {
const bot = context.bot;
const config = context.config;
@@ -1,7 +1,7 @@
import { loadCommands } from '../util/loadCommands';
import { LoadCommands } from '../util/LoadCommands';
import { CommandError } from '../command/CommandError';
export class commandManager {
export default class commandManager {
constructor (context: any) {
const bot = context.bot;
const config = context.config;
@@ -78,6 +78,6 @@ export class commandManager {
},
}
loadCommands(bot, config);
LoadCommands(bot, config);
}
}
}
@@ -1,6 +1,6 @@
import translations from '../resources/translations.json';
import translations from '../resources/Translations.json';
import format from '../data/console/format';
export class Console {
export default class Console {
constructor (context: any) {
const bot = context.bot;
const config = context.config;
+6 -2
View File
@@ -1,6 +1,6 @@
// i may or may not have used v4's command core for a base here
export class core {
export default class Core {
constructor (context: any) {
const bot = context.bot;
const config = context.config;
@@ -32,6 +32,10 @@ export class core {
bot.core.refill()
},
commandBlockCoords: [],
needsFilling: false,
currentBlock () {
const relativePosition = bot.core.currentBlockRelative
const corePosition = bot.core.position
@@ -76,4 +80,4 @@ export class core {
bot.core.move(bot.position)
})
}
}
}
@@ -1,7 +1,7 @@
import v8 from 'v8';
const { heap_size_limit } = v8.getHeapStatistics();
export class memUsage {
export default class MemUsage {
constructor (context: any) {
const bot = context.bot;
const config = context.config;
@@ -22,4 +22,4 @@ setInterval(() => {
console.log(`Process mem: ${Math.floor(rss / mbDivide)} MB / ${Math.floor(heap_size_limit) / mbDivide} MB`);
console.log(`OS mem: ${osMemUsed} MB / ${Math.floor(totalmem() / mbDivide)} MB`)
}, 1000)
*/
*/
@@ -1,8 +1,8 @@
const convertNbtComponentToJson = require("../util/convertNbtComponentToJson");
const entityUUID = require('../util/entityUUID');
const convertNbtComponentToJson = require("../util/ConvertNbtComponentToJson");
const entityUUID = require('../util/EntityUUID');
// taken from FNFBoyfriendBot v8.0.0
export class players {
export default class Players {
constructor(context: any) {
const bot = context.bot;
bot.players = [];
@@ -98,4 +98,4 @@ export class players {
bot.on("end", () => (bot.players = []));
}
}
}
@@ -1,4 +1,4 @@
export class position {
export default class Position {
constructor (context: any) {
const bot = context.bot;
@@ -17,4 +17,4 @@ export class position {
bot.on('end', () => bot.position = null);
}
}
}
@@ -1,6 +1,6 @@
import mc from 'minecraft-protocol';
export class reconnect {
export default class Reconnect {
constructor (context: any) {
const bot = context.bot;
const config = context.config;
@@ -9,6 +9,9 @@ export class reconnect {
let client;
bot.on('end', () => {
bot.world.dimensions = [];
bot.world.chunks = [];
bot.world.currentDimension = undefined;
setTimeout(() => {
client = options.client ?? mc.createClient(options);
bot._client = client;
@@ -1,7 +1,7 @@
import createRegistry from 'prismarine-registry';
import language from '../resources/language.json';
import language from '../resources/Language.json';
export class registry {
export default class Registry {
constructor(context: any) {
const bot = context.bot;
@@ -13,4 +13,4 @@ export class registry {
bot.registry.loadDimensionCodec(packet)
})
}
}
}
@@ -1,4 +1,4 @@
export class selfcare {
export default class Selfcare {
constructor (context: any) {
const bot = context.bot;
const config = context.config;
@@ -10,8 +10,8 @@ export class selfcare {
};
const entity = [
require('../selfcare/entity/permission'),
require('../selfcare/entity/gamemode')
require('../selfcare/entity/Permission'),
require('../selfcare/entity/GameMode')
];
for (const file of entity) file.default(bot, config);
@@ -29,4 +29,4 @@ export class selfcare {
if (timer) clearInterval(timer);
})
}
}
}
+4 -4
View File
@@ -1,6 +1,6 @@
const convertNbtToComponent = require('../util/convertNbtComponentToJson');
const convertNbtToComponent = require('../util/ConvertNbtComponentToJson');
export class sign {
export default class Sign {
constructor (context: any) {
const bot = context.bot;
const options = bot.options;
@@ -8,8 +8,8 @@ export class sign {
bot.on('packet.tile_entity_data', (packet: any) => {
const front = convertNbtToComponent(null, packet.nbtData.value.front_text);
const back = convertNbtToComponent(null, packet.nbtData.value.back_text);
console.log(front);
console.log(back);
//console.log(front);
//console.log(back);
});
bot.on("packet.error", (error: any) => console.error(error))
@@ -1,6 +1,6 @@
// taken from FNFBoyfriendBot v8.0.0
export class tabComplete {
export default class TabComplete {
constructor(context: any) {
const bot = context.bot;
// let aaa cook
@@ -19,4 +19,4 @@ export class tabComplete {
});
};
}
}
}
@@ -1,4 +1,4 @@
export default function gamemode (bot: any, config: any) {
export default function GameMode (bot: any, config: any) {
bot.on('packet.game_state_change', (packet: any) => {
if (packet.reason === "change_game_mode") {
bot.selfcare.gamemode = packet.gameMode
@@ -6,4 +6,4 @@ export default function gamemode (bot: any, config: any) {
bot._client.write('client_command', { action: 0 })
}
})
}
}
@@ -1,4 +1,4 @@
export default function permission (bot: any, config: any) {
export default function Permission (bot: any, config: any) {
bot.on("packet.entity_status", (packet: any) => {
if (
packet.entityId !== bot.entityId
@@ -9,4 +9,4 @@ export default function permission (bot: any, config: any) {
) return
bot.selfcare.permission = packet.entityStatus - 24;
})
}
}
@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';
export async function loadCommands (bot: any, config: any) {
export async function LoadCommands (bot: any, config: any) {
const foldersPath = path.join(__dirname, "../commands");
const commandFolders = fs.readdirSync(foldersPath);
for (const folder of commandFolders) {
@@ -17,23 +17,10 @@ export async function loadCommands (bot: any, config: any) {
const command = new commands.default();
bot.commandManager.register(command, filename, folderName);
bot.commandManager.list.push(command);
//console.log(command)
//console.log(new commands.default())
//const command = new commands.default();
//console.log(command)
// bot.commandManager.register(command, filename, folderName);
// console.log(command.default)
// console.log(path.basename(path.dirname(filePath)));
// console.log(path.dirname(commandFolders))
// console.log(path.dirname(filename).split(filePath))
// console.log(path.dirname(filename))
// console.log(filename);
// path.dirname(filename).split(path.sep).pop()
// console.log(commandsPath)
}
} catch (error) {
console.error("Failed to load command", filename, ":", error);
}
}
}
}
}
+23
View File
@@ -0,0 +1,23 @@
import fs from 'fs';
import path from 'path';
export async function LoadModules (context: any) {
const bot = context.bot;
const config = context.config
for (
const filename of fs.readdirSync(
path.join(__dirname, '../modules')
)
) {
try {
if (filename.endsWith('.js')) {
const module = await import(path.join(__dirname, '../modules/', filename));
new module.default({ bot, config });
//bot.modules.push(module)
}
} catch (e) {
console.error(`Failed to load module: ${filename} due to the following Error\n`);
console.error(e)
}
}
}
@@ -1,7 +1,7 @@
import { readFileSync } from 'fs';
import { join } from 'path';
import toml from 'smol-toml';
export function parseToml (path: any) {
export function ParseToml (path: any) {
try {
const file = readFileSync(join(path), 'utf8');
const parse = toml.parse(file)
@@ -1,4 +1,4 @@
export function usernameGen() {
export function UsernameGen() {
const characters =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
let username = "";
+52
View File
@@ -7,9 +7,12 @@
"dependencies": {
"minecraft-protocol": "^1.62.0",
"prismarine-chat": "^1.12.0",
"prismarine-chunk": "^1.39.0",
"prismarine-registry": "^1.11.0",
"prismarine-world": "^3.6.3",
"smol-toml": "^1.5.2",
"socket.io-client": "^4.8.1",
"vec3": "^0.1.10",
"yaml": "^2.8.2"
},
"devDependencies": {
@@ -624,6 +627,25 @@
"prismarine-registry": "^1.4.0"
}
},
"node_modules/prismarine-chunk": {
"version": "1.39.0",
"resolved": "https://registry.npmjs.org/prismarine-chunk/-/prismarine-chunk-1.39.0.tgz",
"integrity": "sha512-RJHACPV2T3ABGlj0+q/ZUDBLPcslWTIa12lWyE2jJb/svqpTBx8S/K6VjHxhyJ488L9ZWdEmOAr+CHMZJtwWHw==",
"license": "MIT",
"dependencies": {
"prismarine-biome": "^1.2.0",
"prismarine-block": "^1.14.1",
"prismarine-nbt": "^2.2.1",
"prismarine-registry": "^1.1.0",
"smart-buffer": "^4.1.0",
"uint4": "^0.1.2",
"vec3": "^0.1.3",
"xxhash-wasm": "^0.4.2"
},
"engines": {
"node": ">=14"
}
},
"node_modules/prismarine-item": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/prismarine-item/-/prismarine-item-1.17.0.tgz",
@@ -665,6 +687,18 @@
"prismarine-nbt": "^2.0.0"
}
},
"node_modules/prismarine-world": {
"version": "3.6.3",
"resolved": "https://registry.npmjs.org/prismarine-world/-/prismarine-world-3.6.3.tgz",
"integrity": "sha512-zqdqPEYCDHzqi6hglJldEO63bOROXpbZeIdxBmoQq7o04Lf81t016LU6stFHo3E+bmp5+xU74eDFdOvzYNABkA==",
"license": "MIT",
"dependencies": {
"vec3": "^0.1.7"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
@@ -884,6 +918,12 @@
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"license": "MIT"
},
"node_modules/uint4": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/uint4/-/uint4-0.1.2.tgz",
"integrity": "sha512-lhEx78gdTwFWG+mt6cWAZD/R6qrIj0TTBeH5xwyuDJyswLNlGe+KVlUPQ6+mx5Ld332pS0AMUTo9hIly7YsWxQ==",
"license": "MIT"
},
"node_modules/undici-types": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
@@ -917,6 +957,12 @@
"macaddress": "^0.5.1"
}
},
"node_modules/vec3": {
"version": "0.1.10",
"resolved": "https://registry.npmjs.org/vec3/-/vec3-0.1.10.tgz",
"integrity": "sha512-Sr1U3mYtMqCOonGd3LAN9iqy0qF6C+Gjil92awyK/i2OwiUo9bm7PnLgFpafymun50mOjnDcg4ToTgRssrlTcw==",
"license": "BSD"
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
@@ -962,6 +1008,12 @@
"node": ">=0.4.0"
}
},
"node_modules/xxhash-wasm": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/xxhash-wasm/-/xxhash-wasm-0.4.2.tgz",
"integrity": "sha512-/eyHVRJQCirEkSZ1agRSCwriMhwlyUcFkXD5TPVSLP+IPzjsqMVzZwdoczLp1SoQU0R3dxz1RpIK+4YNQbCVOA==",
"license": "MIT"
},
"node_modules/yaml": {
"version": "2.8.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz",
+3
View File
@@ -2,9 +2,12 @@
"dependencies": {
"minecraft-protocol": "^1.62.0",
"prismarine-chat": "^1.12.0",
"prismarine-chunk": "^1.39.0",
"prismarine-registry": "^1.11.0",
"prismarine-world": "^3.6.3",
"smol-toml": "^1.5.2",
"socket.io-client": "^4.8.1",
"vec3": "^0.1.10",
"yaml": "^2.8.2"
},
"devDependencies": {