Co-Authored-By: morgan <53660725+MorganAnkan@users.noreply.github.com>
This commit is contained in:
Chipmunk 2022-12-03 23:03:24 -05:00
parent 8495b6c190
commit dac08341e6
321 changed files with 522918 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
# ignore configs and modules
*/config.json
*/node_modules

View file

@ -0,0 +1,56 @@
var instruments_map = require("./instruments_map.json");
function mapnoteblocks(bot) {
var result = [];
for (x = -4; x <= 4; x++) {
for (y = -4; y <= 4; y++) {
for (z = -4; z <= 4; z++) {
var pos = bot.blockAt(bot.entity.position.offset(x, y, z));
var blockAbove = bot.blockAt(bot.entity.position.offset(x, y + 1, z));
if (pos.name == "note_block" && (blockAbove.name == "air" || blockAbove.name == "cave_air" || blockAbove.name == "void_air")) {
var NBInfo = getNoteBlockInfo(pos);
pos.pitch = NBInfo.pitch == undefined ? 0 : NBInfo.pitch;
pos.instrumentid = NBInfo.instrumentid == undefined ? 0 : NBInfo.instrumentid;
result.push(pos);
}
}
}
}
return result;
}
// Thanks Quad
function noteblockInfoFromMetadata(metadata) {
var instrumentid = Math.floor(metadata / 50);
var pitch;
if ((metadata % 2) == 0) {
pitch = metadata / 2;
} else {
pitch = ((metadata - 1) / 2) + 1;
}
pitch = pitch - instrumentid * 25;
pitch = pitch - 1;
var instrument = instruments_map.lowercase[instrumentid];
return { instrument: instrument, instrumentid: instrumentid, pitch: pitch };
}
function getNoteBlockInfo(block) {
if (block == null) return console.log("Block was null!");
if (block.name == null || block.metadata == null) return console.log("Block name or metadata was null!");//should never happend
if (block.name != "note_block") return console.log("Expected name 'note_block' got " + block.name);
return noteblockInfoFromMetadata(block.metadata);
}
module.exports = {
mapnoteblocks,
getNoteBlockInfo,
noteblockInfoFromMetadata
};

234
SandCatBot/command-handler.js Executable file
View file

@ -0,0 +1,234 @@
var fs = require("fs");
var path = require("path");
var is_initilized = false;
var commands = {};
var categories = {};
//main functions
function load(prefix = "s!", directory = "./commands") {
//setup global variable
this.prefix = prefix;
this.directory = directory;
//initiliaze command handler
let categories_ = [];
let aliases = [];
if (!isDirectory(directory))
fs.mkdirSync(directory);
if (categories["default"] == null)
categories["default"] = { enabled: true, commands: {} };
fs.readdirSync(directory).forEach(file => {
let absolute_path = path.resolve(`${directory}/${file}`);
if (isDirectory(absolute_path) && path.parse(absolute_path).name != "default") {
categories_.push(absolute_path);
return;
}
let required = loadCommand(absolute_path);
if (required == null)
return;
if (commands[required.name] == null) {
commands[required.name] = required;
categories[required.category].commands[required.name] = required;
}
if (required.aliases.length != 0)
aliases.push(required);
});
categories_.forEach(category => {
if (categories[path.parse(category).name] == null)
categories[path.parse(category).name] = { enabled: true, commands: {} };
fs.readdirSync(category).forEach(file => {
let absolute_path = path.resolve(`${category}/${file}`);
let required = loadCommand(absolute_path, path.parse(category).name);
if (required == null)
return;
if (commands[required.name] == null) {
commands[required.name] = required;
categories[required.category].commands[required.name] = required;
}
if (required.aliases.length != 0)
aliases.push(required);
});
});
aliases.forEach(command => {
command.aliases.forEach(alias => {
if (commands[alias] == null)
commands[alias] = command;
});
});
is_initilized = true;
}
function loadCommand(absolute_path, category = "default") {
if (!isFile(absolute_path) || path.parse(absolute_path).ext != ".js")
return;
let file = path.parse(absolute_path).base;
try {
let required = require(absolute_path);
if (!isValid(required)) {
console.log(`Command ${file} is invalid!`)
return;
}
required.path = absolute_path;
required.category = category;
return required;
} catch (err) {
console.log(`Couldnt load ${file}:\n ${err}`);
return;
}
}
function execute(bot, cmd, username, args, ...custom) {
if (!is_initilized)
return error(`The command ahndler was not initlized!`, "not_init");
if (!isCommand(cmd))
return error(`Invalid command ${cmd}!`, "invalid_command");
let cmd_info = info(cmd);
if (!cmd_info.enabled)
return error(`Command ${cmd} is currently disabled!`);
try {
let output = cmd_info.execute(bot, cmd, username, args, this, ...custom);
return success(output);
} catch (err) {
console.log(`Error while executing ${cmd} (args: [${args.join(", ")}])!`);
console.log(err.stack);
return error(`Error while executing the command!`);
}
}
function reload(command) {
if (!is_initilized)
return error(`The command ahndler was not initlized!`, "not_init");
if (command == null) {
try {
Object.keys(commands).forEach(key => {
let command = commands[key];
delete require.cache[command.path];
});
} catch (err) { }
commands = {};
categories = {};
load();
return success(`successfully reloaded all commands!`);
} else {
let cmd_info = info(command);
if (cmd_info == null)
return error(`${this.prefix}${command} doesnt exist or was not loaded before!`);
try {
let path = cmd_info.path;
let category = cmd_info.category;
let aliases = cmd_info.aliases;
aliases.forEach(alias => {
if (commands[alias] == cmd_info)
delete commands[alias];
});
delete commands[cmd_info.name];
delete categories[cmd_info.category].commands[cmd_info.name];
delete require.cache[cmd_info.path];
let required = loadCommand(path, category);
if (required == null)
return;
if (commands[required.name] == null) {
commands[required.name] = required;
categories[required.category].commands[required.name] = required;
}
if (required.aliases.length != 0) {
required.aliases.forEach(alias => {
if (commands[alias] == null)
commands[alias] = required;
});
}
return success(`Successfully reloaded ${this.prefix}${command}`);
} catch (err) {
console.log(`Error while realoding ${command}!`);
console.log(err.stack);
return error(`Couldn't reload ${this.prefix}${command}`, "reload_error");
}
}
}
//utility functions
function isCommand(command) {
return commands[command] != null;
}
function info(command) {
if (!isCommand(command))
return null;
return commands[command];
}
function getCategory(category) {
if (categories[category] != null && Object.keys(categories[category].commands).length == 0)
return null;
return categories[category];
}
function getCategories() {
return Object.keys(categories);
}
function success(message) {
return { status: "success", message };
}
function error(message, code = "unknown") {
return { status: "error", message, code };
}
function isFile(filePath) {
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
}
function isDirectory(filePath) {
return fs.existsSync(filePath) && fs.statSync(filePath).isDirectory();
}
function isValid(command) {
return command != null && typeof command.execute == "function" && typeof command.name == "string" && typeof command.description == "string" && typeof command.usage == "string" && typeof command.enabled == "boolean" && Array.isArray(command.aliases);
}
//module.exports
module.exports = load;
module.exports.reload = reload;
module.exports.execute = execute;
module.exports.isCommand = isCommand;
module.exports.getCategories = getCategories;
module.exports.getCategory = getCategory;
module.exports.info = info;
module.exports.prefix = "s!";
module.exports.directory = "./commands";

View file

