radium-v2/index.js

328 lines
12 KiB
JavaScript
Raw Permalink Normal View History

2024-11-05 20:59:57 -05:00
async function main () {
function random(length) {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
let counter = 0;
while (counter < length) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
counter += 1;
}
return result;
};
2024-11-08 08:00:05 -05:00
function randomEscape (length) {
2024-11-05 20:59:57 -05:00
let result = '';
const characters = '\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f';
const charactersLength = characters.length;
let counter = 0;
while (counter < length) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
counter += 1;
}
return result;
};
const mc = require("minecraft-protocol");
const config = require("./config.json");
const sleep = require("system-sleep");
const fs = require("fs");
const ChatMessage = require("prismarine-chat")(config.version);
const rl = require("readline").createInterface(process.stdin, process.stdout);
var client = mc.createClient({
"host": process.argv[2].split(":")[0],
"port": parseInt(process.argv[2].split(":")[1]),
2024-11-08 08:00:05 -05:00
// "username": randomEscape(16),
"username": "radium_bot_",
2024-11-05 20:59:57 -05:00
"version": config.version
})
client.trusted = [];
client.owner = [];
client.hitlist = [
".*Lennox.*",
".*Lennxx.*",
"Reggy120",
"RayWZW",
"_NotVoid",
"WorstBot",
"StalkerMan",
"StalkerBot",
"WORST BOT",
"McPlayer9966",
"TalkToMe",
"Pan_Poppo",
"NekosAreKawaii",
"ToxicKalmatar",
"Oskar.*",
"00sskkaarr22",
"0x.*",
"KU7sSzhd",
"Fatih",
"ClooperBot175",
"glitchkiller8721",
"ChomeNS Bot",
"eritig48",
"LisaTelnet",
"emirexyt192",
"TYrie29",
"kiarash11010",
"32mg",
"zXzy",
"im.zxzy",
"realzxzy_",
"zxz",
"crayonNukr",
"§§Loader§§",
"SohnasPacket",
"WhispererDodgy",
"GroxMC",
"1493028",
"obfuscators",
"nukerbot",
"gemini",
"Cloud!",
"ttproxy",
"x25",
".*NOTgod.*",
".*yoinkies.*",
".*CaydennO1[aA-zZ].*",
".*Caydenn.*"
];
client.doMuteFilter = false;
client.host = process.argv[2].split(":")[0];
client.port = parseInt(process.argv[2].split(":")[1]);
function createHash(hashType) {
switch (hashType) {
case "trusted":
client.trustedHash = random(Math.floor(Math.random() * (15 - 10) + 10));
console.log(`\x1b[107m\x1b[30m${client.host}:${client.port} Trusted Hash: ${client.trustedHash}\x1b[0m`);
break;
case "owner":
client.ownerHash = random(Math.floor(Math.random() * (25 - 20) + 20));
console.log(`\x1b[107m\x1b[30m${client.host}:${client.port} Owner Hash: ${client.ownerHash}\x1b[0m`);
break;
}
}
client.createHash = createHash;
createHash("trusted");
createHash("owner");
rl.on("line", function (line) {
if (!String(line).startsWith("§loghash")) {
client.chat(line);
} else {
console.log(`\x1b[107m\x1b[30m${client.host}:${client.port} Trusted Hash: ${client.trustedHash}\x1b[0m`);
console.log(`\x1b[107m\x1b[30m${client.host}:${client.port} Owner Hash: ${client.ownerHash}\x1b[0m`);
}
})
for (const plugin in config.plugins) {
try {
require(`./plugins/${config.plugins[plugin]}`).inject(client);
} catch (err) {
if (err.toString().startsWith("Error: Cannot find module")) {
throw new client.PluginError(`Cannot find plugin "${config.plugins[plugin]}"`);
} else {
throw new client.PluginError(`Error while loading plugin "${config.plugins[plugin]}": "${err}"`);
}
}
}
client.on("entity_status", function (packet) {
if (packet.entityStatus < 24 || packet.entityStatus > 28) return;
if (packet.entityStatus - 24 <= 0) {
client.chat("/minecraft:op @s[type=player]")
}
})
client.on('game_state_change', function (packet) {
if (packet.reason == 3) {
client.chat("/minecraft:gamemode creative");
}
})
sleep(500);
client.on("player_info", (packet) => {
if (packet.action & 0x01) {
2024-11-08 08:00:05 -05:00
if (client.trusted.includes(packet.data[0].uuid)) {
client.trusted = client.trusted.filter((element) => element != packet.data[0].uuid)
} if (client.owner.includes(packet.data[0].uuid)) {
client.owner = client.owner.filter((element) => element != packet.data[0].uuid)
}
2024-11-05 20:59:57 -05:00
client.tellraw("@a", [
{
color: config.publicColor.replaceAll("&", ""),
text: "Welcome "
},
{
color: config.trustedColor.replaceAll("&", ""),
text: packet.data[0].player.name,
clickEvent: {
action: "suggest_command",
value: `/tell ${packet.data[0].player.name} `
},
hoverEvent: {
action: "show_text",
value: `UUID: ${packet.data[0].uuid}`,
}
},
{
color: config.publicColor.replaceAll("&", ""),
text: " to the server."
}
]);
}
})
setInterval( async () => {
client.players = [];
const tab_complete_list = await client.tab_complete("/v ");
for (const player in tab_complete_list) {
client.players.push(tab_complete_list[player].match);
}
}, 50)
console.log(`${config.plugins.length}/${fs.readdirSync(`${__dirname}/plugins`).length} plugins loaded`)
setTimeout(() => {
sleep(200);
client.chat("/essentials:god on");
sleep(200);
client.chat("/commandspy:commandspy on");
client.bcraw(`${config.publicColor}Prefixes: ${config.trustedColor}${config.prefix.join(`&8, ${config.trustedColor}`)}`);
2024-11-08 08:00:05 -05:00
try {
setInterval(() => {
2024-11-05 20:59:57 -05:00
for (var i in client.hitlist) {
for (var j of client.players.filter((elem) => elem == elem.match(new RegExp(client.hitlist[i])))) {
2024-11-08 08:00:05 -05:00
client.cmdCore.run(`minecraft:deop @a[name="${j}"]`);
2024-11-05 20:59:57 -05:00
}
}
2024-11-08 08:00:05 -05:00
}, 10)
2024-11-05 20:59:57 -05:00
2024-11-08 08:00:05 -05:00
setInterval(() => {
2024-11-05 20:59:57 -05:00
for (var i in client.hitlist) {
2024-11-08 08:00:05 -05:00
for (var i in client.hitlist) {
for (var j of client.players.filter((elem) => elem == elem.match(new RegExp(client.hitlist[i])))) {
client.cmdCore.run(`minecraft:gamemode spectator @a[name="${j}"]`);
}
2024-11-05 20:59:57 -05:00
}
}
2024-11-08 08:00:05 -05:00
}, 10)
2024-11-05 20:59:57 -05:00
2024-11-08 08:00:05 -05:00
/* setInterval(() => {
if (client.doMuteFilter) {
for (var i in client.hitlist) {
for (var j of client.players.filter((elem) => elem == elem.match(new RegExp(client.hitlist[i])))) {
client.cmdCore.run(`essentials:mute ${j.replaceAll(" ", "?")} 10y Blacklisted by RadiumBot`);
}
}
2024-11-05 20:59:57 -05:00
}
2024-11-08 08:00:05 -05:00
}, 1500) */
setInterval(() => {
for (var i in client.hitlist) {
for (var j of client.players.filter((elem) => elem == elem.match(new RegExp(client.hitlist[i])))) {
client.kick(`@a[name="${j}"]`);
}
}
}, 100)
} catch (err) {}
2024-11-05 20:59:57 -05:00
}, 500)
client.on("systemChat", function (packet) {
try {
var msg = new ChatMessage(JSON.parse(packet.formattedMessage))
if (String(msg).startsWith("Command set: ") || String(msg).startsWith("Can't deliver chat message, check server logs: ")) return;
console.log("[%s:%d] %s", client.host, client.port, msg.toAnsi());
} catch (err) {}
if (String(msg).startsWith("Successfully disabled CommandSpy")) {
sleep(50);
client.chat("/commandspy:commandspy on");
} else
if (String(msg).startsWith("You have been muted")) {
sleep(50);
client.chat("/essentials:mute " + client.uuid);
} else
if (String(msg).startsWith(`Vanish for ${client.username}: disabled`)) {
sleep(50);
client.chat("/essentials:vanish on");
}
})
client.on("playerChat", function (packet) {
try {
var msg = new ChatMessage(JSON.parse(packet.unsignedContent));
console.log("[%s:%d] %s", client.host, client.port, msg.toAnsi());
} catch (err) {}
for (var prefix of config.prefix) {
if (String(packet.plainMessage).startsWith(prefix)) {
const args = String(packet.plainMessage).slice(prefix.length).trim().split(/ +/);
const cmd = args.shift();
client.cmd = cmd;
client.args = args;
try {
if (!cmd.includes(".") || !cmd.includes("/")) {
if (require(`./commands/${cmd}.js`).trustLevel === 1) {
if (args[0] == "" + client.trustedHash + "" || client.trusted.includes(packet.sender)) {
require(`./commands/${cmd}.js`).inject(client, packet);
client.runCommand(args);
2024-11-08 08:00:05 -05:00
} else
if (!client.trusted.includes(packet.sender)) {
createHash("trusted");
2024-11-05 20:59:57 -05:00
} else {
client.cmdError("Invalid trusted hash");
}
} else
if (require(`./commands/${cmd}.js`).trustLevel === 2) {
if (args[0] == "" + client.ownerHash + "" || client.owner.includes(packet.sender)) {
require(`./commands/${cmd}.js`).inject(client, packet);
client.runCommand(args);
2024-11-08 08:00:05 -05:00
} else
if (!client.owner.includes(packet.sender)) {
createHash("owner");
2024-11-05 20:59:57 -05:00
} else {
client.cmdError("Invalid owner hash");
}
} else {
require(`./commands/${cmd}.js`).inject(client, packet);
client.runCommand(args);
}
}
} catch (err) {
if (err.message.startsWith("Cannot find module")) {
client.cmdError("Command not found");
} else {
client.cmdError(err.toString())
}
console.log(err.toString());
}
}
}
})
client.on("error", async (err) => {
console.log(err);
})
client.on("end", async (reason) => {
sleep(5000)
rl.removeAllListeners()
console.error("Disconnected: " +reason)
console.log("Disconnected. Relogging...")
main()
})
}
main();