Upload files to "commands"

This commit is contained in:
m_c_player 2024-11-05 21:01:27 -05:00
parent 53f9e3db95
commit 137c2bc205
5 changed files with 209 additions and 0 deletions

38
commands/auth.js Normal file
View file

@ -0,0 +1,38 @@
const desc = "authenticate";
const usages = " - auth <hash>";
const trustLevel = 0;
const config = require("../config.json");
function inject (client, packet) {
const command = ((args) => {
switch (args[0]) {
case "" + client.trustedHash + "":
if (!client.trusted.includes(packet.sender)) {
client.trusted.push(packet.sender);
client.bcraw(`${config.publicColor}You have been authenticated as a ${config.trustedColor}trusted user${config.publicColor}.`);
} else {
client.cmdError("Nothing changed. You are already authed for trusted");
}
client.createHash("trusted");
break;
case "" + client.ownerHash + "":
if (!client.owner.includes(packet.sender)) {
client.owner.push(packet.sender);
client.bcraw(`${config.publicColor}You have been authenticated as the ${config.trustedColor}owner${config.publicColor}.`);
} else {
client.cmdError("Nothing changed. You are already authed for owner");
}
client.createHash("owner");
break;
default:
client.cmdError("Invalid hash");
break;
}
})
client.runCommand = command;
return command;
}
module.exports = { inject, desc, usages, trustLevel };

53
commands/cloop.js Normal file
View file

@ -0,0 +1,53 @@
const desc = "loop commands";
const usages = " - cloop add <interval> <command>\n - cloop clear\n - cloop remove <index>\n - cloop list";
const trustLevel = 1;
const config = require("../config.json");
var clooplist = [];
var cloops = [];
function inject (client) {
const command = ((args) => {
switch (args[1]) {
case "add":
clooplist.push({ command: args.slice(3).join(" "), interval: parseInt(args[2]) });
client.bcraw(`${config.publicColor}Added ${config.trustedColor}${args.slice(3).join(" ")}${config.publicColor} with interval ${config.trustedColor}${parseInt(args[2])}${config.publicColor} to the cloops`);
cloops.push(setInterval(() => { client.cmdCore.run(args.slice(3).join(" ")); }, parseInt(args[2])));
break;
case "clear":
for (var i of cloops) {
clearInterval(i);
}
clooplist = [];
cloops = [];
client.bcraw(`${config.publicColor}Cleared the cloops`);
break;
case "list":
var result = [];
for (var i in clooplist) {
result.push(`&l${i}: &r${clooplist[i].command}&f &l(${clooplist[i].interval})&r`);
}
client.bcraw(`&7Cloops &8(${config.publicColor}${clooplist.length}&8) &7» &f${result.join("&8, &f")}`);
break;
case "remove":
if (cloops[parseInt(args[2])]) {
clearInterval(cloops[parseInt(args[2])])
cloops = cloops.filter(element => cloops.indexOf(element) != parseInt(args[2]));
client.bcraw(`${config.publicColor}Removed cloop ${config.trustedColor}${parseInt(args[2])}${config.publicColor}`);
} else {
client.cmdError("Nothing changed. That cloop is not in the list")
}
break;
default:
client.cmdError("Incorrect argument for command");
break;
}
})
client.runCommand = command;
return command;
}
module.exports = { inject, desc, usages, trustLevel };

57
commands/filter.js Normal file
View file

@ -0,0 +1,57 @@
const desc = "filters a player with regex";
const usages = " - filter add <player>\n - filter remove <player>\n - filter list\n - filter clear";
const trustLevel = 1;
const config = require("../config.json");
function inject (client) {
const command = ((args) => {
switch (args[1]) {
case "add":
if (!client.hitlist.includes(args.slice(2).join(" "))) {
client.hitlist.push(args.slice(2).join(" "));
client.bcraw(`${config.publicColor}Added ${config.trustedColor}${args.slice(2).join(" ")}${config.publicColor} to the filter`);
} else {
client.cmdError("Nothing changed. That player is already in the filter");
}
break;
case "clear":
client.hitlist = [];
client.bcraw(`${config.publicColor}Cleared the filter`);
break;
case "list":
client.bcraw(`&7Filtered regexes &8(${config.publicColor}${client.hitlist.length}&8) &7» &f${client.hitlist.join("&8, &f")}`);
break;
case "remove":
if (client.hitlist.includes(args.slice(2).join(" "))) {
client.hitlist = client.hitlist.filter(element => element != args.slice(2).join(" "));
client.bcraw(`${config.publicColor}Removed ${config.trustedColor}${args.slice(2).join(" ")}${config.publicColor} from the filter`);
} else {
client.cmdError("Nothing changed. That player is not in the filter");
}
break;
/* case "muting":
if (args[2] == "true") {
client.doMuteFilter = true;
} else
if (args[2] == "false") {
client.doMuteFilter = false;
} else {
client.cmdError("Incorrect argument for command");
}
client.bcraw(`${config.publicColor}Doing mute commands is now ${config.trustedColor}${client.doMuteFilter}`);
break; */
default:
client.cmdError("Incorrect argument for command");
break;
}
})
client.runCommand = command;
return command;
}
module.exports = { inject, desc, usages, trustLevel };

25
commands/kick.js Normal file
View file

@ -0,0 +1,25 @@
const desc = "kick a player";
const usages = " - kick <type> <player>";
const trustLevel = 1;
function inject (client) {
const command = ((args) => {
switch (args[1]) {
case "longstring":
client.kick(args.slice(2).join(" "));
break;
case "translate":
client.crash(args.slice(2).join(" "));
break;
default:
client.cmdError("Incorrect argument for command");
break;
}
})
client.runCommand = command;
return command;
}
module.exports = { inject, desc, usages, trustLevel };

36
commands/validate.js Normal file
View file

@ -0,0 +1,36 @@
const desc = "validate a hash or check that you are authed";
const usages = " - validate [hash]";
const trustLevel = 0;
function inject (client, packet) {
const command = ((args) => {
function toNBTUUID(uuid) {
return `[I;${uuid.replace(/-/g, '').match(/.{8}/g).map(str => Number.parseInt(str, 16)).map(num => num & 0x80000000 ? num - 0xffffffff - 1 : num).join(',')}]`;
}
if (args[0]) {
switch (args[0]) {
case "" + client.trustedHash + "":
client.tellraw(`@a[nbt={UUID:${toNBTUUID(packet.sender)}}]`, { text: "Valid Trusted Hash", color: "green" } );
break;
case "" + client.ownerHash + "":
client.tellraw(`@a[nbt={UUID:${toNBTUUID(packet.sender)}}]`, { text: "Valid Owner Hash", color: "green" } );
break;
default:
client.tellraw(`@a[nbt={UUID:${toNBTUUID(packet.sender)}}]`, { text: "Invalid Hash", color: "red" } );
break;
}
} else {
if (client.trusted.includes(packet.sender)) {
client.tellraw(`@a`, { text: "You are authed for Trusted", color: "green" } );
} if (client.owner.includes(packet.sender)) {
client.tellraw(`@a`, { text: "You are authed for Owner", color: "green" } );
}
}
})
client.runCommand = command;
return command;
}
module.exports = { inject, desc, usages, trustLevel };