Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions js/plugin_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions types/custom/misc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type EventName =
| 'process_chat_message'
| 'loaded_plugin'
| 'unloaded_plugin'
| 'installed_plugin'
| 'uninstalled_plugin'
| 'update_settings'
| 'update_project_settings'
| 'save_project'
Expand Down