Add Formatting (Thank God)

This commit is contained in:
2024-08-29 15:47:58 +02:00
parent 545e47a9f3
commit 1ab45204b9
35 changed files with 2331 additions and 254 deletions

View File

@@ -11,7 +11,7 @@ export class Command {
}
constructor(argv: string[], player: Player) {
this.argv = (function* () {
for (let arg of argv) yield arg;
for (const arg of argv) yield arg;
})();
this.__player = player;
}
@@ -83,13 +83,13 @@ export class Commands {
public static register(prefix: string, command: string, commandFunction: (arg: Command) => void): void {
if (prefix.startsWith("/")) throw Error("Unable to register slash commands.");
world.beforeEvents.chatSend.subscribe((arg) => {
var argv = arg.message.split(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g).filter((e) => e.trim().length > 0);
const argv = arg.message.split(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g).filter((e) => e.trim().length > 0);
if (argv[0] === `${prefix}${command}`) {
arg.cancel = true;
try {
commandFunction(new Command(argv, arg.sender));
} catch (err) {
let { statusMessage } = JSON.parse(err as string);
const { statusMessage } = JSON.parse(err as string);
console.error(err);
arg.sender.sendMessage(`§c${statusMessage}`);
}