diff --git a/js/plugin_loader.ts b/js/plugin_loader.ts index 22eed8cb7..2afa4b0d9 100644 --- a/js/plugin_loader.ts +++ b/js/plugin_loader.ts @@ -345,10 +345,11 @@ export class Plugin { } this.#runPluginFile(path).then((content) => { if (cb) cb.bind(scope)() - if (first && scope.oninstall) { - scope.oninstall() + if (first) { + scope.oninstall?.() + Blockbench.dispatchEvent('installed_plugin', {plugin: scope}); + Blockbench.showQuickMessage(tl('message.installed_plugin', [this.title])); } - if (first) Blockbench.showQuickMessage(tl('message.installed_plugin', [this.title])); resolve() }).catch((error) => { if (isApp) { @@ -581,9 +582,8 @@ export class Plugin { uninstall() { try { this.unload(); - if (this.onuninstall) { - this.onuninstall(); - } + this.onuninstall?.(); + Blockbench.dispatchEvent('uninstalled_plugin', {plugin: this}); } catch (err) { console.error(`Error in unload or uninstall method of "${this.id}": `, err); } diff --git a/types/custom/misc.d.ts b/types/custom/misc.d.ts index 04014468e..8f09e8896 100644 --- a/types/custom/misc.d.ts +++ b/types/custom/misc.d.ts @@ -37,6 +37,8 @@ type EventName = | 'process_chat_message' | 'loaded_plugin' | 'unloaded_plugin' + | 'installed_plugin' + | 'uninstalled_plugin' | 'update_settings' | 'update_project_settings' | 'save_project'