@ -0,0 +1,107 @@
var name = "addbot";
var aliases = ["ab"];
var description = "Adds a bot to the server.";
var usage = "{prefix}addbot <username>";
var enabled = true;
var fs = require('fs');
var path = require('path');
var mineflayer = require('mineflayer');
var util = require("./../../util.js");
var cmd_handler = require("./cmdhandler/command-handler.js");
var online_mode = require("./../../online_mode.js");
function execute(bot, cmd, username, args, handler) {
const options = bot.options;
options.username = args[0] || `bot${Math.round(util.random(1000,9999))}`; options.username += ` §${Math.round(util.random(1, 9))}`
options.password = null;
const prevName = options.username;
const prevHost = options.host;
const prevPort = options.port;
if(args[1]) options.host = args[1];
if(args[2]) options.port = args[2];
if (online_mode.getEnabled()) {
const account = online_mode.getAccount();
options.username = account[0];
options.password = account[1];
online_mode.incAccountsUsed();
}
const nBot = mineflayer.createBot(options);
cmd_handler();
nBot.on ('login', _ => {
//if (online_mode.getEnabled()) bot.chat(`/sudo `+nBot.username+` username `+prevName);
console.log('Added bot '+nBot.username+' successfully connected.');
nBot.chat(util.colors('&aConnected!'));
});
const handleChat = (username, message) => {
//console.log(`[chat] <${username}> ${message}`);
if (message.startsWith(cmd_handler.prefix)) {
let args = message.slice(cmd_handler.prefix.length).split(" ");
let command = args.shift();
if (cmd_handler.isCommand(command)) {
let output = cmd_handler.execute(nBot, command, username, args);
if (output.status == "success") {
if (typeof output.message == "string")
nBot.chat(util.infoMessage(output.message));
} else if (output.status == "error") {
if (typeof output.message == "string")
nBot.chat(util.errorMessage(output.message));
}
}
}
/*
if (message.startsWith(cmd_handler.prefix)) {
let args = message.split(" ");
let command = args.shift().slice(cmd_handler.prefix.length);
let output = cmd_handler.execute(command, username, args, bot)
if (output.status == "error") {
let error = output.message;
//let code = output.code;
bot.chat(util.errorMessage(error));
}
}
*/
}
nBot.on("chat", handleChat);
if (prevHost != options.host) {
bot.on("chat", handleChat);
}
nBot.on ('error', (err) => {
bot.chat(util.colors('&c'+err));
});
/*nBot.on ('error', (err) => {
bot.chat(util.colors('&c'+err));
});*/
nBot.on ('end', _ => {
if (online_mode.getEnabled()) online_mode.incAccountsUsed(-1);
});
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,48 @@
var name = "addserver";
var aliases = ["as"];
var description = "Adds server.";
var usage = "{prefix}addserver";
var enabled = true;
var mcServer = require('flying-squid')
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
mcServer.createMCServer({
'motd': 'A Minecraft Server \nRunning flying-squid',
'port': Math.round(util.random(1025,65535)),
'max-players': 10,
'online-mode': false,
'logging': true,
'gameMode': 1,
'difficulty': 1,
'worldFolder':'world',
'generation': {
'name': 'diamond_square',
'options':{
'worldHeight': 80
}
},
'kickTimeout': 10000,
'plugins': {
},
'modpe': false,
'view-distance': 10,
'player-list-text': {
'header':'Flying squid',
'footer':'Test server'
},
'everybody-op': true,
'max-entities': 100,
'version': '1.16.1'
})
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,14 @@
var name = "chatasbot";
var aliases = [];
var description = "Chats as an added bot.";
var usage = "{prefix}chatAsBot <username> <message>";
var enabled = true;
function execute(bot, cmd, username, args, handler) { }
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,234 @@
var fs = require("fs");
var path = require("path");
var is_initilized = false;
var commands = {};
var categories = {};
//main functions
function load(prefix = "s!", directory = "./commands/addBot/commands") {
//setup global variable
this.prefix = prefix;
this.directory = directory;
//initiliaze command handler
let categories_ = [];
let aliases = [];
if (!isDirectory(directory))
fs.mkdirSync(directory);
if (categories["default"] == null)
categories["default"] = { enabled: true, commands: {} };
fs.readdirSync(directory).forEach(file => {
let absolute_path = path.resolve(`${directory}/${file}`);
if (isDirectory(absolute_path) && path.parse(absolute_path).name != "default") {
categories_.push(absolute_path);
return;
}
let required = loadCommand(absolute_path);
if (required == null)
return;
if (commands[required.name] == null) {
commands[required.name] = required;
categories[required.category].commands[required.name] = required;
}
if (required.aliases.length != 0)
aliases.push(required);
});
categories_.forEach(category => {
if (categories[path.parse(category).name] == null)
categories[path.parse(category).name] = { enabled: true, commands: {} };
fs.readdirSync(category).forEach(file => {
let absolute_path = path.resolve(`${category}/${file}`);
let required = loadCommand(absolute_path, path.parse(category).name);
if (required == null)
return;
if (commands[required.name] == null) {
commands[required.name] = required;
categories[required.category].commands[required.name] = required;
}
if (required.aliases.length != 0)
aliases.push(required);
});
});
aliases.forEach(command => {
command.aliases.forEach(alias => {
if (commands[alias] == null)
commands[alias] = command;
});
});
is_initilized = true;
}
function loadCommand(absolute_path, category = "default") {
if (!isFile(absolute_path) || path.parse(absolute_path).ext != ".js")
return;
let file = path.parse(absolute_path).base;
try {
let required = require(absolute_path);
if (!isValid(required)) {
console.log(`Command ${file} is invalid!`)
return;
}
required.path = absolute_path;
required.category = category;
return required;
} catch (err) {
console.log(`Couldnt load ${file}:\n ${err}`);
return;
}
}
function execute(bot, cmd, username, args, ...custom) {
if (!is_initilized)
return error(`The command ahndler was not initlized!`, "not_init");
if (!isCommand(cmd))
return error(`Invalid command ${cmd}!`, "invalid_command");
let cmd_info = info(cmd);
if (!cmd_info.enabled)
return error(`Command ${cmd} is currently disabled!`);
try {
let output = cmd_info.execute(bot, cmd, username, args, this, ...custom);
return success(output);
} catch (err) {
console.log(`Error while executing ${cmd} (args: [${args.join(", ")}])!`);
console.log(err.stack);
return error(`Error while executing the command!`);
}
}
function reload(command) {
if (!is_initilized)
return error(`The command ahndler was not initlized!`, "not_init");
if (command == null) {
try {
Object.keys(commands).forEach(key => {
let command = commands[key];
delete require.cache[command.path];
});
} catch (err) { }
commands = {};
categories = {};
load();
return success(`successfully reloaded all commands!`);
} else {
let cmd_info = info(command);
if (cmd_info == null)
return error(`${this.prefix}${command} doesnt exist or was not loaded before!`);
try {
let path = cmd_info.path;
let category = cmd_info.category;
let aliases = cmd_info.aliases;
aliases.forEach(alias => {
if (commands[alias] == cmd_info)
delete commands[alias];
});
delete commands[cmd_info.name];
delete categories[cmd_info.category].commands[cmd_info.name];
delete require.cache[cmd_info.path];
let required = loadCommand(path, category);
if (required == null)
return;
if (commands[required.name] == null) {
commands[required.name] = required;
categories[required.category].commands[required.name] = required;
}
if (required.aliases.length != 0) {
required.aliases.forEach(alias => {
if (commands[alias] == null)
commands[alias] = required;
});
}
return success(`Successfully reloaded ${this.prefix}${command}`);
} catch (err) {
console.log(`Error while realoding ${command}!`);
console.log(err.stack);
return error(`Couldn't reload ${this.prefix}${command}`, "reload_error");
}
}
}
//utility functions
function isCommand(command) {
return commands[command] != null;
}
function info(command) {
if (!isCommand(command))
return null;
return commands[command];
}
function getCategory(category) {
if (categories[category] != null && Object.keys(categories[category].commands).length == 0)
return null;
return categories[category];
}
function getCategories() {
return Object.keys(categories);
}
function success(message) {
return { status: "success", message };
}
function error(message, code = "unknown") {
return { status: "error", message, code };
}
function isFile(filePath) {
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
}
function isDirectory(filePath) {
return fs.existsSync(filePath) && fs.statSync(filePath).isDirectory();
}
function isValid(command) {
return command != null && typeof command.execute == "function" && typeof command.name == "string" && typeof command.description == "string" && typeof command.usage == "string" && typeof command.enabled == "boolean" && Array.isArray(command.aliases);
}
//module.exports
module.exports = load;
module.exports.reload = reload;
module.exports.execute = execute;
module.exports.isCommand = isCommand;
module.exports.getCategories = getCategories;
module.exports.getCategory = getCategory;
module.exports.info = info;
module.exports.prefix = "s!";
module.exports.directory = "./commands";

View file

@ -0,0 +1,26 @@
var name = "chatasbot";
var aliases = [];
var description = "Chats as an added bot.";
var usage = "{prefix}chatAsBot <username> <message>";
var enabled = true;
var util = require("./../../../../util.js");
function execute(bot, cmd, username, args, handler) {
if (bot.username !== args[0]) return
let chat = '';
for (let i = 1; i < args.length; i++) {
chat = chat + ' ' + args[i];
}
bot.chat(chat.trim());
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,22 @@
var name = "endbot";
var aliases = ["eb"];
var description = "Ends added bot.";
var usage = "{prefix}endbot <username>";
var enabled = true;
var util = require("./../../../../util.js");
function execute(bot, cmd, username, args, handler) {
if (bot.username !== args[0] && args[0] !== 'all') return
bot.chat(util.colors('Bye!'));
bot.end();
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,29 @@
var name = "reload";
var aliases = ["r"];
var description = "Reload a command";
var usage = "{prefix}reload";
var enabled = true;
var util = require("./../../../../util.js");
//var perms = require("./../../config.json").commands_perms;
function execute(bot, cmd, username, args, handler) {
/*if (!perms.includes(username) && username !== bot.username)
return bot.chat(util.errorMessage("No permission to use this command."));*/
let result = handler.reload(args[0]);
if (result.status == "success")
bot.chat(util.infoMessage(result.message));
else
bot.chat(util.errorMessage(result.message));
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,14 @@
var name = "endbot";
var aliases = ["eb"];
var description = "Ends added bot.";
var usage = "{prefix}endbot <username>";
var enabled = true;
function execute(bot, cmd, username, args, handler) { }
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,30 @@
var name = "entitypos";
var aliases = ["epos"];
var description = "Gets the pos of an entity.";
var usage = "{prefix}entitypos";
var enabled = true;
var util = require("./../../util.js");
var sleep = require("system-sleep");
function execute(bot, cmd, username, args, handler) {
bot.addChatPattern('pos', /.+\[(.+)d, (.+)d, (.+)d]/, { parse: true, repeat: false });
bot.once('chat:pos', matches => {
const coords = `${matches[0]}`.split(',');
sleep(150);
bot.chat(`&aThe position of the entity ${args[0]} is: ${coords[0]}, ${coords[1]}, ${coords[2]}.`);
});
bot.chat(`/data get entity ${args[0]} Pos`);
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,24 @@
var name = "entitytp2coords";
var aliases = ["entitytp2c","etp2c"];
var description = "Teleports an entity to coordinates.";
var usage = "{prefix}entitytp2coords <target> <x> <y> <z>";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
if (args.length !== 4) {
bot.chat(`&cUsage: ` + usage);
return;
}
bot.chat(`/execute as ${args[0]} run data merge entity @s {Pos:[ ${args[1]}d,${args[2]}d,${args[3]}d]}`);
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,23 @@
var name = "entitytp2entity";
var aliases = ["entitytp2e","etp2e"];
var description = "Teleports an entity to another entity.";
var usage = "{prefix}entitytp2entity <target1> <target2>";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
if (args.length !== 2) {
bot.chat(`&cUsage: ` + usage);
return;
}
bot.chat(`/execute as ` + args[0] + ` run data modify entity @s Pos prepend from entity ` + args[1] + ` Pos[]`);
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,19 @@
var name = "rtp";
var aliases = [];
var description = "Teleports you to a random location.";
var usage = "{prefix}rtp";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
bot.chat(`/tp ${username} ${util.random(-30000000, 30000000)} 256 ${util.random(-30000000, 30000000)}`);
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,29 @@
var name = "ulspawnmob";
var aliases = [];
var description = "SpawnMob without the 10 mobs limit.";
var usage = "{prefix}ulspawnmob <mob> <count>";
var enabled = true;
var util = require("./../../util.js");
var sleep = require("system-sleep");
function execute(bot, cmd, username, args, handler) {
let toSpawn = args[1]
while (toSpawn > 0) {
let spawning = toSpawn;
if (spawning > 10) spawning = 10;
bot.chat(`/sudo ${username} spawnmob ${args[0]} ${spawning}`);
//bot._client.write('chat', {message: `/spawnmob ` + args[0] + ` ` + spawning})
toSpawn -= spawning;
sleep(150);
}
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,77 @@
var name = "check";
var aliases = ["canplay"];
var description = "Check if a song can be played";
var usage = "{prefix}check <song>";
var enabled = true;
var util = require("./../../util.js");
var parser = require("./../../parser.js");
var mapper = require("./../../block-mapper.js");
var instruments_map = require("./../../instruments_map.json");
function execute(bot, cmd, username, args, handler) {
if (args[0] == null)
return bot.chat(util.errorMessage(`Usage: ${usage.replace(/{prefix}/g, handler.prefix)}`));
var sang = `./songs/${args[0]}` + (args[0].endsWith(".txt") ? "" : ".txt");
let info = parser.songInfo(sang);
if (info == null) {
bot.chat(util.errorMessage(`Failed to get songinfo for ${args[0]}`));
return;
}
let noteblocks = mapper.mapnoteblocks(bot);
if (noteblocks.length == 0) {
bot.chat(util.errorMessage(`No noteblocks found!`));
return;
}
Object.keys(info.noteblocksByInstrument).forEach(id => {
let instruments_arr = info.noteblocksByInstrument[id];
noteblocks.forEach(noteblock => {
if (noteblock.instrumentid == id) {
instruments_arr.shift();
}
});
});
let missing_instruments = Object.keys(info.noteblocksByInstrument).map(key => info.noteblocksByInstrument[key]).filter(instrument => instrument.length > 0);
if (missing_instruments.length > 0) {
//missing instruments
let missing = {};
Object.keys(info.noteblocksByInstrument).forEach(key => {
if (info.noteblocksByInstrument[key].length > 0)
missing[key] = info.noteblocksByInstrument[key].length;
});
let send = Object.keys(missing).map(key => {
return `&r${instruments_map.lowercase[key]}/&7${instruments_map.blocks[key]} &r(&c${missing[key]}&r)`;
}).join(", ");
var message = [];
Object.keys(missing_instruments).forEach(instrument => {
console.log(missing_instruments[instrument])
message.push(`&r${instruments_map.lowercase[instrument]}&7/${instruments_map.blocks[instrument]}&r: &b${missing_instruments[instrument]}`);
});
message = message.join(", ");
bot.chat(util.infoMessage(`Missing: ${send}`));
} else {
//there are all the instruments
bot.chat(util.infoMessage(`The bot has all &b${info.used_instruments.length}&7 instruments required to play the song &b${args[0]}`));
}
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,45 @@
var name = "instrument";
var aliases = ["instrumentinfo","instinfo","instinf"];
var description = "Instrument info";
var usage = "{prefix}instrument <instrumentid/string>";
var enabled = true;
var util = require("./../../util.js");
var instruments_map = require("./../../instruments_map.json");
var parser = require("./../../parser.js");
function execute(bot, cmd, username, args, handler) {// TODO: maybe blocks too but would need a better instrument map for blocks
if(args.length == 0) return bot.chat(util.errorMessage(`Usage: ${handler.prefix}instrument <instrumentid/string>`));
var joined = args.join("_").toLowerCase();
if(isNumber(args[0])) {
var instToFind = parseInt(args[0]);
if(instToFind > Object.keys(instruments_map.lowercase).length-1) {
return bot.chat(util.errorMessage(`Cant find any info for instrument ${instToFind}`));
}
bot.chat(util.infoMessage(`Info for instrument &b${instToFind}`));
util.wait(80).then(() => bot.chat(util.infoMessage(`As integer &b${instToFind}`)));
util.wait(80*2).then(() => bot.chat(util.infoMessage(`Block &b${instruments_map.blocks[instToFind]}`)));
util.wait(80*3).then(() => bot.chat(util.infoMessage(`Instrument name &b${instruments_map.lowercase[instToFind]}`)));
} else if(Object.keys(instruments_map.reverse_lowercase).includes(joined)) {
bot.chat(util.infoMessage(`Info for instrument &b${joined}`));
util.wait(80).then(() => bot.chat(util.infoMessage(`As integer &b${instruments_map.reverse_lowercase[joined]}`)));
util.wait(80*2).then(() => bot.chat(util.infoMessage(`Block &b${instruments_map.blocks[instruments_map.reverse_lowercase[joined]]}`)));
util.wait(80*3).then(() => bot.chat(util.infoMessage(`Instrument name &b${joined}`)));
} else return bot.chat(util.errorMessage(`Cant find any info for instrument ${joined}`));
}
function isNumber(str) {
if(typeof str == "number") return true;
try {
return !isNaN(parseInt(str));
} catch(notNumber) {
return false;
}
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,41 @@
var name = "nowplaying";
var aliases = ["np","current"];
var description = "Says info about the song that is playing";
var usage = "{prefix}nowplaying";
var enabled = true;
var parser = require("./../../parser.js");
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
if(!parser.isPlaying()) {
bot.chat(util.infoMessage(`Bot is currently not playing anything`));
return;
}
var np = parser.getNowPlaying();
bot.chat(util.infoMessage(`Now playing &e${np.song_name}`));
let currtime = parser.timeConverter(np.time.current);
let fulltime = parser.timeConverter(np.time.full);
let timeStrc = timeToStr(currtime, np.time.current);
let timeStrf = timeToStr(fulltime, np.time.full);
util.wait(120).then(() => {bot.chat(util.infoMessage(`Current time: ${timeStrc}`))});
util.wait(120*2).then(() => {bot.chat(util.infoMessage(`Full time: ${timeStrf}`))});
util.wait(120*3).then(() => {bot.chat(util.infoMessage(`Added by: &b${np.addedBy}`))});
if(np.url != undefined) {
util.wait(120*4).then(() => {bot.chat(util.infoMessage(`URL: &b${np.url}`))});
}
}
function timeToStr(time, ticks) {
return `&b${time.h}&7h &b${time.min}&7min &b${time.sec}&7sec &b${time.ms}&7ms (&b${ticks}&7ticks)`;
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,73 @@
var name = "play";
var aliases = ["p"];
var description = "Play a notebot song";
var usage = "{prefix}play <song>";
var enabled = true;
var blockmapper = require("./../../block-mapper.js");
var parser = require("./../../parser.js");
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
if(args.length == 0) {
bot.chat(util.errorMessage(`Usage: ${handler.prefix}play <song>`));
return;
}
/*if(bot.player.gamemode != 0) {
bot.chat(util.errorMessage("Bot is not in survival mode!"));
return;
}*/
if(parser.isPlaying() == true) {
bot.chat(util.errorMessage("Bot is already playing a song"));
return;
}
if(parser.isTuning() == true) {
bot.chat(util.errorMessage("Bot is tuning"));
return;
}
var file = `./songs/${args[0]}`;
if(!args[0].endsWith(".txt")) {
file += ".txt";
}
if(!parser.isValidFile(file)) {
bot.chat(util.errorMessage(`${args[0]} appears to be a invalid notebot file`));
return;
}
var test = file.match(/\\/g); test == null ? 0 : test;
if(file.match(/\//g).length > 2 || test > 0) {// so people dont try to go outside of the ./songs/ directory
bot.chat(util.errorMessage("no dont even try with that dir"));
return;
}
let noteblocks = blockmapper.mapnoteblocks(bot);
bot.chat(util.infoMessage(`Found &b${noteblocks.length}&7 noteblocks!`));
parser.tuneNoteblocks(file, noteblocks, true, (success, error) => {
if(success) {
util.wait(80).then(() => bot.chat(util.infoMessage(success)));
util.wait(200).then(() => {
var songName = args[0].replace(".txt", "");
parser.editNowPlaying(songName, 0, undefined, undefined, username);
bot.chat(util.infoMessage(`Now playing &e${songName}`));
parser.play(bot, noteblocks, file);
});
} else if(error) {
util.wait(80).then(() => bot.chat(util.errorMessage(error)));
} else {
console.log(`The playing of song ${file} has been cancelled manually`);
util.wait(80).then(() => bot.chat(util.infoMessage(`The playing of song &b${file.replace("./songs/", "").replace(".txt", "")}&7 has been cancelled manually`)));
}
});
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,91 @@
var name = "playurl";
var aliases = ["purl","pu"];
var description = "Play a url instead of a file";
var usage = "{prefix}playurl <url>";
var enabled = true;
var util = require("./../../util.js");
var parser = require("./../../parser.js");
var config = require("./../../config.json");
var blockmapper = require("./../../block-mapper.js");
var download = require("./../../songdownloader.js").download;
var toNotebot = require("./../../miditonotebot").toNotebot;
var fs = require("fs");
var path = require("path");
function execute(bot, cmd, username, args, handler) {
if (args.length == 0) {
return bot.chat(util.errorMessage(`Usage: ${handler.prefix}playurl <url>`));
}
/*if (bot.player.gamemode != 0) {
bot.chat(util.errorMessage("Bot is not in survival mode!"));
return;
}*/
if (parser.isPlaying() == true) {
bot.chat(util.errorMessage("Bot is already playing a song"));
return;
}
if (parser.isTuning() == true) {
bot.chat(util.errorMessage("Bot is tuning"));
return;
}
var urlObj = new URL(args[0].toString());
if (urlObj.protocol == "https:" || urlObj.protocol == "http:") {
bot.chat(util.infoMessage("Starting download..."));
util.wait(80).then(() => tryDownload(urlObj.toString(), bot, username));
} else {
return bot.chat(util.errorMessage(`hm something went wrong while parsing url: ${urlObj.toString()}`));
}
}
function tryDownload(url, bot, username) {
var start = Date.now();
download(url, undefined, (err, file) => {
if (err) {
console.log(`failed download in ${Date.now() - start}ms! ${err}`);
bot.chat(util.errorMessage(`Failed to download file: ${err}`));
} else {
bot.chat(util.infoMessage(`Finished downloading took &e${Date.now() - start}&7ms`));
console.log(`finished download in ${Date.now() - start}ms! ${file}`);
toNotebot(file, (filename, err) => {
if (err || filename == undefined) {
util.wait(200).then(() => bot.chat(util.errorMessage(err == undefined ? "Failed to parse midi file to notebot format" : err.replace("\u0000", "\u2400"))));
console.log(util.errorMessage(err == undefined ? "Failed to parse midi file to notebot format" : err));
return;
} else {
let noteblocks = blockmapper.mapnoteblocks(bot);
bot.chat(util.infoMessage(`Found &b${noteblocks.length}&7 noteblocks!`));
parser.tuneNoteblocks(filename, noteblocks, true, (success, error) => {
if (success) {
util.wait(80).then(() => bot.chat(util.infoMessage(success)));
util.wait(200).then(() => {
var songName = path.basename(filename).replace(".txt", "");
parser.editNowPlaying(songName, 0, undefined, url, username);
bot.chat(util.infoMessage(`Now playing &e${songName}`));
parser.play(bot, noteblocks, filename);
config.settings.save_downloaded_songs ? undefined : fs.unlink(filename, () => { });
});
} else if (error) {
util.wait(80).then(() => bot.chat(util.errorMessage(error)));
config.settings.save_downloaded_songs ? undefined : fs.unlink(filename, () => { });
} else {
console.log(`The playing of song ${filename} has been cancelled manually`);
util.wait(80).then(() => bot.chat(util.infoMessage(`The playing of song &b${file.replace("./songs/", "").replace(".txt", "")}&7 has been cancelled manually`)));
config.settings.save_downloaded_songs ? undefined : fs.unlink(filename, () => { });
}
});
}
});
}
});
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,49 @@
var name = "songinfo";
var aliases = ["si"];
var description = "Prints songinfo in chat";
var usage = "{prefix}songinfo <song>";
var enabled = true;
var util = require("./../../util.js");
var parser = require("./../../parser.js");
var instruments_map = require("./../../instruments_map.json");
function execute(bot, cmd, username, args, handler) {
if (args.length == 0)
return bot.chat(util.infoMessage(`Usage: ${handler.prefix}songinfo <song>`));
bot.chat(util.infoMessage(`Attempting to get songinfo for song &b${args[0]}&7 please wait...`));
let info = parser.songInfo("./songs/"+args[0]+(args[0].endsWith(".txt") ? "" : ".txt"));
if(info == null) return;
util.wait(120).then(() => bot.chat(util.infoMessage(`Total pitches &b${info.used_pitches.length}`)));
util.wait(120*2).then(() => bot.chat(util.infoMessage(`Total instruments &b${info.used_instruments.length}`)));
let instruments = [];
Object.keys(info.noteblocksByInstrument).forEach((note) => {
let thing = info.noteblocksByInstrument[note];
instruments.push(`&r${instruments_map.lowercase[parseInt(note)]}&7/${instruments_map.blocks[note]}&r: &b${thing.length}`);
})
util.wait(120*3).then(() => bot.chat(util.infoMessage(`Instruments ${instruments.join("&7, ")}`)));
let time = parser.timeConverter(info.songlength);
let timeStr = `&b${time.h}&7h &b${time.min}&7min &b${time.sec}&7sec &b${time.ms}&7ms (&b${info.songlength}&7ticks)`;
util.wait(120*4).then(() => bot.chat(util.infoMessage(`Song length ${timeStr}`)));
/*
the object returned:
{
used_pitches, ---> [1, 4, 5, 10, ...] (pitches list)
used_instruments, ---> [0, 5, 4, 2, ...] (instruments list numerical ids)
noteblocks_list, ---> [{instrument: 0, pitch: 3}, {instrument: 1, pitch: 6}, ...] (all the unique noteblocks needed)
noteblocksByInstrument, ---> {3: [1, 5, 6], 0: [0, 10, 11], ...} (all the pitches that a specific instrument use)
length ---> 1500 (length of the song in ticks)
}
*/
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,27 @@
var name = "songs";
var aliases = ["songlist"];
var description = "Says all available songs in chat";
var usage = "{prefix}songs";
var enabled = true;
var util = require("./../../util.js");
var fs = require("fs");
function execute(bot, cmd, username, args, handler) {
var files = fs.readdirSync("./songs/");
files.filter((file) => file.endsWith(".txt"));
var i = 0;
files.forEach((file) => {
util.wait(100*i++).then(() => {
bot.chat(util.infoMessage("Song: &e"+file));
});
});
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,28 @@
var name = "stop";
var aliases = ["cancel"];
var description = "Stops the current song/tuning";
var usage = "{prefix}stop";
var enabled = true;
var util = require("./../../util.js");
var parser = require("./../../parser.js");
function execute(bot, cmd, username, args, handler) {
if(!parser.isTuning() && !parser.isPlaying()) {
bot.chat(util.errorMessage("No song is playing..."));
} else if(parser.isTuning()) {
parser.setcancelTune(true);
bot.chat(util.infoMessage("Stopped tuning!"));
} else if(parser.isPlaying()) {
parser.setcancelPlay(true);
bot.chat(util.infoMessage("Stopped playing!"));
}
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,23 @@
var name = "hbotdiscord";
var aliases = [];
var description = "When the message is sus :o";
var usage = "{prefix}hbotdiscord <username> <message>";
var enabled = true;
var util = require("./../../util.js");
var sleep = require("system-sleep");
var perms = require("./../../config.json").commands_perms;
function execute(bot, cmd, username, args, handler) {
user = args.shift();
msg = args.join(' ');
bot.chat(`&8[&9HBot Discord&8] &3${user} &8 &7${msg}`);
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,18 @@
var name = "0trust";
var aliases = ["0t"];
var description = "Free trusted commands on 0skar's command bot.";
var usage = "{prefix}0trust <command>";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
bot.chat(`/say <ignGeri> ${args.join(' ')}`)
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,27 @@
var name = "buildcloop";
var aliases = [];
var description = "Builds a cloop.";
var usage = "{prefix}buildcloop <command>";
var enabled = true;
var util = require("./../../util.js");
var sleep = require("system-sleep");
var perms = require("./../../config.json").commands_perms;
function execute(bot, cmd, username, args, handler) {
command = args.join(' ');
bot.chat(`/execute at ${username} run setblock ~ ~2 ~1 repeating_command_block[facing=up]{Command:'clone ~ ~2 ~ ~ ~3 ~ ~ ~ ~'}`); sleep(150);
bot.chat(`/execute at ${username} run setblock ~ ~3 ~1 chain_command_block[facing=up]{Command:'${command}',auto:1b}`); sleep(150);
bot.chat(`/execute at ${username} run setblock ~ ~4 ~1 repeating_command_block[facing=up]{Command:'clone ~ ~2 ~ ~ ~3 ~ ~ ~ ~'}`); sleep(150);
bot.chat(`/execute at ${username} run setblock ~ ~5 ~1 chain_command_block[facing=up]{Command:'${command}',auto:1b}`); sleep(150);
bot.chat(`/execute at ${username} run setblock ~ ~ ~1 observer[facing=up]`); sleep(150);
bot.chat(`/execute at ${username} run setblock ~ ~1 ~1 observer[facing=down]`); sleep(150);
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

19
SandCatBot/commands/util/cb.js Executable file
View file

@ -0,0 +1,19 @@
var name = "cb";
var aliases = [];
var description = "Executes what you type in a command block.";
var usage = "{prefix}cb <command>";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
bot.chat(`/setblock ~ 1 ~ command_block{auto:1b,Command:"${args.join(' ').replace(/"/g, '\\"')
.replace(/{command}/, hander.prefix+command+' '+args.join(' '))}"} destroy`);
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,20 @@
var name = "clearlooped";
var aliases = [/*"clrlp"*/];
var description = "Clears looped chat messages.";
var usage = "{prefix}clearlooped <text>";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
bot.loopChat = [];
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,18 @@
var name = "echo";
var aliases = ["e"];
var description = "Echoes what you type.";
var usage = "{prefix}echo <text>";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
bot.chat(args.join(' '));
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,31 @@
var name = "endlock";
var aliases = ["elock","el"];
var description = "Locks a player using the end";
var usage = "{prefix}endlock <player>";
var enabled = true;
var util = require("./../../util.js");
var sleep = require("system-sleep");
var perms = require("./../../config.json").commands_perms;
function execute(bot, cmd, username, args, handler) {
if (!perms.includes(username) && username !== bot.username)
return bot.chat(util.errorMessage("No permission to use this command."));
bot.chat(`/world world_the_end`); sleep(150);
const x = Math.round(util.random(-30000000, 30000000));
const y = Math.round(util.random(0, 255));
const z = Math.round(util.random(-30000000, 30000000));
bot.chat(`/forceload add ${x} ${z} ${x} ${z}`); sleep(1500);
bot.chat(`/setblock ${x} ${y} ${z} end_portal`); sleep(150);
bot.chat(`/spawnpoint ${args[0]} ${x} ${y} ${z}`); sleep(150);
bot.chat(`/ekill ${args[0]}`); sleep(150);
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,31 @@
var name = "eval";
var aliases = ["ev"];
var description = "Evaluate nodejs code";
var usage = "{prefix}eval <code>";
var enabled = true;
var util = require("./../../util.js");
var perms = require("./../../config.json").eval.perms;
var enabled = require("./../../config.json").eval.enabled;
function execute(bot, cmd, username, args, handler) {
if (!perms.includes(username) && username !== bot.username)
return bot.chat(util.errorMessage("No permisson to use this command."));
if(!enabled) return bot.chat(util.colors(`&a>eval is currently disabled ;/`));
new Promise((resolve, reject) => {
resolve(eval(args.join(" ")));
}).then((output) => {
util.wait(100).then(() => bot.chat(util.colors(`&a>${output}`)))
}).catch((err) => {
//console.log(err);
bot.chat(util.colors(`&c>${err}`))
});
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,47 @@
var name = "help";
var aliases = ["commands","cmds","h"];
var description = "Help for a command.";
var usage = "{prefix}help <command>";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
if (args[0] == null) {
let categories = handler.getCategories();
let num = 0;
let a = 0;
categories.forEach((category) => {
let category_ = handler.getCategory(category);
if(category_ == null) return;
if (category_.enabled) {
let commands = Object.keys(category_.commands).map(key => category_.commands[key]).filter(cmd => cmd.enabled).map(cmd => cmd.usage.replace(/{prefix}/g, handler.prefix));
util.wait(100*num++).then(() => { bot.chat(util.colors(`${a++ % 2 == 0 ? "&f" : "&6"}&l${util.firstLetterUppercase(category)}:&7 ${commands.join("&r, &7")}`)); });
}
});
} else {
if (handler.isCommand(args[0])) {
let command = handler.info(args[0]);
bot.chat(util.infoMessage(`Info for command &f${args[0]}`));
util.wait(100).then(() => { bot.chat(util.infoMessage(`Description: &f${command.description}`)); });
util.wait(100*2).then(() => { bot.chat(util.infoMessage(`Usage: &f${command.usage.replace(/{prefix}/g, handler.prefix)}`)); });
util.wait(100*3).then(() => { bot.chat(util.infoMessage(`Aliases: &f${command.aliases.join("&7, &f")}`)); });
util.wait(100*4).then(() => { bot.chat(util.infoMessage(`Enabled: ${(command.enabled) ? "&aEnabled" : "&cDisabled"}`)); });
} else
bot.chat(util.errorMessage(`${handler.prefix}${args[0]} is not a command!`));
}
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,19 @@
var name = "kick";
var aliases = [];
var description = "sus.";
var usage = "{prefix}kick";
var enabled = false;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
bot.chat(`/title ${args[0]} title [{"nbt":"","entity":"@e"},{"nbt":"","entity":"@e"},{"nbt":"","entity":"@e"},{"nbt":"","entity":"@e"},{"nbt":"","entity":"@e"}]`)
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,18 @@
var name = "loop";
var aliases = ["l"];
var description = "Loops something in chat.";
var usage = "{prefix}loop <text>";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
bot.loopChat.push(args.join(' '));
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,55 @@
var name = "operator";
var aliases = ["o"];
var description = "Operator.";
var usage = "{prefix}operator";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
let num1 = parseFloat(args[0]);
let num2 = parseFloat(args[2]);
let operator = args[1]
let result;
switch(operator) {
case '%=':
result = args[0];
result %= args[2];
break;
case '*=':
result = args[0];
result *= args[2];
break;
case '+=':
result = args[0];
result += args[2];
break;
case '-=':
result = args[0];
result -= args[2];
break;
case '/=':
result = args[0];
result /= args[2];
break;
case '=':
result = args[0];
result = args[2];
break;
}
bot.chat(util.colors(`&aResult: ${result}`));
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,18 @@
var name = "quit";
var aliases = ["q"];
var description = "Ends the bot.";
var usage = "{prefix}end";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
bot.quit();
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,29 @@
var name = "reload";
var aliases = ["r"];
var description = "Reload a command";
var usage = "{prefix}reload";
var enabled = true;
var util = require("./../../util.js");
var perms = require("./../../config.json").commands_perms;
function execute(bot, cmd, username, args, handler) {
if (!perms.includes(username) && username !== bot.username)
return bot.chat(util.errorMessage("No permission to use this command."));
let result = handler.reload(args[0]);
if (result.status == "success")
bot.chat(util.infoMessage(result.message));
else
bot.chat(util.errorMessage(result.message));
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,19 @@
var name = "resetskins";
var aliases = ["rskins","rs"];
var description = "Resets skins.";
var usage = "{prefix}resetskins";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
bot.chat(`/`)
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,30 @@
var name = "screensaver";
var aliases = [];
var description = "Shows you a screensaver";
var usage = "{prefix}screensaver <player>";
var enabled = true;
var util = require("./../../util.js");
var sleep = require("system-sleep");
var perms = require("./../../config.json").commands_perms;
function execute(bot, cmd, username, args, handler) {
bot.chat('/world world_the_end'); sleep(150);
const x = Math.round(util.random(-30000000, 30000000));
const y = Math.round(util.random(2, 252));
const z = Math.round(util.random(-30000000, 30000000));
bot.chat(`/forceload add ${x} ${z} ${x} ${z}`); sleep(1500);
bot.chat(`/fill ${(x-3)} ${(y-3)} ${(z-3)} ${(x+3)} ${(y+3)} ${(z+3)} end_gateway`); sleep(150);
bot.chat(`/fill ${(x-2)} ${(y-2)} ${(z-2)} ${(x+2)} ${(y+2)} ${(z+2)} barrier hollow`); sleep(150);
bot.chat(`/tppos ${x} ${y} ${z}`); sleep(150);
bot.chat(`/tphere ${username}`); sleep(150);
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,23 @@
var name = "unendlock";
var aliases = [];
var description = "Unlocks an endlocked player.";
var usage = "{prefix}unendlock <player>";
var enabled = true;
var util = require("./../../util.js");
var sleep = require("system-sleep");
var perms = require("./../../config.json").commands_perms;
function execute(bot, cmd, username, args, handler) {
if (!perms.includes(username))
return bot.chat(util.errorMessage("No permission to use this command."));
bot.chat(`/sudo ${args[0]} spawn`); sleep(150);
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

55
SandCatBot/core.js Executable file
View file

@ -0,0 +1,55 @@
const bot = require("mineflayer")
bot.on('spawn', () => {
const x = 561
const y = 150
const z = -5151
setInterval(() => {
check(x, y, z);
}, 3000);
});
function check(x, y, z){
let posupd = new vec3(bot.player.entity.position)
let xu = Math.round(posupd.x)
let yu = Math.round(posupd.y)
let zu = Math.round(posupd.z)
if((x+y+z) != (xu+yu+zu)){
sleep(150);
bot.chat(`/tp ${x} ${y+0.5} ${z}`);
sleep(150);
bot.chat(`/fill ~1 ~-1 ~1 ~-1 ~-1 ~-1 minecraft:repeating_command_block`);
};
const commandBlock = bot.findBlock({
matching: mcData.blocksByName.repeating_command_block.id
});
if(commandBlock == null){
bot.chat(`/fill ~1 ~-1 ~1 ~-1 ~-1 ~-1 minecraft:repeating_command_block`);
};
};
function core(command) {
const commandBlock = bot.findBlock({
matching: mcData.blocksByName.repeating_command_block.id
});
try {
bot.setCommandBlock(commandBlock.position, command, { mode: 1, trackOutput: true, conditional: false, alwaysActive: true });
} catch (e) {
console.log('[Error]: '+e.message);
if(e.message.includes('creative mode')){
bot.chat('/gmc');
sleep(150);
core(command);
};
};
};

217
SandCatBot/index.js Executable file
View file

@ -0,0 +1,217 @@
var mineflayer = require("mineflayer");
var fs = require("fs");
var cmd_handler = require("./command-handler.js");
var util = require("./util.js");
var online_mode = require("./online_mode.js");
var sleep = require("system-sleep");
var vec3 = require("vec3");
let mcData;
var config = require("./config.json");
var botVersion = "69";
var options = {
username: config.bot.username || "SandCatBot",
host: config.bot.host || "veast.network",
port: config.bot.port || 25565,
//version: "1.15.2",
checkTimeoutInterval: 5555*1000,
plugins: {
"bed":false,
"book":false,
"boss_bar":false,
"chest":false,
//"command_block":false,
"craft":false,
"creative":false,
"digging":false,
"dispenser":false,
"enchantment_table":false,
"experience":false,
"furnace":false,
"health":false,
"inventory":false,
"rain":false,
"scoreboard":false,
"sound":false,
"title":false,
"villager":false//maybe some more?
}
}
if (online_mode.getEnabled()) {
const account = online_mode.getAccount();
const prevName = options.username;
options.username = account[0];
options.password = account[1];
online_mode.incAccountsUsed();
}
var bot = mineflayer.createBot(options);
bot.entity = {position: {x: null, y: null} };
bot.options = options;
cmd_handler();
function check(x, y, z){
let posupd = new vec3(bot.player.entity.position)
let xu = Math.round(posupd.x)
let yu = Math.round(posupd.y)
let zu = Math.round(posupd.z)
if((x+y+z) != (xu+yu+zu)){
sleep(150);
bot.chat(`/tp ${x} ${y+0.5} ${z}`);
sleep(150);
bot.chat(`/fill ~1 ~-1 ~1 ~-1 ~-1 ~-1 minecraft:repeating_command_block`);
};
const commandBlock = bot.findBlock({
matching: mcData.blocksByName.repeating_command_block.id
});
if(commandBlock == null){
bot.chat(`/fill ~1 ~-1 ~1 ~-1 ~-1 ~-1 minecraft:repeating_command_block`);
};
};
bot.core = function(command) {
const commandBlock = bot.findBlock({
matching: mcData.blocksByName.repeating_command_block.id
});
try {
bot.setCommandBlock(commandBlock.position, command, { mode: 1, trackOutput: true, conditional: false, alwaysActive: true });
} catch (e) {
console.log('[Error]: '+e.message);
if(e.message.includes('creative mode')){
bot.chat('/gmc');
sleep(150);
core(command);
};
};
};
// util.randomizeUsername(options);
var bot = mineflayer.createBot(options);
bot.options = options;
addListeners(bot);
cmd_handler();
function addListeners(bot) {
bot.on("login", () => {
mcData = require("minecraft-data")(bot.version);
console.log(`(${bot.username}) logged in!`);
bot.chat("/c on");
sleep(150);
bot.chat(util.colors("&fSandCatBot&7 v&6"+botVersion+"&7 made by &9_ChipMC_&7 and uses stuff from a bot by &aMorganAnkan&7. Prefix: '" + cmd_handler.prefix + "'."));
if (online_mode.getEnabled()) {
sleep(150);
bot.chat("/username "+config.bot.username);
}
const x = 561
const y = 150
const z = -5151
setInterval(() => {
check(x, y, z);
}, 3000);
});
bot.on("chat", (username, message) => {
console.log(`[chat] <${username}> ${message}`);
if (message.startsWith(cmd_handler.prefix)) {
let args = message.slice(cmd_handler.prefix.length).split(" ");
let command = args.shift();
if (!cmd_handler.isCommand(command)) return bot.chat(util.errorMessage(command+' is not a valid command!'));
let output = cmd_handler.execute(bot, command, username, args);
if (output.status == "success") {
if (typeof output.message == "string")
bot.chat(util.infoMessage(output.message));
} else if (output.status == "error") {
if (typeof output.message == "string")
bot.chat(util.errorMessage(output.message));
}
}
/*
if (message.startsWith(cmd_handler.prefix)) {
let args = message.split(" ");
let command = args.shift().slice(cmd_handler.prefix.length);
let output = cmd_handler.execute(command, username, args, bot);
if (output.status == "error") {
let error = output.message;
//let code = output.code;
bot.chat(util.errorMessage(error));
}
}
*/
});
bot.loopChat = [];
bot.on('physicTick', _ => {
for (const item in bot.loopChat) {
const message = bot.loopChat[item]
.replace(/{rand}/g, util.random(0, 69420));
if (message)
bot.chat(message);
}
});
bot.on("playerJoined", (player) => {
console.log(`[join] Player ${player.username} (${player.uuid}) joined.`);
});
bot.on("end", _ => {/*
bot.removeAllListeners()
sleep(5000);
options.username = config.bot.username || "SandCatBot";
util.randomizeUsername(options);
bot = mineflayer.createBot(options);
bot.entity = {position: {x: null, y: null} };
addListeners(bot);*/
});
bot._client.on('game_state_change', (packet) => {
// Fix end portal exploit lol
if (packet.reason === 4) {
bot._client.write('client_command', { payload: 0 });
}
});
}
module.exports.getBot = _ => bot
const stdin = process.openStdin();
stdin.addListener("data", (d) => {
const message = d.toString().trim();
if (!message.startsWith('/')) {
bot.chat(`/tellraw @a [{"text":"<"},{"text":"_ChipMC_","color":"blue"},{"text":"> ${message.replace(/"/g, '\\"')}"}]`);
return;
}
bot.chat(message);
});

18
SandCatBot/indexmf.js Normal file
View file

@ -0,0 +1,18 @@
const mineflayer = require('mineflayer')
const bot = mineflayer.createBot({
host: 'veast.network',
port: 25565,
username: 'test',
password: null,
plugins: {
'chat': false
}
})
bot.chat = message => bot._client.write('chat', {message: message});
bot.on('login', _ => {
bot.chat('test')
})

219
SandCatBot/indexsus.js Executable file
View file

@ -0,0 +1,219 @@
var mineflayer = require("mineflayer");
var fs = require("fs");
var cmd_handler = require("./command-handler.js");
var util = require("./util.js");
var online_mode = require("./online_mode.js");
var sleep = require("system-sleep");
var vec3 = require("vec3");
let mcData;
var config = require("./config.json");
var botVersion = "69";
var options = {
username: config.bot.username || "SandCatBot",
host: config.bot.host || "veast.network",
port: config.bot.port || 25565,
//version: "1.15.2",
checkTimeoutInterval: 5555*1000,
plugins: {
"bed":false,
"book":false,
"boss_bar":false,
"chat":false,
"chest":false,
//"command_block":false,
"craft":false,
"creative":false,
"digging":false,
"dispenser":false,
"enchantment_table":false,
"experience":false,
"furnace":false,
"health":false,
"inventory":false,
"rain":false,
"scoreboard":false,
"sound":false,
"title":false,
"villager":false//maybe some more?
}
}
if (online_mode.getEnabled()) {
const account = online_mode.getAccount();
const prevName = options.username;
options.username = account[0];
options.password = account[1];
online_mode.incAccountsUsed();
}
var bot = mineflayer.createBot(options);
bot.entity = {position: {x: null, y: null} };
bot.options = options;
bot.chat = message => bot._client.write('chat', {Message: message});
cmd_handler();
function check(x, y, z){
let posupd = new vec3(bot.player.entity.position)
let xu = Math.round(posupd.x)
let yu = Math.round(posupd.y)
let zu = Math.round(posupd.z)
if((x+y+z) != (xu+yu+zu)){
sleep(150);
bot.chat(`/tp ${x} ${y+0.5} ${z}`);
sleep(150);
bot.chat(`/fill ~1 ~-1 ~1 ~-1 ~-1 ~-1 minecraft:repeating_command_block`);
};
const commandBlock = bot.findBlock({
matching: mcData.blocksByName.repeating_command_block.id
});
if(commandBlock == null){
bot.chat(`/fill ~1 ~-1 ~1 ~-1 ~-1 ~-1 minecraft:repeating_command_block`);
};
};
bot.core = function(command) {
const commandBlock = bot.findBlock({
matching: mcData.blocksByName.repeating_command_block.id
});
try {
bot.setCommandBlock(commandBlock.position, command, { mode: 1, trackOutput: true, conditional: false, alwaysActive: true });
} catch (e) {
console.log('[Error]: '+e.message);
if(e.message.includes('creative mode')){
bot.chat('/gmc');
sleep(150);
core(command);
};
};
};
util.randomizeUsername(options);
var bot = mineflayer.createBot(options);
bot.options = options;
addListeners(bot);
cmd_handler();
function addListeners(bot) {
bot.on("login", () => {
mcData = require("minecraft-data")(bot.version);
console.log(`(${bot.username}) logged in!`);
bot.chat("/c on");
sleep(150);
bot.chat(util.colors("&fSandCatBot&7 v&6"+botVersion+"&7 made by &9_ChipMC_&7 and uses stuff from a bot by &aMorganAnkan&7. Prefix: '" + cmd_handler.prefix + "'."));
if (online_mode.getEnabled()) {
sleep(150);
bot.chat("/username "+config.bot.username);
}
const x = 561
const y = 150
const z = -5151
setInterval(() => {
check(x, y, z);
}, 3000);
});
bot.on("chat", (username, message) => {
console.log(`[chat] <${username}> ${message}`);
if (message.startsWith(cmd_handler.prefix)) {
let args = message.slice(cmd_handler.prefix.length).split(" ");
let command = args.shift();
if (!cmd_handler.isCommand(command)) return bot.chat(util.errorMessage(command+' is not a valid command!'));
let output = cmd_handler.execute(bot, command, username, args);
if (output.status == "success") {
if (typeof output.message == "string")
bot.chat(util.infoMessage(output.message));
} else if (output.status == "error") {
if (typeof output.message == "string")
bot.chat(util.errorMessage(output.message));
}
}
/*
if (message.startsWith(cmd_handler.prefix)) {
let args = message.split(" ");
let command = args.shift().slice(cmd_handler.prefix.length);
let output = cmd_handler.execute(command, username, args, bot);
if (output.status == "error") {
let error = output.message;
//let code = output.code;
bot.chat(util.errorMessage(error));
}
}
*/
});
bot.loopChat = [];
bot.on('physicTick', _ => {
for (const item in bot.loopChat) {
const message = bot.loopChat[item];
if (message)
bot.chat(message);
}
});
bot.on("playerJoined", (player) => {
console.log(`[join] Player ${player.username} (${player.uuid}) joined.`);
});
bot.on("end", _ => {
sleep(5000);
options.username = config.bot.username || "SandCatBot";
util.randomizeUsername(options);
bot = mineflayer.createBot(options);
bot.entity = {position: {x: null, y: null} };
addListeners(bot);
});
bot._client.on('game_state_change', (packet) => {
// Fix end portal exploit lol
if (packet.reason === 4) {
bot._client.write('client_command', { payload: 0 });
}
});
}
module.exports.getBot = _ => bot
const stdin = process.openStdin();
stdin.addListener("data", (d) => {
const message = d.toString().trim();
if (!message.startsWith('/')) {
bot.chat(`/tellraw @a [{"text":"<"},{"text":"_ChipMC_","color":"blue"},{"text":"> ${message.replace(/"/g, '\\"')}"}]`);
return;
}
bot.chat(message);
});

View file

@ -0,0 +1,74 @@
{
"uppercase":{
"0":"HARP",
"1":"BASEDRUM",
"2":"SNARE",
"3":"HAT",
"4":"BASS",
"5":"FLUTE",
"6":"BELL",
"7":"GUITAR",
"8":"CHIME",
"9":"XYLOPHONE",
"10":"IRON_XYLOPHONE",
"11":"COW_BELL",
"12":"DIDGERIDOO",
"13":"BIT",
"14":"BANJO",
"15":"PLING"
},
"lowercase":{
"0":"harp",
"1":"basedrum",
"2":"snare",
"3":"hat",
"4":"bass",
"5":"flute",
"6":"bell",
"7":"guitar",
"8":"chime",
"9":"xylophone",
"10":"iron_xylophone",
"11":"cow_bell",
"12":"didgeridoo",
"13":"bit",
"14":"banjo",
"15":"pling"
},
"reverse_lowercase":{
"harp":"0",
"basedrum":"1",
"snare":"2",
"hat":"3",
"bass":"4",
"flute":"5",
"bell":"6",
"guitar":"7",
"chime":"8",
"xylophone":"9",
"iron_xylophone":"10",
"cow_bell":"11",
"didgeridoo":"12",
"bit":"13",
"banjo":"14",
"pling":"15"
},
"blocks": {
"0": "dirt (any)",
"1": "stone",
"2": "sand",
"3": "glass",
"4": "wood",
"5": "clay",
"6": "gold block",
"7": "wool",
"8": "packed ice",
"9": "bone block",
"10": "iron block",
"11": "soul sand",
"12": "pumpkin",
"13": "emerald block",
"14": "hay bale",
"15": "glowstone"
}
}

View file

@ -0,0 +1 @@
{}

15
SandCatBot/logs/1637338289.log Executable file
View file

@ -0,0 +1,15 @@
[INFO]: Started logging...
0 [Warning] onItemPlace handler was registered twice for redstone_torch
November 19th 2021, 11:11:30 [Warning] onItemPlace handler was registered twice for repeater
November 19th 2021, 11:11:30 [Warning] onItemPlace handler was registered twice for oak_sign
November 19th 2021, 11:11:30 [Warning] onItemPlace handler was registered twice for spruce_sign
November 19th 2021, 11:11:30 [Warning] onItemPlace handler was registered twice for birch_sign
November 19th 2021, 11:11:30 [Warning] onItemPlace handler was registered twice for acacia_sign
November 19th 2021, 11:11:30 [Warning] onItemPlace handler was registered twice for jungle_sign
November 19th 2021, 11:11:30 [Warning] onItemPlace handler was registered twice for dark_oak_sign
November 19th 2021, 11:11:30 [INFO]: Server listening on port 25565
November 19th 2021, 11:11:30 seed: 1881458950
November 19th 2021, 12:48:27 [ERR]: Command not found
November 19th 2021, 12:48:34 [ERR]: Command not found
November 19th 2021, 12:48:50 [ERR]: Command not found
November 19th 2021, 12:48:56 [ERR]: Command not found

3
SandCatBot/logs/1637356429.log Executable file
View file

@ -0,0 +1,3 @@
[INFO]: Started logging...
November 19th 2021, 16:13:50 seed: 1881458950
November 19th 2021, 16:16:56 [ERR]: Command not found

4
SandCatBot/logs/1637359167.log Executable file
View file

@ -0,0 +1,4 @@
[INFO]: Started logging...
November 19th 2021, 16:59:28 seed: 1881458950
November 19th 2021, 17:00:51 [ERR]: Command not found
November 19th 2021, 17:01:03 [CHAT]: [Server] susi

6
SandCatBot/logs/1637539942.log Executable file
View file

@ -0,0 +1,6 @@
[INFO]: Started logging...
November 21st 2021, 19:12:23 seed: 1881458950
November 21st 2021, 19:13:10 [ERR]: Command not found
November 21st 2021, 19:13:20 [ERR]: Command not found
November 21st 2021, 19:13:22 [CHAT]: [Server] @a
November 21st 2021, 19:13:31 [ERR]: Command not found

2
SandCatBot/logs/1637994811.log Executable file
View file

@ -0,0 +1,2 @@
[INFO]: Started logging...
November 27th 2021, 01:34:07 seed: 1881458950

2
SandCatBot/logs/1638219840.log Executable file
View file

@ -0,0 +1,2 @@
[INFO]: Started logging...
November 29th 2021, 16:06:31 seed: 1881458950

4
SandCatBot/logs/1638479965.log Executable file
View file

@ -0,0 +1,4 @@
[INFO]: Started logging...
December 2nd 2021, 16:19:27 seed: 1881458950
December 2nd 2021, 16:20:38 [ERR]: Command not found
December 2nd 2021, 16:20:55 [ERR]: Command not found

3
SandCatBot/logs/1638482330.log Executable file
View file

@ -0,0 +1,3 @@
[INFO]: Started logging...
December 2nd 2021, 16:58:51 seed: 1881458950
December 2nd 2021, 16:59:28 [ERR]: Command not found

2
SandCatBot/logs/1638553982.log Executable file
View file

@ -0,0 +1,2 @@
[INFO]: Started logging...
December 3rd 2021, 12:53:25 seed: 1881458950

81
SandCatBot/logs/1638554031.log Executable file
View file

@ -0,0 +1,81 @@
[INFO]: Started logging...
December 3rd 2021, 12:54:21 seed: 1881458950
December 3rd 2021, 12:54:21 seed: 1881458950
December 3rd 2021, 12:54:21 seed: 1881458950
December 3rd 2021, 12:54:21 seed: 1881458950
December 3rd 2021, 12:54:21 seed: 1881458950
December 3rd 2021, 12:54:21 seed: 1881458950
December 3rd 2021, 12:54:21 seed: 1881458950
December 3rd 2021, 12:54:21 seed: 1881458950
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for redstone_torch
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for repeater
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for oak_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for spruce_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for acacia_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for birch_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for jungle_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for dark_oak_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for redstone_torch
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for repeater
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for oak_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for spruce_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for birch_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for acacia_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for jungle_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for dark_oak_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for redstone_torch
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for repeater
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for oak_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for spruce_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for birch_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for acacia_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for jungle_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for dark_oak_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for redstone_torch
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for repeater
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for oak_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for spruce_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for birch_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for acacia_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for jungle_sign
December 3rd 2021, 12:54:22 [Warning] onItemPlace handler was registered twice for dark_oak_sign
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for redstone_torch
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for repeater
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for oak_sign
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for spruce_sign
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for birch_sign
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for acacia_sign
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for jungle_sign
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for dark_oak_sign
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for redstone_torch
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for repeater
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for oak_sign
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for spruce_sign
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for birch_sign
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for acacia_sign
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for jungle_sign
December 3rd 2021, 12:54:23 [Warning] onItemPlace handler was registered twice for dark_oak_sign
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for redstone_torch
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for repeater
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for oak_sign
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for spruce_sign
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for birch_sign
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for acacia_sign
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for jungle_sign
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for dark_oak_sign
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for redstone_torch
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for repeater
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for oak_sign
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for spruce_sign
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for birch_sign
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for acacia_sign
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for jungle_sign
December 3rd 2021, 12:54:24 [Warning] onItemPlace handler was registered twice for dark_oak_sign
December 3rd 2021, 12:54:24 [INFO]: Server listening on port 31224
December 3rd 2021, 12:54:24 [INFO]: Server listening on port 25609
December 3rd 2021, 12:54:24 [INFO]: Server listening on port 39060
December 3rd 2021, 12:54:24 [INFO]: Server listening on port 1180
December 3rd 2021, 12:54:24 [INFO]: Server listening on port 60396
December 3rd 2021, 12:54:24 [INFO]: Server listening on port 60311
December 3rd 2021, 12:54:24 [INFO]: Server listening on port 16086
December 3rd 2021, 12:54:24 [INFO]: Server listening on port 24070

2
SandCatBot/logs/1638556755.log Executable file
View file

@ -0,0 +1,2 @@
[INFO]: Started logging...
December 3rd 2021, 13:39:17 seed: 1881458950

0
SandCatBot/logs/1638576598.log Executable file
View file

4
SandCatBot/logs/1638996615.log Executable file
View file

@ -0,0 +1,4 @@
[INFO]: Started logging...
December 8th 2021, 15:50:17 seed: 1881458950
December 8th 2021, 15:50:42 [INFO]: bot6447 (::ffff:127.0.0.1) connected
December 8th 2021, 15:50:42 [INFO]: position written, player spawning...

4
SandCatBot/logs/1638996721.log Executable file
View file

@ -0,0 +1,4 @@
[INFO]: Started logging...
December 8th 2021, 15:52:01 seed: 1881458950
December 8th 2021, 15:52:12 [INFO]: bot3110 (::ffff:127.0.0.1) connected
December 8th 2021, 15:52:12 [INFO]: position written, player spawning...

4
SandCatBot/logs/1638996748.log Executable file
View file

@ -0,0 +1,4 @@
[INFO]: Started logging...
December 8th 2021, 15:52:28 seed: 1881458950
December 8th 2021, 15:52:48 [INFO]: e (::ffff:127.0.0.1) connected
December 8th 2021, 15:52:49 [INFO]: position written, player spawning...

0
SandCatBot/logs/1638996980.log Executable file
View file

5
SandCatBot/logs/1638997194.log Executable file
View file

@ -0,0 +1,5 @@
December 8th 2021, 16:00:28 seed: 1881458950
December 8th 2021, 16:00:29 seed: 1881458950
December 8th 2021, 16:00:29 seed: 1881458950
December 8th 2021, 16:00:29 seed: 1881458950
December 8th 2021, 16:00:29 seed: 1881458950

View file

@ -0,0 +1,16 @@
[INFO]: Started logging...
Warning] onItemPlace handler was registered twice for repeater
March 10th 2022, 19:29:27 [Warning] onItemPlace handler was registered twice for oak_sign
March 10th 2022, 19:29:27 [Warning] onItemPlace handler was registered twice for spruce_sign
March 10th 2022, 19:29:27 seed: 1881458950
March 10th 2022, 19:29:40 [ERR]: Command not found
March 10th 2022, 19:29:41 [ERR]: Command not found
March 10th 2022, 19:29:42 [ERR]: Command not found
March 10th 2022, 19:29:42 [ERR]: Command not found
March 10th 2022, 19:29:43 [ERR]: Command not found
March 10th 2022, 19:29:43 [ERR]: Command not found
March 10th 2022, 19:29:43 [ERR]: Command not found
March 10th 2022, 19:29:44 [ERR]: Command not found
March 10th 2022, 19:29:45 [ERR]: Command not found
March 10th 2022, 19:29:45 [ERR]: Command not found
March 10th 2022, 19:29:49 [CHAT]: [Server] sus

View file

@ -0,0 +1,3 @@
[INFO]: Started logging...
Warning] onItemPlace handler was registered twice for spruce_sign
March 10th 2022, 22:23:38 seed: 1881458950

View file

@ -0,0 +1,174 @@
[INFO]: Started logging...
May 23rd 2022, 23:55:13 seed: 1881458950
May 23rd 2022, 23:55:13 seed: 1881458950
May 23rd 2022, 23:55:28 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:28 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:28 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:28 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:28 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:28 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:28 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:28 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:28 [INFO]: Server listening on port 1731
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:29 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:30 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:31 [Warning] onItemPlace handler was registered twice for redstone_torch
May 23rd 2022, 23:55:31 [Warning] onItemPlace handler was registered twice for repeater
May 23rd 2022, 23:55:31 [Warning] onItemPlace handler was registered twice for oak_sign
May 23rd 2022, 23:55:31 [Warning] onItemPlace handler was registered twice for spruce_sign
May 23rd 2022, 23:55:31 [Warning] onItemPlace handler was registered twice for birch_sign
May 23rd 2022, 23:55:31 [Warning] onItemPlace handler was registered twice for acacia_sign
May 23rd 2022, 23:55:31 [Warning] onItemPlace handler was registered twice for jungle_sign
May 23rd 2022, 23:55:31 [Warning] onItemPlace handler was registered twice for dark_oak_sign
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 28067
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 25602
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 61433
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 20903
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 58676
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 15107
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 50002
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 57549
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 41526
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 6828
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 54108
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 36741
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 27700
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 42490
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 21610
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 57429
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 23892
May 23rd 2022, 23:55:31 [INFO]: Server listening on port 49637

329
SandCatBot/miditonotebot.js Normal file
View file

@ -0,0 +1,329 @@
var { Midi } = require("@tonejs/midi");
var { isValidFile } = require("./parser.js");
var fs = require("fs");
var compiledTracks = [];
var timeConstant = (5 / 3) * 12;// 20
var midi;
/*
Note structure:
{
midi: 70,
velocity: 0.7559055118110236,
noteOffVelocity: 0,
ticks: 82016,
durationTicks: 480
}
*/
function fixFileName(f) {
if (f.includes("/")) {
var len = f.split("/").length;
f = f.split("/")[len - 1];
}
return f.replace(".midi", "").replace(".mid", "");
}
function toNotebot(midiFile, cb) {
if (!isValidFile(midiFile) || midiFile.indexOf(".mid") == -1) {
throw new Error(`${midiFile} is a invalid file!`);
}
var midiFileName = fixFileName(midiFile);//for output later
var midiData = fs.readFileSync(midiFile);
try {
midi = new Midi(midiData);
} catch(e) {
cb(undefined, e);
return;
}
console.log(`Converting Midi file ${midi.name == "" ? midiFile : midi.name} to notebot format`);
compileMIDI(midi);
var lines = [];
for (var i = 0; i < compiledTracks.length; i++) {
for (var j = 0; j < compiledTracks[i].length; j++) {
lines.push(compiledTracks[i][j]);
}
}
var finalString = "";
for (var i = 0; i < lines.length; i++) {
finalString += lines[i] + (i === lines.length - 1 ? "" : "\n");
}
var songout = "./songs/" + midiFileName + ".txt";
fs.writeFileSync(songout, finalString);
console.log("Done! wrote song to ./songs/" + midiFileName + ".txt");
fs.unlink(midiFile, () => {});
midi = undefined;
compiledTracks = undefined;
finalString = "";
cb(songout);
}
module.exports.toNotebot = toNotebot;
function isPercussion(channel) {
return channel == 10; //channel 10 reserved for percussion
}
function compileMIDI(midi) {
compiledTracks = [];
for (var i = 0; i < midi.tracks.length; i++) {
compiledTracks[i] = [];
}
for (var i = 0; i < midi.tracks.length; i++) {
if (midi.tracks[i].notes.length == 0) {// no notes
console.log(`skipping midi track ${midi.tracks[i].name} (track: ${i}) due to no notes`)
continue;
}
// then loop through again to compile
if (curInstrument !== null) {
for (var j = 0; j < midi.tracks[i].notes.length; j++) {
var curInstrument = getMinecraftInstrument(midi.tracks[i].instrument.number, midi.tracks[i], 0, midi.tracks[i].notes[i] == undefined ? undefined : midi.tracks[i].notes[i].midi);
compileNoteFromTrack(i, j, curInstrument);
}
}
}
}
function compileNoteFromTrack(trackNum, curNote, curInstrument) {
if (midi.tracks[trackNum].notes[curNote] == undefined)
return;
// done playing this track
var noteTime = Math.floor(midi.tracks[trackNum].notes[curNote].time * timeConstant); //convert seconds to minecraft ticks
if (isPercussion(midi.tracks[trackNum].channel)) {
// has to check this again for every note if this track is percussion because percussion can use different notes for different drums
var useInstrument = getMinecraftInstrument(midi.tracks[trackNum].instrument.number, midi.tracks[trackNum], curNote);
} else {
var useInstrument = curInstrument;
}
if (useInstrument == undefined)
return;
compiledTracks[trackNum].push(`${noteTime}:${convertNote(midi.tracks[trackNum].notes[curNote].midi, midi.tracks[trackNum])}:${useInstrument}`);
}
function convertNote(noteVal, midiTrack) {
if(isPercussion(midiTrack.channel)) return 0;
if(noteVal >= 30 && noteVal <= 54) {
return noteVal - 30;
} else if(noteVal >= 54 && noteVal <= 78) {
return noteVal - 54;
} else if(noteVal >= 78 && noteVal <= 102) {
return noteVal - 78;
} else {
return 0; // deafult to 0 if unknown
}
}
function getMinecraftInstrument(instrumentNumber, midiTrack, drumNoteNumber, midiPitch) {
if (isPercussion(midiTrack.channel)) {
if (midiTrack.notes.length > 0) {
var drumId = midiTrack.notes[drumNoteNumber].midi;
// TODO: drumid 24-34 & 82-87
// https://jazz-soft.net/demo/GeneralMidiPerc.html
if (drumId == 35 || drumId == 36 || drumId == 41 || drumId == 43
|| drumId == 45 || drumId == 47 || drumId == 48 || drumId == 50
|| drumId == 58) return 1; //basedrum
if (drumId == 37 || drumId == 38 || drumId == 40 || drumId == 49
|| drumId == 56 || drumId == 60 || drumId == 61 || drumId == 67
|| drumId == 68 || drumId == 70 || drumId == 78 || drumId == 79) return 2; //snare
if (drumId == 39 || drumId == 42 || drumId == 44 || drumId == 46
|| drumId == 51 || drumId == 52 || drumId == 53 || drumId == 54
|| drumId == 55 || drumId == 57 || drumId == 59 || drumId == 62
|| drumId == 63 || drumId == 64 || drumId == 65 || drumId == 66
|| drumId == 69 || drumId == 71 || drumId == 72 || drumId == 73
|| drumId == 74 || drumId == 75 || drumId == 76 || drumId == 77
|| drumId == 80 || drumId == 81) return 3; //hat
// default to basedrum if nothing found
return 1; //basedrum
}
}
//normal midi instruments https://jazz-soft.net/demo/GeneralMidi.html
var MCInstrument = 0;
if (midiPitch != undefined) {//TODO: make this a bit smaller/less if statements
/* reference:
if (midiPitch >= 30 && midiPitch <= 54) {//low (bass, digeridoo)
MCInstrument = 0;
} else if (midiPitch >= 54 && midiPitch <= 78) {//medium (harp, iron xylophone, bit, banjo, pling)
MCInstrument = 0;
} else if (midiPitch >= 78 && midiPitch <= 102) {//high (bells, chimes, xylophone)
MCInstrument = 0;
} */
if (instrumentNumber >= 0 && instrumentNumber <= 7) {// Piano
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 4; //bass
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 0; //harp
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bells
}
} else if (instrumentNumber >= 8 && instrumentNumber <= 15) {// Chromatic Percussion
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 4; //bass
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 10; //iron xylophone
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 9; // xylophone
}
} else if (instrumentNumber >= 16 && instrumentNumber <= 23) {// Organ
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 13; //bit
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} else if (instrumentNumber >= 24 && instrumentNumber <= 31) {// Guitar
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 13; //bit
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} else if (instrumentNumber >= 32 && instrumentNumber <= 39) {// Bass
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 13; //bit
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} else if (instrumentNumber >= 40 && instrumentNumber <= 47) {// Strings
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 13; //bit
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} else if (instrumentNumber >= 48 && instrumentNumber <= 55) { // Ensemble
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 13; //bit
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} else if (instrumentNumber >= 56 && instrumentNumber <= 63) {// Brass
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 13; //bit
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} else if (instrumentNumber >= 64 && instrumentNumber <= 71) {// Reed
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 13; //bit
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} else if (instrumentNumber >= 72 && instrumentNumber <= 79) {// Pipe
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 13; //bit // maybe flute in the future
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} else if (instrumentNumber >= 80 && instrumentNumber <= 87) {// Synth Lead
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 13; //bit
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} else if (instrumentNumber >= 88 && instrumentNumber <= 95) {// Synth Pad
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 13; //bit
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} else if (instrumentNumber >= 96 && instrumentNumber <= 103) {// Synth Effects
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 13; //bit
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} else if (instrumentNumber >= 104 && instrumentNumber <= 111) {// Ethnic
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 13; //bit
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} else if (instrumentNumber >= 112 && instrumentNumber <= 119) {// Percussive
if (midiPitch >= 30 && midiPitch <= 54) {
MCInstrument = 12; //digeridoo
} else if (midiPitch >= 54 && midiPitch <= 78) {
MCInstrument = 10; //iron xylophone
} else if (midiPitch >= 78 && midiPitch <= 102) {
MCInstrument = 6; //bell
}
} /*else if (instrumentNumber >= 120 && instrumentNumber <= 127) {// Sound Effects
if (midiPitch >= 30 && midiPitch <= 54) {//low (bass, digeridoo)
MCInstrument = 0;
} else if (midiPitch >= 54 && midiPitch <= 78) {//medium (harp, iron xylophone, bit, banjo, pling)
MCInstrument = 0;
} else if (midiPitch >= 78 && midiPitch <= 102) {//high (bells, chimes, xylophone)
MCInstrument = 0;
}
}*/ // very unlikley to see in a midi file so just be harp...
}
// default to harp if nothing found
return MCInstrument; //harp
}

28
SandCatBot/online_mode.js Executable file
View file

@ -0,0 +1,28 @@
const config = require("./config.json");
const enabled = config.online_mode.enabled;
const accounts = config.online_mode.accounts;
let accountsUsed = 0;
const getEnabled = _ => {
return enabled;
}
const getAccount = (item = accountsUsed) => {
const num = item;
//if (num > accounts.length) num = 0;
return accounts[num].split(':') || ['bot', null];
}
const getAccountsUsed = _ => {
return accountsUsed;
}
const incAccountsUsed = (amount = 1) => {
accountsUsed += amount;
}
module.exports.getEnabled = getEnabled;
module.exports.getAccount = getAccount;
module.exports.getAccountsUsed = getAccountsUsed;
module.exports.incAccountsUsed = incAccountsUsed;

2251
SandCatBot/package-lock.json generated Executable file

File diff suppressed because it is too large Load diff

11
SandCatBot/package.json Executable file
View file

@ -0,0 +1,11 @@
{
"dependencies": {
"@tonejs/midi": "^2.0.27",
"flying-squid": "^1.4.0",
"fs": "^0.0.1-security",
"mineflayer": "^3.11.2",
"sleep": "^6.3.0",
"system-sleep": "^1.3.7",
"vec3": "^0.1.7"
}
}

462
SandCatBot/parser.js Normal file
View file

@ -0,0 +1,462 @@
var fs = require("fs");
var util = require("./util.js");
var instruments_map = require("./instruments_map.json");
var config = require("./config.json");
var indexjs = require("./index.js");
var handler = require("./command-handler.js");
var playing = false;
var tuning = false;
var interval = null;
var nowPlaying = {
"song_name": undefined,
"time": {
"current": -1,
"full": -1
},
"url": undefined,
"addedBy": undefined
};
var cancelTune = false;
var cancelPlay = false;
function resetNowPlaying() {
nowPlaying = {
"song_name": undefined,
"time": {
"current": -1,
"full": -1
},
"url": undefined,
"addedBy": undefined
};
}
function isValidFile(file) {
if(file == null) return false;
return fs.existsSync(file) && fs.statSync(file).isFile();
}
function parse(file) {
if (!isValidFile(file)) {
console.log(`File ${file} is not a valid file!`);
return null;
}
let data = fs.readFileSync(file).toString();
if (data == null || typeof(data) != "string")
return null;
data = data.split("\n").map(line => line.replace(/\r/, ""));
/*data = data.filter(line => {
if (line == null) return false;
let split = line.split(":");
try {
let tick = parseInt(split[0]);
let pitch = parseInt(split[1]);
let instrument = parseInt(split[2]);
return tick != null && pitch != null && instrument != null;
} catch(e) {
return false;
}
});*/
let parsed = [];
data.forEach((line) => {
let split = line.split(":");
if(split[0] == null || split[1] == null || split[2] == null) return;
let tick = parseInt(split[0]);
let pitch = parseInt(split[1]);
let instrument = parseInt(split[2]);
parsed.push({tick, pitch, instrument});
});
return parsed;
}
function songInfo(file) {
if (!isValidFile(file)) {
console.log(`Error: ${file} is invalid!`);
return null;
}
// lines shit
let lines = fs.readFileSync(file)
if (lines instanceof Buffer) lines = lines.toString();
if (lines == null || typeof(lines) != "string") return null;
lines = lines.split("\n").map(line => line.replace(/\r/, ""));
//filter out bad lines
lines = lines.filter(line => {
if (line == null) return false;
let split = line.split(":");
let tick = split[0];
let pitch = split[1];
let instrument = split[2];
return !(isNaN(tick) || pitch < 0 || pitch > 24 || instrument < 0 || instrument > 15);
});
if (lines.length == 0) {
console.log(`Error: ${file} is invalid!`);
return null;
}
let used_pitches = [];
let used_instruments = [];
let noteblocks_list = [];
let noteblocksByInstrument = {};
let songlength = 0;
lines.forEach(line => {
let split = line.split(":");
if(split[0] == undefined || split[1] == undefined || split[2] == undefined) return;
let tick = parseInt(split[0]);
let pitch = parseInt(split[1]);
let instrument = parseInt(split[2]);
if (!used_pitches.includes(pitch))
used_pitches.push(pitch);
if (!used_instruments.includes(instrument))
used_instruments.push(instrument);
if (noteblocks_list.filter(obj => obj.pitch == pitch && obj.instrument == instrument).length == 0)
noteblocks_list.push({pitch, instrument});
if (noteblocksByInstrument[instrument] == null)
noteblocksByInstrument[instrument] = [instrument];
else if (!noteblocksByInstrument[instrument].includes(pitch))
noteblocksByInstrument[instrument].push(pitch);
if (tick > songlength)
songlength = tick;
});
return {
used_pitches,
used_instruments,
noteblocks_list,
noteblocksByInstrument,
minimunNoteblocks: used_pitches.length,
songlength
};
}
function tuneNoteblocks(file, noteblocks_1, instruments_enabled = false, callback = null) {/*
tuning = true;
if(callback == null) callback = function(res, err) {if(res){console.log(res)} if(err){console.log(err)} };
if (!isValidFile(file)) {
if(file.toString().startsWith("http")) {
callback(undefined, `${file} appears to be a invalid notebot file, try ${handler.prefix}playurl`); //Tells the user to use the playurl command if it starts with "http"
}
callback(undefined, `The file ${file} could not be found!`);
tuning = false;
resetNowPlaying();
return;
}
var noteblocks = util.clone(noteblocks_1);
var info = songInfo(file);
if(info == null) {
callback(undefined, `Failed to get songinfo for ${file}`);
tuning = false;
resetNowPlaying();
return;
}
if (noteblocks.length < info.minimunNoteblocks) {
callback(undefined, `${file} needs atleast ${info.minimunNoteblocks} noteblocks, ${info.minimunNoteblocks - noteblocks.length} are missing`);
tuning = false;
resetNowPlaying();
return;
}
var pitches = info.used_pitches;
var tuned = [];
var untuned = [];
var tuneLater = [];
var nbByInst = info.noteblocksByInstrument;
if(!instruments_enabled) {
noteblocks.forEach((noteblock) => {
if (pitches.includes(noteblock.pitch) && !tuned.includes(noteblock)) {
tuned.push(noteblock);
util.remove(noteblocks, noteblock);
}
if(pitches.length == 0) {
tuning = false;
callback("Done tuning!", undefined);
return;
}
});
} else {
noteblocks.forEach((noteblock) => {
if (nbByInst[noteblock.instrumentid] == null) return;
if(nbByInst[noteblock.instrumentid].includes(noteblock.pitch)) {
tuned.push(noteblock);
var idx = nbByInst[noteblock.instrumentid].indexOf(noteblock.pitch);
nbByInst[noteblock.instrumentid].splice(idx, 1);
} else {
untuned.push(noteblock);
}
});
untuned.forEach((noteblock) => {
if (nbByInst[noteblock.instrumentid].length > 0 && !tuned.includes(noteblock)) {
let pitch = nbByInst[noteblock.instrumentid].shift();
tuneLater.push({noteblock, pitch});
}
})
var missing_instruments = Object.keys(nbByInst).map(key => nbByInst[key]).filter(instrument => instrument.length > 0);
if (missing_instruments.length > 0) {
let missing = {};
Object.keys(nbByInst).forEach(key => {
if (nbByInst[key].length > 0)
missing[key] = nbByInst[key].length;
});
let message = Object.keys(missing).map(key => {
return `&r${instruments_map.lowercase[key]}/&7${instruments_map.blocks[key]} &r(&c${missing[key]}&r)`;
}).join(", ");
console.log(`Missing Instruments: ${message}`);
callback(undefined, `Missing Instruments: ${util.colors(message)}`);
instruments_enabled = false;
}
}
*/
function next() {
/*if (instruments_enabled) {
if(tuneLater[0] == null) {*/
tuning = false;
cancelTune = false;
callback("Done tuning!", undefined);
return;
/*}
if (tuneLater[0].noteblock != null)
tuneNoteblock(tuneLater[0].noteblock, tuneLater[0].pitch, (success) => {
tuned.push(tuneLater[0].noteblock);
tuneLater.shift();
if(cancelTune) {
callback(undefined, undefined);
cancelTune = false;
tuning = false;
resetNowPlaying();
return;
}
if (tuneLater.length > 0) {
next();
} else {
tuning = false;
cancelTune = false;
callback("Done tuning!", undefined);
}
});
} else {
if(noteblocks[0] == null || pitches[0] == null) return;
tuneNoteblock(noteblocks[0], pitches[0], (success) => {
tuned.push(noteblocks[0]);
pitches.shift();
noteblocks.shift();
if(cancelTune) {
callback(undefined, undefined);
cancelTune = false;
tuning = false;
resetNowPlaying();
return;
}
if(pitches.length > 0) {
next();
} else {
tuning = false;
cancelTune = false;
callback("Done tuning!", undefined);
}
});
}
*/}
next();
}
function tuneNoteblock(block, pitch, callback) {
if(block == null) {
callback(false);
return;
}
if(block.pitch == pitch) {
callback(true);
return;
}
let play_times = 0;
if (pitch - block.pitch < 0)
play_times = 25-(block.pitch-pitch);
else
play_times = pitch-block.pitch;
var timeouts = []
for (i = 0; i < play_times; i++) {
if(cancelTune) {
for(i = 0; i < timeouts.length; i++) {
clearTimeout(timeouts[i]);
}
callback(false);
cancelTune = false;
tuning = false;
resetNowPlaying();
return;
}
timeouts[i] = setTimeout(() => {
indexjs.getBot()._client.write('block_place', {
location: block.position,
direction: 1,
hand: 0,
cursorX: 0.5,
cursorY: 0.5,
cursorZ: 0.5
});
}, config.settings.tune_speed*i);
if(i == play_times-1) {
setTimeout(() => {
callback(true);
}, config.settings.tune_speed*i);
}
}
block.pitch = pitch;
}
function timeConverter(duration) {
duration = duration * 50;//1 tick = 50ms
let milliseconds = parseInt((duration % 1000) / 100),
seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
return {
h: hours,
min: minutes,
sec: seconds,
ms: milliseconds
}
}
function play(bot, noteblocks, file) {
if (playing == true || tuning == true)
return false;
if (!isValidFile(file))
return false;
playing = true;
var parsed = parse(file);
var info = songInfo(file);
let tick = 0;
if(info !== null) {
nowPlaying.time.full = info.songlength;
}
interval = setInterval(function() {
if (interval != this) {
clearInterval(this);
return;
}
if (Object.keys(parsed).length <= 1) {
bot.chat(util.infoMessage(`Finished playing`));
clearInterval(this);
interval = null;
playing = false;
cancelPlay = false;
resetNowPlaying();
return;
}
parsed.forEach((note, i, arr) => {
if(cancelPlay) {
clearInterval(this);
cancelPlay = false;
playing = false;
resetNowPlaying();
return;
}
var foundBlock = null;
if (tick >= note.tick) {
/*noteblocks.forEach(noteblock => {
if (noteblock.pitch == note.pitch && noteblock.instrumentid == note.instrument) {
foundBlock = noteblock;
}
});
*/arr.splice(i, 1);/*
if(foundBlock == null) {
console.log("not found:", note);
} else {
playNoteblock(bot, foundBlock);
}*/
let floatingpitch = Math.pow(2, (note.pitch-12) / 12.0);
bot.chat(`/playsound block.note_block.${instruments_map.lowercase[note.instrument]} player @a ~ ~ ~ 2000000 ${floatingpitch}`);
}
});
tick++;
nowPlaying.time.current = tick;
}, 1000/20); // every tick = 50ms
}
function playNoteblock(bot, noteblock) {
bot._client.write('block_dig', {
status: 0,
location: noteblock.position,
face: 1
});
bot._client.write('block_dig', {
status: 1,
location: noteblock.position,
face: 1
});
}
module.exports.timeConverter = timeConverter;
module.exports.tuneNoteblocks = tuneNoteblocks;
module.exports.tuneNoteblock = tuneNoteblock;
module.exports.parse = parse;
module.exports.play = play;
module.exports.songInfo = songInfo;
module.exports.isValidFile = isValidFile;
module.exports.getNowPlaying = () => {return nowPlaying};
module.exports.editNowPlaying = (song_name, current, full, url, addedBy) => {
song_name != undefined ? nowPlaying.song_name = song_name : undefined;
current != undefined ? nowPlaying.time.current = current : undefined;
full != undefined ? nowPlaying.time.full = full : undefined;
url != undefined ? nowPlaying.url = url : undefined;
addedBy != undefined ? nowPlaying.addedBy = addedBy : undefined;
};
module.exports.isTuning = () => {return tuning};
module.exports.isPlaying = () => {return playing};
module.exports.setcancelTune = (b) => {cancelTune = b};
module.exports.setcancelPlay = (b) => {cancelPlay = b};

View file

@ -0,0 +1,90 @@
var https = require("https");
var http = require("http");
var fs = require('fs');
var config = require("./config.json");
var maxDownloadBytes = config.settings.max_download_bytes; //deafults to 10mb
function download(url, dest, cb) {
var file = null;
var httpOrHttps = https;
url.startsWith("https:") ? httpOrHttps = https : httpOrHttps = http;
var request = httpOrHttps.get(url, (response) => {
console.log("Download started! url: "+url);
var size;
try {
size = parseInt(response.headers["content-length"]);
} catch(e) {size = null;}
if(response.headers["content-disposition"] != null && dest == undefined) {//get name from headers if it exists
dest = "./"+response.headers["content-disposition"].toString().split("filename=")[1].replace(/\//g, "").replace(/\"/g, "").replace(/\'/g, "").replace(/\`/g, "");
}
if(dest == undefined || dest == "./") {
if(url.toLowerCase().endsWith(".mid") || url.toLowerCase().endsWith(".midi")) {
var split = url.split("/");
dest = "./"+split[split.length - 1];
} else {
dest = "./song.mid";
}
}
if(fs.existsSync(dest)) {
fs.unlinkSync(dest);
}
file = fs.createWriteStream(dest);
if (size != null) {
if (size > maxDownloadBytes) {
if (cb) cb(`File was too big max allowed ${formatBytes(maxDownloadBytes)} (${maxDownloadBytes}) Recieved ${formatBytes(size)} (${size}) [header]`);
request.abort();
fs.unlink(dest, () => { });
return;
}
}
response.on("data", (data) => {
size = 0;
size += data.length;
if (size > maxDownloadBytes) {
if (cb) cb(`File was too big max allowed ${formatBytes(maxDownloadBytes)} (${maxDownloadBytes}) Recieved ${formatBytes(size)} (${size}) [data.length]`);
request.abort();
fs.unlink(dest);
return;
}
}).pipe(file);
response.on("error", (err) => {
request.abort();
fs.unlink(dest, () => { });
if (cb) cb(err.message);
})
file.on("finish", () => {
file.close(() => {
cb(undefined, dest);
});
});
}).on("error", (err) => {
request.abort();
fs.unlink(dest, () => { });
if (cb) cb(err.message);
});
};
module.exports.download = download;
function formatBytes(bytes, decimals = 2) {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

536
SandCatBot/songs/mc.txt Normal file
View file

@ -0,0 +1,536 @@
25:10:0
25:10:4
25:13:0
25:10:0
25:10:4
25:13:0
49:12:4
49:12:4
73:15:0
73:13:4
73:20:0
73:15:0
73:13:4
73:20:0
97:17:4
97:17:4
121:12:0
121:15:4
121:15:0
121:12:0
121:15:4
121:15:0
145:13:4
145:13:4
169:15:0
169:19:0
169:8:4
169:15:0
169:19:0
169:8:4
217:13:0
217:10:0
217:10:4
217:17:0
217:13:0
217:10:0
217:10:4
217:17:0
241:12:4
241:12:4
265:20:0
265:15:0
265:24:0
265:13:4
265:20:0
265:15:0
265:24:0
265:13:4
289:17:4
289:17:4
313:15:0
313:12:0
313:19:0
313:15:4
313:15:0
313:12:0
313:19:0
313:15:4
337:13:4
337:13:4
362:19:0
362:15:0
362:8:4
362:22:0
362:19:0
362:15:0
362:8:4
362:22:0
409:13:0
409:10:0
409:10:4
409:17:0
409:13:0
409:10:0
409:10:4
409:17:0
433:12:4
433:12:4
457:20:0
457:15:0
457:13:4
457:24:0
457:20:0
457:15:0
457:13:4
457:24:0
482:17:4
482:17:4
506:15:0
506:12:0
506:19:0
506:15:4
506:15:0
506:12:0
506:19:0
506:15:4
530:13:4
530:13:4
554:19:0
554:15:0
554:22:0
554:8:4
554:19:0
554:15:0
554:22:0
554:8:4
602:13:0
602:10:0
602:17:0
602:10:4
602:13:0
602:10:0
602:17:0
602:10:4
626:12:4
626:15:0
626:12:4
626:15:0
638:17:0
638:17:0
650:20:0
650:15:0
650:12:0
650:13:4
650:20:0
650:15:0
650:12:0
650:13:4
674:17:4
674:17:4
686:8:0
686:8:0
691:10:0
691:10:0
698:15:0
698:12:0
698:15:4
698:19:0
698:15:0
698:12:0
698:15:4
698:19:0
722:13:4
722:13:4
734:12:0
734:12:0
740:15:0
740:15:0
746:19:0
746:15:0
746:8:4
746:10:0
746:19:0
746:15:0
746:8:4
746:10:0
794:13:0
794:10:0
794:10:4
794:17:0
794:13:0
794:10:0
794:10:4
794:17:0
806:20:0
806:20:0
818:17:0
818:12:4
818:17:0
818:12:4
830:15:0
830:15:0
841:20:0
841:15:0
841:12:0
841:13:4
841:20:0
841:15:0
841:12:0
841:13:4
865:17:4
865:17:4
877:8:0
877:8:0
883:10:0
883:10:0
889:15:0
889:12:0
889:7:0
889:15:4
889:15:0
889:12:0
889:7:0
889:15:4
914:13:4
914:13:4
925:15:0
925:15:0
931:12:0
931:12:0
938:19:0
938:15:0
938:8:4
938:22:0
938:19:0
938:15:0
938:8:4
938:22:0
985:13:0
985:10:0
985:10:4
985:17:0
985:13:0
985:10:0
985:10:4
985:17:0
1009:12:4
1009:15:0
1009:12:4
1009:15:0
1021:17:0
1021:17:0
1034:15:0
1034:24:0
1034:20:0
1034:13:4
1034:20:0
1034:15:0
1034:24:0
1034:20:0
1034:13:4
1034:20:0
1057:17:4
1057:17:4
1070:24:0
1070:8:0
1070:24:0
1070:8:0
1076:10:0
1076:22:0
1076:10:0
1076:22:0
1082:12:0
1082:15:0
1082:8:0
1082:19:0
1082:19:0
1082:15:4
1082:12:0
1082:15:0
1082:8:0
1082:19:0
1082:19:0
1082:15:4
1105:13:4
1105:13:4
1117:12:0
1117:20:0
1117:12:0
1117:20:0
1123:19:0
1124:19:0
1129:15:0
1129:22:0
1129:19:0
1129:15:0
1129:8:4
1129:15:0
1129:22:0
1129:19:0
1129:15:0
1129:8:4
1177:13:0
1177:10:0
1177:17:0
1177:10:4
1177:13:0
1177:10:0
1177:17:0
1177:10:4
1201:17:0
1201:12:4
1201:17:0
1201:12:4
1213:15:0
1213:15:0
1225:20:0
1225:15:0
1225:13:4
1225:12:0
1225:20:0
1225:15:0
1225:13:4
1225:12:0
1249:17:4
1249:17:4
1261:8:0
1261:8:0
1267:10:0
1267:10:0
1273:15:0
1273:12:0
1273:15:4
1273:7:0
1273:15:0
1273:12:0
1273:15:4
1273:7:0
1297:13:4
1297:13:4
1309:12:0
1309:12:0
1315:15:0
1315:15:0
1321:19:0
1321:15:0
1321:8:4
1321:10:0
1321:19:0
1321:15:0
1321:8:4
1321:10:0
1369:13:0
1369:10:0
1369:17:0
1369:10:4
1369:13:0
1369:10:0
1369:17:0
1369:10:4
1393:15:0
1393:12:4
1393:15:0
1393:12:4
1405:17:0
1405:17:0
1417:20:0
1417:15:0
1417:13:4
1417:12:0
1417:20:0
1417:15:0
1417:13:4
1417:12:0
1441:17:4
1441:17:4
1453:8:0
1453:8:0
1459:10:0
1459:10:0
1465:15:0
1465:12:0
1465:7:0
1465:15:4
1465:15:0
1465:12:0
1465:7:0
1465:15:4
1489:13:4
1489:13:4
1501:12:0
1501:12:0
1507:15:0
1507:15:0
1513:19:0
1513:15:0
1513:8:4
1513:10:0
1513:19:0
1513:15:0
1513:8:4
1513:10:0
1561:13:0
1561:10:0
1561:10:4
1561:17:0
1561:13:0
1561:10:0
1561:10:4
1561:17:0
1585:12:4
1585:15:0
1585:12:4
1585:15:0
1597:17:0
1597:17:0
1609:15:0
1609:24:0
1609:20:0
1609:13:4
1609:20:0
1609:15:0
1609:24:0
1609:20:0
1609:13:4
1609:20:0
1633:17:4
1633:17:4
1645:8:0
1645:8:0
1651:10:0
1651:10:0
1657:15:0
1657:12:0
1657:7:0
1657:15:4
1657:15:0
1657:12:0
1657:7:0
1657:15:4
1681:24:0
1681:13:4
1681:24:0
1681:13:4
1693:12:0
1693:12:0
1699:15:0
1699:15:0
1705:19:0
1705:15:0
1705:22:0
1705:8:4
1705:19:0
1705:15:0
1705:22:0
1705:8:4
1753:5:0
1753:12:0
1753:8:0
1753:17:4
1753:5:4
1753:5:0
1753:12:0
1753:8:0
1753:17:4
1753:5:4
1790:17:0
1790:17:0
1795:15:0
1795:15:0
1801:10:0
1801:17:0
1801:14:0
1801:10:4
1801:10:0
1801:10:0
1801:17:0
1801:14:0
1801:10:4
1801:10:0
1825:10:0
1825:10:0
1837:8:0
1837:8:0
1849:3:0
1849:15:0
1849:10:0
1849:3:4
1849:7:0
1849:3:0
1849:15:0
1849:10:0
1849:3:4
1849:7:0
1886:8:0
1886:8:0
1892:10:0
1892:10:0
1898:13:0
1898:8:0
1898:13:4
1898:5:0
1898:13:0
1898:8:0
1898:13:4
1898:5:0
1946:5:0
1946:8:0
1946:20:0
1946:12:0
1946:17:4
1946:5:4
1946:5:0
1946:8:0
1946:20:0
1946:12:0
1946:17:4
1946:5:4
1981:17:0
1981:17:0
1988:15:0
1988:15:0
1994:10:0
1994:17:0
1994:14:0
1994:10:0
1994:10:4
1994:10:0
1994:17:0
1994:14:0
1994:10:0
1994:10:4
2017:10:0
2017:10:0
2030:22:0
2030:8:0
2030:22:0
2030:8:0
2041:3:0
2041:10:0
2041:7:0
2041:15:0
2041:19:0
2041:3:4
2041:3:0
2041:10:0
2041:7:0
2041:15:0
2041:19:0
2041:3:4
2066:20:0
2066:20:0
2078:24:0
2078:8:0
2078:24:0
2078:8:0
2084:10:0
2084:10:0
2090:13:0
2090:8:0
2090:13:4
2090:17:0
2090:13:0
2090:8:0
2090:13:4
2090:17:0

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

2754
SandCatBot/songs/nyancat.txt Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

72
SandCatBot/util.js Executable file
View file

@ -0,0 +1,72 @@
let config = require("./config.json");
function colors(message) {
if (config.settings.colors_enabled == null) return message;
return (config.settings.colors_enabled) ? message/*.replace(/&/g, "§")*/ : message.replace(/&[0-9a-fk-or]/g, "");
}
function firstLetterUppercase(s) {
if(s == undefined) return "";
s = typeof s !== "string" ? s.toString() : s;
return s.charAt(0).toUpperCase()+s.slice(1);
}
function infoMessage(message) {
return colors(`&6INFO: &7${message}`);
}
function errorMessage(message) {
return colors(`&cError: ${message}`);
}
function wait(time) {
return new Promise((resolve, reject) => setTimeout(resolve, time));
}
function clone(arr) {
if (!(arr instanceof Array)) return null;
return arr.slice(0);
};
function Error(error, code = "unknown") {
return {status: "error", message: error, code: code};
}
function Success(message) {
return {status: "success", message: message};
}
function remove(array, elem) {
var index = array.indexOf(elem);
if (index > -1) {
array.splice(index, 1);
}
}
function random(from = 0, to = 1) {
let num = Math.random();
num *= to - from;
num += from;
return num;
//return (Math.random() * to - from + to); // is meant to be better but doesnt work lol
}
function randomizeUsername(options) {
options.username += '§'+Math.round(random(0, 9));
options.username += '§'+Math.round(random(0, 9));
options.username += '§'+Math.round(random(0, 9));
}
module.exports = {
colors: colors,
infoMessage: infoMessage,
errorMessage: errorMessage,
wait: wait,
clone: clone,
Error: Error,
Success: Success,
remove: remove,
firstLetterUppercase: firstLetterUppercase,
random: random,
randomizeUsername: randomizeUsername
};

BIN
SandCatBot/world/level.dat Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
SandCatBot/world/region/r.0.0.mca Executable file

Binary file not shown.

View file

@ -0,0 +1,56 @@
var instruments_map = require("./instruments_map.json");
function mapnoteblocks(bot) {
var result = [];
for (x = -4; x <= 4; x++) {
for (y = -4; y <= 4; y++) {
for (z = -4; z <= 4; z++) {
var pos = bot.blockAt(bot.entity.position.offset(x, y, z));
var blockAbove = bot.blockAt(bot.entity.position.offset(x, y + 1, z));
if (pos.name == "note_block" && (blockAbove.name == "air" || blockAbove.name == "cave_air" || blockAbove.name == "void_air")) {
var NBInfo = getNoteBlockInfo(pos);
pos.pitch = NBInfo.pitch == undefined ? 0 : NBInfo.pitch;
pos.instrumentid = NBInfo.instrumentid == undefined ? 0 : NBInfo.instrumentid;
result.push(pos);
}
}
}
}
return result;
}
// Thanks Quad
function noteblockInfoFromMetadata(metadata) {
var instrumentid = Math.floor(metadata / 50);
var pitch;
if ((metadata % 2) == 0) {
pitch = metadata / 2;
} else {
pitch = ((metadata - 1) / 2) + 1;
}
pitch = pitch - instrumentid * 25;
pitch = pitch - 1;
var instrument = instruments_map.lowercase[instrumentid];
return { instrument: instrument, instrumentid: instrumentid, pitch: pitch };
}
function getNoteBlockInfo(block) {
if (block == null) return console.log("Block was null!");
if (block.name == null || block.metadata == null) return console.log("Block name or metadata was null!");//should never happend
if (block.name != "note_block") return console.log("Expected name 'note_block' got " + block.name);
return noteblockInfoFromMetadata(block.metadata);
}
module.exports = {
mapnoteblocks,
getNoteBlockInfo,
noteblockInfoFromMetadata
};

View file

@ -0,0 +1,234 @@
var fs = require("fs");
var path = require("path");
var is_initilized = false;
var commands = {};
var categories = {};
//main functions
function load(prefix = "/", directory = "./commands") {
//setup global variable
this.prefix = prefix;
this.directory = directory;
//initiliaze command handler
let categories_ = [];
let aliases = [];
if (!isDirectory(directory))
fs.mkdirSync(directory);
if (categories["default"] == null)
categories["default"] = { enabled: true, commands: {} };
fs.readdirSync(directory).forEach(file => {
let absolute_path = path.resolve(`${directory}/${file}`);
if (isDirectory(absolute_path) && path.parse(absolute_path).name != "default") {
categories_.push(absolute_path);
return;
}
let required = loadCommand(absolute_path);
if (required == null)
return;
if (commands[required.name] == null) {
commands[required.name] = required;
categories[required.category].commands[required.name] = required;
}
if (required.aliases.length != 0)
aliases.push(required);
});
categories_.forEach(category => {
if (categories[path.parse(category).name] == null)
categories[path.parse(category).name] = { enabled: true, commands: {} };
fs.readdirSync(category).forEach(file => {
let absolute_path = path.resolve(`${category}/${file}`);
let required = loadCommand(absolute_path, path.parse(category).name);
if (required == null)
return;
if (commands[required.name] == null) {
commands[required.name] = required;
categories[required.category].commands[required.name] = required;
}
if (required.aliases.length != 0)
aliases.push(required);
});
});
aliases.forEach(command => {
command.aliases.forEach(alias => {
if (commands[alias] == null)
commands[alias] = command;
});
});
is_initilized = true;
}
function loadCommand(absolute_path, category = "default") {
if (!isFile(absolute_path) || path.parse(absolute_path).ext != ".js")
return;
let file = path.parse(absolute_path).base;
try {
let required = require(absolute_path);
if (!isValid(required)) {
console.log(`Command ${file} is invalid!`)
return;
}
required.path = absolute_path;
required.category = category;
return required;
} catch (err) {
console.log(`Couldnt load ${file}:\n ${err}`);
return;
}
}
function execute(bot, cmd, username, args, ...custom) {
if (!is_initilized)
return error(`The command ahndler was not initlized!`, "not_init");
if (!isCommand(cmd))
return error(`Invalid command ${cmd}!`, "invalid_command");
let cmd_info = info(cmd);
if (!cmd_info.enabled)
return error(`Command ${cmd} is currently disabled!`);
try {
let output = cmd_info.execute(bot, cmd, username, args, this, ...custom);
return success(output);
} catch (err) {
console.log(`Error while executing ${cmd} (args: [${args.join(", ")}])!`);
console.log(err.stack);
return error(`Error while executing the command!`);
}
}
function reload(command) {
if (!is_initilized)
return error(`The command ahndler was not initlized!`, "not_init");
if (command == null) {
try {
Object.keys(commands).forEach(key => {
let command = commands[key];
delete require.cache[command.path];
});
} catch (err) { }
commands = {};
categories = {};
load();
return success(`successfully reloaded all commands!`);
} else {
let cmd_info = info(command);
if (cmd_info == null)
return error(`${this.prefix}${command} doesnt exist or was not loaded before!`);
try {
let path = cmd_info.path;
let category = cmd_info.category;
let aliases = cmd_info.aliases;
aliases.forEach(alias => {
if (commands[alias] == cmd_info)
delete commands[alias];
});
delete commands[cmd_info.name];
delete categories[cmd_info.category].commands[cmd_info.name];
delete require.cache[cmd_info.path];
let required = loadCommand(path, category);
if (required == null)
return;
if (commands[required.name] == null) {
commands[required.name] = required;
categories[required.category].commands[required.name] = required;
}
if (required.aliases.length != 0) {
required.aliases.forEach(alias => {
if (commands[alias] == null)
commands[alias] = required;
});
}
return success(`Successfully reloaded ${this.prefix}${command}`);
} catch (err) {
console.log(`Error while realoding ${command}!`);
console.log(err.stack);
return error(`Couldn't reload ${this.prefix}${command}`, "reload_error");
}
}
}
//utility functions
function isCommand(command) {
return commands[command] != null;
}
function info(command) {
if (!isCommand(command))
return null;
return commands[command];
}
function getCategory(category) {
if (categories[category] != null && Object.keys(categories[category].commands).length == 0)
return null;
return categories[category];
}
function getCategories() {
return Object.keys(categories);
}
function success(message) {
return { status: "success", message };
}
function error(message, code = "unknown") {
return { status: "error", message, code };
}
function isFile(filePath) {
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
}
function isDirectory(filePath) {
return fs.existsSync(filePath) && fs.statSync(filePath).isDirectory();
}
function isValid(command) {
return command != null && typeof command.execute == "function" && typeof command.name == "string" && typeof command.description == "string" && typeof command.usage == "string" && typeof command.enabled == "boolean" && Array.isArray(command.aliases);
}
//module.exports
module.exports = load;
module.exports.reload = reload;
module.exports.execute = execute;
module.exports.isCommand = isCommand;
module.exports.getCategories = getCategories;
module.exports.getCategory = getCategory;
module.exports.info = info;
module.exports.prefix = "/";
module.exports.directory = "./commands";

View file

@ -0,0 +1,93 @@
var name = "addbot";
var aliases = ["ab"];
var description = "Adds a bot to the server.";
var usage = "{prefix}addbot <username>";
var enabled = true;
var fs = require('fs');
var path = require('path');
var mineflayer = require('mineflayer');
var util = require("./../../util.js");
var cmd_handler = require("./cmdhandler/command-handler.js");
function execute(bot, cmd, username, args, handler) {
const options = bot.options;
options.username = args[0] || `bot${Math.round(util.random(1000,9999))}`;
options.password = null;
const prevName = options.username;
const prevHost = options.host;
const prevPort = options.port;
if(args[1]) options.host = args[1];
if(args[2]) options.port = args[2];
const nBot = mineflayer.createBot(options);
cmd_handler();
nBot.on ('login', _ => {
//if (online_mode.getEnabled()) bot.chat(`/sudo `+nBot.username+` username `+prevName);
console.log('Added bot '+nBot.username+' successfully connected.');
nBot.chat(util.colors('&aConnected!'));
});
const handleChat = (username, message) => {
//console.log(`[chat] <${username}> ${message}`);
if (message.startsWith(cmd_handler.prefix)) {
let args = message.slice(cmd_handler.prefix.length).split(" ");
let command = args.shift();
if (cmd_handler.isCommand(command)) {
let output = cmd_handler.execute(nBot, command, username, args);
if (output.status == "success") {
if (typeof output.message == "string")
nBot.chat(util.infoMessage(output.message));
} else if (output.status == "error") {
if (typeof output.message == "string")
nBot.chat(util.errorMessage(output.message));
}
}
}
/*
if (message.startsWith(cmd_handler.prefix)) {
let args = message.split(" ");
let command = args.shift().slice(cmd_handler.prefix.length);
let output = cmd_handler.execute(command, username, args, bot)
if (output.status == "error") {
let error = output.message;
//let code = output.code;
bot.chat(util.errorMessage(error));
}
}
*/
}
nBot.on("chat", handleChat);
if (prevHost != options.host) {
bot.on("chat", handleChat);
}
nBot.on ('error', (err) => {
bot.chat(util.colors('&c'+err));
});
nBot.on ('kick', (err) => {
bot.chat(util.colors('&c'+err));
});
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,48 @@
var name = "addserver";
var aliases = ["as"];
var description = "Adds server.";
var usage = "{prefix}addserver";
var enabled = true;
var mcServer = require('flying-squid')
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
mcServer.createMCServer({
'motd': 'A Minecraft Server \nRunning flying-squid',
'port': Math.round(util.random(1025,65535)),
'max-players': 10,
'online-mode': false,
'logging': true,
'gameMode': 1,
'difficulty': 1,
'worldFolder':'world',
'generation': {
'name': 'diamond_square',
'options':{
'worldHeight': 80
}
},
'kickTimeout': 10000,
'plugins': {
},
'modpe': false,
'view-distance': 10,
'player-list-text': {
'header':'Flying squid',
'footer':'Test server'
},
'everybody-op': true,
'max-entities': 100,
'version': '1.16.1'
})
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,14 @@
var name = "chatasbot";
var aliases = [];
var description = "Chats as an added bot.";
var usage = "{prefix}chatAsBot <username> <message>";
var enabled = true;
function execute(bot, cmd, username, args, handler) { }
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,234 @@
var fs = require("fs");
var path = require("path");
var is_initilized = false;
var commands = {};
var categories = {};
//main functions
function load(prefix = "s!", directory = "./commands/addBot/commands") {
//setup global variable
this.prefix = prefix;
this.directory = directory;
//initiliaze command handler
let categories_ = [];
let aliases = [];
if (!isDirectory(directory))
fs.mkdirSync(directory);
if (categories["default"] == null)
categories["default"] = { enabled: true, commands: {} };
fs.readdirSync(directory).forEach(file => {
let absolute_path = path.resolve(`${directory}/${file}`);
if (isDirectory(absolute_path) && path.parse(absolute_path).name != "default") {
categories_.push(absolute_path);
return;
}
let required = loadCommand(absolute_path);
if (required == null)
return;
if (commands[required.name] == null) {
commands[required.name] = required;
categories[required.category].commands[required.name] = required;
}
if (required.aliases.length != 0)
aliases.push(required);
});
categories_.forEach(category => {
if (categories[path.parse(category).name] == null)
categories[path.parse(category).name] = { enabled: true, commands: {} };
fs.readdirSync(category).forEach(file => {
let absolute_path = path.resolve(`${category}/${file}`);
let required = loadCommand(absolute_path, path.parse(category).name);
if (required == null)
return;
if (commands[required.name] == null) {
commands[required.name] = required;
categories[required.category].commands[required.name] = required;
}
if (required.aliases.length != 0)
aliases.push(required);
});
});
aliases.forEach(command => {
command.aliases.forEach(alias => {
if (commands[alias] == null)
commands[alias] = command;
});
});
is_initilized = true;
}
function loadCommand(absolute_path, category = "default") {
if (!isFile(absolute_path) || path.parse(absolute_path).ext != ".js")
return;
let file = path.parse(absolute_path).base;
try {
let required = require(absolute_path);
if (!isValid(required)) {
console.log(`Command ${file} is invalid!`)
return;
}
required.path = absolute_path;
required.category = category;
return required;
} catch (err) {
console.log(`Couldnt load ${file}:\n ${err}`);
return;
}
}
function execute(bot, cmd, username, args, ...custom) {
if (!is_initilized)
return error(`The command ahndler was not initlized!`, "not_init");
if (!isCommand(cmd))
return error(`Invalid command ${cmd}!`, "invalid_command");
let cmd_info = info(cmd);
if (!cmd_info.enabled)
return error(`Command ${cmd} is currently disabled!`);
try {
let output = cmd_info.execute(bot, cmd, username, args, this, ...custom);
return success(output);
} catch (err) {
console.log(`Error while executing ${cmd} (args: [${args.join(", ")}])!`);
console.log(err.stack);
return error(`Error while executing the command!`);
}
}
function reload(command) {
if (!is_initilized)
return error(`The command ahndler was not initlized!`, "not_init");
if (command == null) {
try {
Object.keys(commands).forEach(key => {
let command = commands[key];
delete require.cache[command.path];
});
} catch (err) { }
commands = {};
categories = {};
load();
return success(`successfully reloaded all commands!`);
} else {
let cmd_info = info(command);
if (cmd_info == null)
return error(`${this.prefix}${command} doesnt exist or was not loaded before!`);
try {
let path = cmd_info.path;
let category = cmd_info.category;
let aliases = cmd_info.aliases;
aliases.forEach(alias => {
if (commands[alias] == cmd_info)
delete commands[alias];
});
delete commands[cmd_info.name];
delete categories[cmd_info.category].commands[cmd_info.name];
delete require.cache[cmd_info.path];
let required = loadCommand(path, category);
if (required == null)
return;
if (commands[required.name] == null) {
commands[required.name] = required;
categories[required.category].commands[required.name] = required;
}
if (required.aliases.length != 0) {
required.aliases.forEach(alias => {
if (commands[alias] == null)
commands[alias] = required;
});
}
return success(`Successfully reloaded ${this.prefix}${command}`);
} catch (err) {
console.log(`Error while realoding ${command}!`);
console.log(err.stack);
return error(`Couldn't reload ${this.prefix}${command}`, "reload_error");
}
}
}
//utility functions
function isCommand(command) {
return commands[command] != null;
}
function info(command) {
if (!isCommand(command))
return null;
return commands[command];
}
function getCategory(category) {
if (categories[category] != null && Object.keys(categories[category].commands).length == 0)
return null;
return categories[category];
}
function getCategories() {
return Object.keys(categories);
}
function success(message) {
return { status: "success", message };
}
function error(message, code = "unknown") {
return { status: "error", message, code };
}
function isFile(filePath) {
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
}
function isDirectory(filePath) {
return fs.existsSync(filePath) && fs.statSync(filePath).isDirectory();
}
function isValid(command) {
return command != null && typeof command.execute == "function" && typeof command.name == "string" && typeof command.description == "string" && typeof command.usage == "string" && typeof command.enabled == "boolean" && Array.isArray(command.aliases);
}
//module.exports
module.exports = load;
module.exports.reload = reload;
module.exports.execute = execute;
module.exports.isCommand = isCommand;
module.exports.getCategories = getCategories;
module.exports.getCategory = getCategory;
module.exports.info = info;
module.exports.prefix = "s!";
module.exports.directory = "./commands";

View file

@ -0,0 +1,26 @@
var name = "chatasbot";
var aliases = [];
var description = "Chats as an added bot.";
var usage = "{prefix}chatAsBot <username> <message>";
var enabled = true;
var util = require("./../../../../util.js");
function execute(bot, cmd, username, args, handler) {
if (bot.username !== args[0]) return
let chat = '';
for (let i = 1; i < args.length; i++) {
chat = chat + ' ' + args[i];
}
bot.chat(chat.trim());
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,22 @@
var name = "endbot";
var aliases = ["eb"];
var description = "Ends added bot.";
var usage = "{prefix}endbot <username>";
var enabled = true;
var util = require("./../../../../util.js");
function execute(bot, cmd, username, args, handler) {
if (bot.username !== args[0] && args[0] !== 'all') return
bot.chat(util.colors('Bye!'));
bot.end();
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,29 @@
var name = "reload";
var aliases = ["r"];
var description = "Reload a command";
var usage = "{prefix}reload";
var enabled = true;
var util = require("./../../../../util.js");
//var perms = require("./../../config.json").commands_perms;
function execute(bot, cmd, username, args, handler) {
/*if (!perms.includes(username) && username !== bot.username)
return bot.chat(util.errorMessage("No permission to use this command."));*/
let result = handler.reload(args[0]);
if (result.status == "success")
bot.chat(util.infoMessage(result.message));
else
bot.chat(util.errorMessage(result.message));
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,14 @@
var name = "endbot";
var aliases = ["eb"];
var description = "Ends added bot.";
var usage = "{prefix}endbot <username>";
var enabled = true;
function execute(bot, cmd, username, args, handler) { }
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,30 @@
var name = "entitypos";
var aliases = ["epos"];
var description = "Gets the pos of an entity.";
var usage = "{prefix}entitypos";
var enabled = true;
var util = require("./../../util.js");
var sleep = require("system-sleep");
function execute(bot, cmd, username, args, handler) {
bot.addChatPattern('pos', /.+\[(.+)d, (.+)d, (\S+)d]/, { parse: true, repeat: false });
bot.once('chat:pos', matches => {
const coords = `${matches[0]}`.split(',');
sleep(150);
bot.chat(`&aThe position of the entity ${args[0]} is: ${coords[0]}, ${coords[1]}, ${coords[2]}.`);
});
bot.chat(`/data get entity ${args[0]} Pos`);
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

View file

@ -0,0 +1,24 @@
var name = "entitytp2coords";
var aliases = ["entitytp2c","etp2c"];
var description = "Teleports an entity to coordinates.";
var usage = "{prefix}entitytp2coords <target> <x> <y> <z>";
var enabled = true;
var util = require("./../../util.js");
function execute(bot, cmd, username, args, handler) {
if (args.length !== 4) {
bot.chat(`&cUsage: ` + usage);
return;
}
bot.chat(`/execute as ${args[0]} run data merge entity @s {Pos:[ ${args[1]}d,${args[2]}d,${args[3]}d]}`);
}
module.exports.name = name;
module.exports.aliases = aliases;
module.exports.description = description;
module.exports.usage = usage;
module.exports.enabled = enabled;
module.exports.execute = execute;

Some files were not shown because too many files have changed in this diff Show more