mirror of
https://code.chipmunk.land/Parker2991/NitoriBot/
synced 2026-12-04 16:15:43 -05:00
initial commit, v0.5
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# you know the usual stuff that needs to be ignored when committing
|
||||
|
||||
node_modules
|
||||
|
||||
config.yml
|
||||
|
||||
src/modules/exploits.js
|
||||
|
||||
.git
|
||||
@@ -0,0 +1,66 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
enabled: true,
|
||||
name: "command manager",
|
||||
type: "commands"
|
||||
},
|
||||
inject (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
bot.commandManager = {
|
||||
commands: {},
|
||||
commandlist: [],
|
||||
execute (commandName, args) {
|
||||
if (!command || !command.execute) console.log('unknown command');
|
||||
const command = this.getCommand(commandName).toLowerCase();
|
||||
|
||||
try {
|
||||
return command.execute({ bot, config, arguments: args} );
|
||||
} catch (e) {
|
||||
console.error(e.stack);
|
||||
}
|
||||
},
|
||||
executeString (command) {
|
||||
//const [commandName, ...args] = command.split(' ')
|
||||
return this.execute(command, args.split(' '))
|
||||
},
|
||||
|
||||
register (command) {
|
||||
this.commands[command.data.name] = command
|
||||
/*if (command.data.aliases) {
|
||||
command.data.aliases.map((a) => (this.commands[a] = command));
|
||||
}*/
|
||||
},
|
||||
|
||||
getCommand (name) {
|
||||
return this.commands[name];
|
||||
}
|
||||
}
|
||||
/* bot.commandManager = {};
|
||||
|
||||
bot.commandManager.commands = {};
|
||||
|
||||
bot.commandManager.register = (command) => {
|
||||
this.commands[command.data.name] = command
|
||||
if (command.data.aliases) {
|
||||
command.data.aliases.map((a) => (this.commands[a] = command));
|
||||
}
|
||||
}
|
||||
|
||||
bot.commandManager.commandlist = [];
|
||||
*/
|
||||
commandlist = [];
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, '../commands'))) {
|
||||
try {
|
||||
const command = require(path.join(__dirname, '../commands', filename));
|
||||
bot.commandManager.register(command)
|
||||
bot.commandManager.commandlist.push(command)
|
||||
} catch (error) {
|
||||
console.error('Failed to load command', filename, ':', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+1128
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"discord.js": "^14.16.3",
|
||||
"js-yaml": "^4.1.0",
|
||||
"minecraft-protocol": "^1.51.0",
|
||||
"prismarine-chat": "^1.10.1",
|
||||
"prismarine-nbt": "^2.7.0",
|
||||
"prismarine-registry": "^1.10.0"
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
const mc = require('minecraft-protocol');
|
||||
const { EventEmitter } = require('events');
|
||||
EventEmitter.defaultMaxListeners = 5e6;
|
||||
const util = require('util');
|
||||
const ChatMessage = require('prismarine-chat');
|
||||
function createBot(context) {
|
||||
const bot = new EventEmitter();
|
||||
const config = context.config;
|
||||
bot.server = {
|
||||
// Set some default values in options
|
||||
host: config.server.host ??= 'localhost',
|
||||
username: config.server.username ??= 'Player',
|
||||
hideErrors: config.server.hideErrors ??= true, // HACK: Hide errors by default as a lazy fix to console being spammed with them
|
||||
};
|
||||
|
||||
bot.server = config.server;
|
||||
// Create our client object, put it on the bot, and register some events
|
||||
bot.on('init_client', client => {
|
||||
client.on('packet', (data, meta) => {
|
||||
bot.emit('packet', data, meta)
|
||||
bot.emit('packet.' + meta.name, data);
|
||||
})
|
||||
|
||||
client.on('login', (data) => {
|
||||
bot.uuid = client.uuid
|
||||
bot.username = client.username
|
||||
})
|
||||
|
||||
client.on('disconnect', data => {
|
||||
bot.emit("disconnect", data);
|
||||
})
|
||||
|
||||
client.on('end', reason => {
|
||||
bot.emit('end', reason);
|
||||
})
|
||||
|
||||
client.on('error', error => {
|
||||
endCount++
|
||||
bot.emit('error', error);
|
||||
})
|
||||
|
||||
client.on("keep_alive", ({ keepAliveId }) => {
|
||||
bot.emit("keep_alive", { keepAliveId })
|
||||
})
|
||||
|
||||
client.on('kick_disconnect', (data) => {
|
||||
bot.emit("kick_disconnect", data.reason)
|
||||
})
|
||||
|
||||
process.on("uncaughtException", (e) => {
|
||||
// console?.warn(e.stack)
|
||||
});
|
||||
})
|
||||
|
||||
const client = mc.createClient(bot.server)
|
||||
bot._client = client
|
||||
bot.emit('init_client', client)
|
||||
// bot.bots = options.bots ?? [bot]
|
||||
return bot;
|
||||
}
|
||||
module.exports = createBot;
|
||||
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
data: {
|
||||
name: "core",
|
||||
enabled: true,
|
||||
aliases: [
|
||||
"cb",
|
||||
"corerun"
|
||||
]
|
||||
},
|
||||
execute (context) {
|
||||
const bot = context.bot;
|
||||
const args = context.arguments;
|
||||
bot.core.run(args.join(' '));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
data: {
|
||||
name: "echo",
|
||||
enabled: true,
|
||||
aliases: [
|
||||
"say",
|
||||
"botsay"
|
||||
]
|
||||
},
|
||||
execute (context) {
|
||||
const bot = context.bot;
|
||||
const args = context.arguments;
|
||||
bot.chat(args.join(' '));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
bots:
|
||||
chomens:
|
||||
prefix: "*"
|
||||
keys:
|
||||
trusted: ""
|
||||
admin: ""
|
||||
|
||||
fnfboyfriendbot:
|
||||
prefix: "~"
|
||||
keys:
|
||||
trusted: ""
|
||||
admin: ""
|
||||
owner: ""
|
||||
|
||||
qbot:
|
||||
prefix: "]"
|
||||
key: ""
|
||||
|
||||
sbot:
|
||||
prefix: ":"
|
||||
key: ""
|
||||
|
||||
testbot:
|
||||
prefix: "-"
|
||||
token: ""
|
||||
|
||||
server:
|
||||
host: ""
|
||||
port: ""
|
||||
username: ""
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
const fs = require('fs');
|
||||
const { load } = require('js-yaml');
|
||||
const path = require('path');
|
||||
|
||||
if (!fs.existsSync(path.join(__dirname, "../config.yml"))) {
|
||||
console.warn("Config not found creating config from the default config");
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, "./data/default_config.yml"),
|
||||
path.join(__dirname, "../config.yml")
|
||||
)
|
||||
}
|
||||
|
||||
try {
|
||||
config = load(fs.readFileSync(path.join(__dirname, '../', 'config.yml')));
|
||||
} catch (e) {
|
||||
console.error("Failed to load the config look below for the error stack");
|
||||
console.error(e.stack);
|
||||
}
|
||||
|
||||
let bot = require('./bot.js')({ config });
|
||||
|
||||
require('./util/loadModules')(bot, config);
|
||||
@@ -0,0 +1,274 @@
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
enabled: true,
|
||||
name: "chat",
|
||||
type: "logging"
|
||||
},
|
||||
inject (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
|
||||
bot.on('packet.player_chat', (data) => {
|
||||
const unsigned = data.unsignedChatContent;
|
||||
try {
|
||||
switch (data.type) {
|
||||
case 1:
|
||||
|
||||
break;
|
||||
case 3:
|
||||
bot.emit('playerChat', [
|
||||
{
|
||||
translate: "[%s %s %s%s %s] ",
|
||||
color: "dark_gray",
|
||||
with: [
|
||||
{ text: 'Player Chat', color: 'dark_purple' },
|
||||
{ text: '|' },
|
||||
{ text: 'Packet Type', color: "aqua" },
|
||||
{ text: ':' },
|
||||
{ text: data.type, color: 'gold' },
|
||||
],
|
||||
},
|
||||
{ translate: "commands.message.display.outgoing",
|
||||
with: [
|
||||
JSON.parse(data.networkName).insertion,
|
||||
data.plainMessage
|
||||
],
|
||||
color: "gray",
|
||||
italic: true
|
||||
}
|
||||
])
|
||||
break
|
||||
case 2:
|
||||
bot.emit('playerChat', [
|
||||
{
|
||||
translate: "[%s %s %s%s %s] ",
|
||||
color: "dark_gray",
|
||||
with: [
|
||||
{ text: 'Player Chat', color: 'dark_purple' },
|
||||
{ text: '|' },
|
||||
{ text: 'Packet Type', color: "aqua" },
|
||||
{ text: ':' },
|
||||
{ text: data.type, color: 'gold' },
|
||||
],
|
||||
},
|
||||
{ translate: "commands.message.display.incoming",
|
||||
with: [
|
||||
JSON.parse(data.networkName).insertion,
|
||||
data.plainMessage
|
||||
],
|
||||
color: "gray",
|
||||
italic: true
|
||||
}
|
||||
])
|
||||
break
|
||||
case 4:
|
||||
bot.emit('playerChat', [
|
||||
{
|
||||
translate: "[%s %s %s%s %s] ",
|
||||
color: "dark_gray",
|
||||
with: [
|
||||
{ text: 'Player Chat', color: 'dark_purple' },
|
||||
{ text: '|' },
|
||||
{ text: 'Packet Type', color: "aqua" },
|
||||
{ text: ':' },
|
||||
{ text: data.type, color: 'gold' },
|
||||
],
|
||||
},
|
||||
JSON.parse(unsigned)
|
||||
])
|
||||
break;
|
||||
case 5:
|
||||
bot.emit('playerChat', [
|
||||
{
|
||||
translate: "[%s %s %s%s %s] ",
|
||||
color: "dark_gray",
|
||||
with: [
|
||||
{ text: 'Player Chat', color: 'dark_purple' },
|
||||
{ text: '|' },
|
||||
{ text: 'Packet Type', color: "aqua" },
|
||||
{ text: ':' },
|
||||
{ text: data.type, color: 'gold' },
|
||||
],
|
||||
},
|
||||
{ translate: "chat.type.announcement",
|
||||
with: [
|
||||
JSON.parse(data.networkName).insertion,
|
||||
data.plainMessage
|
||||
]
|
||||
}
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
console.warn('invalid chat type');
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e.stack);
|
||||
}
|
||||
})
|
||||
|
||||
bot.on('packet.profileless_chat', (packet) => {
|
||||
const message = JSON.parse(packet.message)
|
||||
const sender = JSON.parse(packet.name)
|
||||
switch (packet.type) {
|
||||
case 1:
|
||||
bot?.emit('profilelessChat', [
|
||||
{
|
||||
translate: "[%s %s %s%s %s] ",
|
||||
color: "dark_gray",
|
||||
with: [
|
||||
{ text: 'Profileless Chat', color: 'dark_aqua' },
|
||||
{ text: '|' },
|
||||
{ text: 'Packet Type', color: "aqua" },
|
||||
{ text: ':' },
|
||||
{ text: packet.type, color: 'gold' },
|
||||
],
|
||||
},
|
||||
{ translate: "chat.type.emote",
|
||||
with: [
|
||||
sender,
|
||||
message
|
||||
]
|
||||
}
|
||||
])
|
||||
break
|
||||
case 2:
|
||||
bot.emit('profilelessChat', [
|
||||
{
|
||||
translate: "[%s %s %s%s %s] ",
|
||||
color: "dark_gray",
|
||||
with: [
|
||||
{ text: 'Profileless Chat', color: 'dark_aqua' },
|
||||
{ text: '|' },
|
||||
{ text: 'Packet Type', color: "aqua" },
|
||||
{ text: ':' },
|
||||
{ text: packet.type, color: 'gold' },
|
||||
],
|
||||
},
|
||||
{ translate: "commands.message.display.incoming",
|
||||
with: [
|
||||
sender,
|
||||
message
|
||||
],
|
||||
color: "gray",
|
||||
italic: true
|
||||
}
|
||||
])
|
||||
break
|
||||
case 3:
|
||||
bot.emit('profilelessChat', [
|
||||
{
|
||||
translate: "[%s %s %s%s %s] ",
|
||||
color: "dark_gray",
|
||||
with: [
|
||||
{ text: 'Profileless Chat', color: 'dark_aqua' },
|
||||
{ text: '|' },
|
||||
{ text: 'Packet Type', color: "aqua" },
|
||||
{ text: ':' },
|
||||
{ text: packet.type, color: 'gold' },
|
||||
],
|
||||
},
|
||||
{ translate: "commands.message.display.outgoing",
|
||||
with: [
|
||||
sender,
|
||||
message
|
||||
],
|
||||
color: "gray",
|
||||
italic: true
|
||||
}
|
||||
])
|
||||
break
|
||||
case 4:
|
||||
bot.emit('profilelessChat', [
|
||||
{
|
||||
translate: "[%s %s %s%s %s] ",
|
||||
color: "dark_gray",
|
||||
with: [
|
||||
{ text: 'Profileless Chat', color: 'dark_aqua' },
|
||||
{ text: '|' },
|
||||
{ text: 'Packet Type', color: "aqua" },
|
||||
{ text: ':' },
|
||||
{ text: packet.type, color: 'gold' },
|
||||
],
|
||||
},
|
||||
message
|
||||
])
|
||||
break
|
||||
case 5:
|
||||
bot.emit('profilelessChat', [
|
||||
{
|
||||
translate: "[%s %s %s%s %s] ",
|
||||
color: "dark_gray",
|
||||
with: [
|
||||
{ text: 'Profileless Chat', color: 'dark_aqua' },
|
||||
{ text: '|' },
|
||||
{ text: 'Packet Type', color: "aqua" },
|
||||
{ text: ':' },
|
||||
{ text: packet.type, color: 'gold' },
|
||||
],
|
||||
},
|
||||
{ translate: 'chat.type.announcement',
|
||||
with: [
|
||||
sender,
|
||||
message
|
||||
]
|
||||
}
|
||||
])
|
||||
break
|
||||
}
|
||||
});
|
||||
|
||||
bot.on('packet.system_chat', packet => {
|
||||
const message = JSON.parse(packet.content)
|
||||
|
||||
if (message.translate === 'advMode.setCommand.success') return // Ignores command set message
|
||||
|
||||
if (message.translate === 'multiplayer.message_not_delivered') return;
|
||||
|
||||
bot.emit('system_chat', { message, actionbar: packet.isActionBar })
|
||||
|
||||
if (packet.isActionBar) {
|
||||
return
|
||||
}
|
||||
|
||||
bot.emit('systemChat', [
|
||||
{
|
||||
translate: "[%s] ",
|
||||
color: "dark_gray",
|
||||
with: [
|
||||
{ text: 'System Chat', color: 'dark_blue' },
|
||||
],
|
||||
},
|
||||
message
|
||||
])
|
||||
});
|
||||
|
||||
bot.chat = (args) => {
|
||||
if (args.startsWith('/')) {
|
||||
bot._client.write('chat_command', {
|
||||
command: args?.substring(1).substring(0, 256),
|
||||
timestamp: BigInt(Date.now()),
|
||||
salt: 0n,
|
||||
argumentSignatures: [],
|
||||
signedPreview: false,
|
||||
messageCount: 0,
|
||||
acknowledged: Buffer.alloc(3),
|
||||
previousMessages: []
|
||||
})
|
||||
return;
|
||||
}
|
||||
const acc = 0;
|
||||
const bitset = Buffer.allocUnsafe(3);
|
||||
bitset[0] = acc & 0xFF;
|
||||
bitset[1] = (acc >> 8) & 0xFF;
|
||||
bitset[2] = (acc >> 16) & 0xFF;
|
||||
bot._client.write('chat_message', {
|
||||
message: args?.substring(0, 256),
|
||||
timestamp: BigInt(Date.now()),
|
||||
salt: 0n,
|
||||
offset: 0,
|
||||
acknowledged: bitset
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
const mcData = require('minecraft-data')('1.20.2');
|
||||
const nbt = require('prismarine-nbt');
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
enabled: true,
|
||||
name: "command core",
|
||||
type: "commands"
|
||||
},
|
||||
inject (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
bot.core = {
|
||||
area: {
|
||||
start: config.core?.area.start ?? { x: 0, y: 0, z: 0 },
|
||||
end: config.core?.area.end ?? { x: 15, y: 0, z: 15 }
|
||||
},
|
||||
|
||||
position: null,
|
||||
|
||||
itemPosition: null,
|
||||
|
||||
currentBlockRelative: { x: 0, y: 0, z: 0 },
|
||||
|
||||
usePlacedCommandBlock: false,
|
||||
|
||||
chatRefill () {
|
||||
const pos = bot.core.position
|
||||
const { start, end } = bot.core.area
|
||||
|
||||
if (!pos) return
|
||||
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.chat(`${command}`)
|
||||
},
|
||||
|
||||
itemRefill () {
|
||||
const pos = bot.core.position;
|
||||
const { start, end } = bot.core.area;
|
||||
const itemPosition = bot.core.itemPosition;
|
||||
|
||||
if (!pos) return;
|
||||
|
||||
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: itemPosition,
|
||||
command,
|
||||
flags: 5,
|
||||
mode: 1
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
move (pos = bot.position) {
|
||||
bot.core.position = {
|
||||
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();
|
||||
}
|
||||
},
|
||||
|
||||
currentBlock () {
|
||||
const relativePosition = bot.core.currentBlockRelative
|
||||
const corePosition = bot.core.position
|
||||
if (!corePosition) return null
|
||||
return { x: relativePosition.x + corePosition.x, y: relativePosition.y + corePosition.y, z: relativePosition.z + corePosition.z }
|
||||
},
|
||||
|
||||
incrementCurrentBlock () {
|
||||
const relativePosition = bot.core.currentBlockRelative
|
||||
const { start, end } = bot.core.area
|
||||
|
||||
relativePosition.x++
|
||||
|
||||
if (relativePosition.x > end.x) {
|
||||
relativePosition.x = start.x
|
||||
relativePosition.z++
|
||||
}
|
||||
|
||||
if (relativePosition.z > end.z) {
|
||||
relativePosition.z = start.z
|
||||
relativePosition.y++
|
||||
}
|
||||
|
||||
if (relativePosition.y > end.y) {
|
||||
relativePosition.x = start.x
|
||||
relativePosition.y = start.y
|
||||
relativePosition.z = start.z
|
||||
}
|
||||
},
|
||||
|
||||
run (command) {
|
||||
const location = bot.core.currentBlock();
|
||||
const itemPosition = bot.core.itemPosition;
|
||||
|
||||
if (!location) return;
|
||||
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();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
bot.on('move', () => {
|
||||
bot.core.move(bot.position)
|
||||
})
|
||||
|
||||
bot.on('packet.block_change', (data) => {
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
enabled: true,
|
||||
name: "command manager",
|
||||
type: "commands"
|
||||
},
|
||||
inject (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
bot.commandManager = {
|
||||
commands: {},
|
||||
commandlist: [],
|
||||
execute (commandName, args) {
|
||||
const command = bot.commandManager.getCommand(commandName)//.toLowerCase()
|
||||
|
||||
try {
|
||||
if (!command || !command.execute) console.error('unknown command');
|
||||
return command?.execute({ bot, config, arguments: args })
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
},
|
||||
|
||||
executeString (command) {
|
||||
const [commandName, ...args] = command.split(' ')
|
||||
return this.execute(commandName, args)
|
||||
},
|
||||
|
||||
register (command) {
|
||||
this.commands[command.data.name] = command
|
||||
if (command.data.aliases) {
|
||||
command.data.aliases.map((a) => (
|
||||
this.commands[a] = command
|
||||
))
|
||||
}
|
||||
},
|
||||
|
||||
getCommand (name) {
|
||||
return this.commands[name]
|
||||
},
|
||||
|
||||
getCommands () {
|
||||
return Object.values(this.commands)
|
||||
}
|
||||
}
|
||||
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, '../commands'))) {
|
||||
try {
|
||||
const command = require(path.join(__dirname, '../commands', filename))
|
||||
bot.commandManager.register(command);
|
||||
bot.commandManager.commandlist.push(command);
|
||||
} catch (error) {
|
||||
console.error('Failed to load command', filename, ':', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
const { fromNotch } = require('prismarine-chat')('1.20.2');
|
||||
const readline = require('readline');
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
});
|
||||
|
||||
const CommandSource = require('../util/command_source');
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
enabled: true,
|
||||
name: "console",
|
||||
type: "logging"
|
||||
},
|
||||
inject (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
rl.on('line', (args) => {
|
||||
if (args.startsWith(config.console.prefix)) {
|
||||
return bot.commandManager.executeString(args.substring(config.console.prefix.length));
|
||||
} else if (args.startsWith('')) {
|
||||
bot.commandManager.executeString(`echo ${args.substring(0)}`);
|
||||
}
|
||||
});
|
||||
|
||||
log = function (...args) {
|
||||
rl.output.write("\x1b[2K\r");
|
||||
console.log(args.toString());
|
||||
rl._refreshLine();
|
||||
}
|
||||
|
||||
bot.on('playerChat', (message) => {
|
||||
const ansi = fromNotch(message)?.toAnsi();
|
||||
log(ansi);
|
||||
});
|
||||
|
||||
bot.on('profilelessChat', (message) => {
|
||||
const ansi = fromNotch(message)?.toAnsi();
|
||||
log(ansi);
|
||||
});
|
||||
|
||||
bot.on('systemChat', (message) => {
|
||||
const ansi = fromNotch(message)?.toAnsi();
|
||||
log(ansi);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
module.exports = {
|
||||
data: {
|
||||
enabled: true,
|
||||
name: "position",
|
||||
type: "client"
|
||||
},
|
||||
inject (context) {
|
||||
const bot = context.bot;
|
||||
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 })
|
||||
|
||||
bot.emit('move')
|
||||
})
|
||||
|
||||
bot.on('end', () => { bot.position = null })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
const mc = require('minecraft-protocol');
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
enabled: true,
|
||||
name: "reconnect",
|
||||
type: "client"
|
||||
},
|
||||
inject (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
if (bot.server.reconnectDelay < 0) return
|
||||
bot.on('end', () => {
|
||||
setTimeout(() => {
|
||||
let client = new mc.createClient(bot.server)
|
||||
bot._client = client;
|
||||
bot.emit('init_client', client)
|
||||
}, bot.server.reconnectDelay);
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
const registry = require('prismarine-registry');
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
name: 'registry',
|
||||
type: 'client',
|
||||
enabled: true
|
||||
},
|
||||
inject (context) {
|
||||
let bot = context.bot;
|
||||
bot.on('login', packet => {
|
||||
bot.registry = registry(bot.version)
|
||||
bot.registry.language = require('../data/language.json');
|
||||
bot.emit('registry_ready', bot.registry)
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
module.exports = {
|
||||
data: {
|
||||
enabled: true,
|
||||
name: "selfcare",
|
||||
type: "client"
|
||||
},
|
||||
inject (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
|
||||
let entityId;
|
||||
let permission = 2
|
||||
let gameMode;
|
||||
|
||||
bot.on('packet.entity_status', (data) => {
|
||||
if (data.entityId !== entityId || data.entityStatus < 24 || data.entityStatus > 28) return;
|
||||
permission = data.entityStatus - 24
|
||||
});
|
||||
|
||||
bot.on('packet.game_state_change', (data) => {
|
||||
if (data.reason !== 3) return; // Reason 3 = Change Game Mode
|
||||
if (data.reason !== 4) return;
|
||||
gameMode = data.gameMode;
|
||||
});
|
||||
|
||||
let timer;
|
||||
bot.on('packet.login', (data) => {
|
||||
console.log(data.gameMode);
|
||||
entityId = data.entityId;
|
||||
gameMode = data.gameMode;
|
||||
timer = setInterval(() => {
|
||||
if (permission < 2) bot.chat("/minecraft:op @s[type=player]");
|
||||
else if (gameMode !== 1) bot.chat("/minecraft:gamemode creative");
|
||||
|
||||
else if (gameMode !== 4) bot._client.write("client_command", { actionId: 0 });
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
const registry = require('prismarine-registry');
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
name: 'test',
|
||||
type: 'client',
|
||||
enabled: false
|
||||
},
|
||||
inject (context) {
|
||||
let bot = context.bot;
|
||||
bot.end();
|
||||
/* bot.on('login', packet => {
|
||||
bot.registry = registry(bot.version)
|
||||
bot.registry.language = require('../data/language.json');
|
||||
bot.emit('registry_ready', bot.registry)
|
||||
});*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
data: {
|
||||
enabled: true,
|
||||
name: "validation",
|
||||
type: "bot validation shit"
|
||||
},
|
||||
inject (context) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class CommandSource {
|
||||
constructor (player) {
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
module.exports = CommandSource
|
||||
@@ -0,0 +1,18 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
async function loadModules (bot, config) {
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, '../', 'modules'))) {
|
||||
try {
|
||||
if (filename.endsWith(".js")) {
|
||||
const module = require(path.join(__dirname, '../modules', filename));
|
||||
if (module.data.enabled === false) return;
|
||||
module.inject({ bot, config });
|
||||
bot.emit('modules', module.data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to load module ${filename} due to error`);
|
||||
console.error(`\x1b[31m${error.stack}\x1b[0m`);
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = loadModules;
|
||||
Reference in New Issue
Block a user