[GM > Plugin] Add commands wrapper
This commit is contained in:
parent
4b0de84b00
commit
b8320bb167
|
@ -1,11 +1,19 @@
|
||||||
import showToast from '@goosemod/toast';
|
import showToast from '@goosemod/toast';
|
||||||
|
import { commands } from '@goosemod/patcher';
|
||||||
|
|
||||||
export default class Plugin {
|
export default class Plugin {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.patches = [];
|
this.patches = [];
|
||||||
|
this.commands = [];
|
||||||
this.stylesheets = [];
|
this.stylesheets = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
command(...args) {
|
||||||
|
this.commands.push(args[0]);
|
||||||
|
|
||||||
|
commands.add(...args);
|
||||||
|
}
|
||||||
|
|
||||||
enqueueUnpatch(unpatch) {
|
enqueueUnpatch(unpatch) {
|
||||||
this.patches.push(unpatch);
|
this.patches.push(unpatch);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +43,7 @@ export default class Plugin {
|
||||||
onRemove: () => {
|
onRemove: () => {
|
||||||
this.patches.forEach((x) => x());
|
this.patches.forEach((x) => x());
|
||||||
this.stylesheets.forEach((x) => x.remove());
|
this.stylesheets.forEach((x) => x.remove());
|
||||||
|
this.commands.forEach((x) => commands.remove(x));
|
||||||
|
|
||||||
this.onRemove();
|
this.onRemove();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue