[GM > Plugin] Add commands wrapper

This commit is contained in:
Ducko 2021-07-05 15:21:08 +01:00 committed by Alyxia Sother
parent 4b0de84b00
commit b8320bb167
No known key found for this signature in database
GPG Key ID: 355968D14144B739
1 changed files with 9 additions and 0 deletions

View File

@ -1,11 +1,19 @@
import showToast from '@goosemod/toast';
import { commands } from '@goosemod/patcher';
export default class Plugin {
constructor() {
this.patches = [];
this.commands = [];
this.stylesheets = [];
}
command(...args) {
this.commands.push(args[0]);
commands.add(...args);
}
enqueueUnpatch(unpatch) {
this.patches.push(unpatch);
}
@ -35,6 +43,7 @@ export default class Plugin {
onRemove: () => {
this.patches.forEach((x) => x());
this.stylesheets.forEach((x) => x.remove());
this.commands.forEach((x) => commands.remove(x));
this.onRemove();
}