Pluginmanager stuff
This commit is contained in:
parent
881b33f4b6
commit
5ec53510be
File diff suppressed because it is too large
Load Diff
|
@ -10,13 +10,14 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const { Logger } = require('./modules');
|
||||
const { Logger, PluginManager } = require('./modules');
|
||||
|
||||
|
||||
class BetterDiscord {
|
||||
|
||||
constructor() {
|
||||
Logger.log('main', 'Init');
|
||||
window.pm = PluginManager;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,9 +16,10 @@ class Module {
|
|||
|
||||
constructor(args) {
|
||||
this.__ = {
|
||||
state: args,
|
||||
state: args || {},
|
||||
args
|
||||
}
|
||||
this.setState = this.setState.bind(this);
|
||||
this.init();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class PluginManager extends Module {
|
|||
|
||||
setInitialState() {
|
||||
this.setState({
|
||||
plugins: {}
|
||||
plugins: []
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,24 @@ class PluginManager extends Module {
|
|||
return this.state.plugins;
|
||||
}
|
||||
|
||||
loadPlugin(plugin) {
|
||||
const { plugins } = this;
|
||||
plugins.push(plugin);
|
||||
this.setState({
|
||||
plugins
|
||||
});
|
||||
}
|
||||
|
||||
getPluginByName(name) {
|
||||
return this.plugins.find(plugin => plugin.name === name);
|
||||
}
|
||||
|
||||
getPluginById(id) {
|
||||
return this.plugins.find(plugin => plugin.id === id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = { PluginManager }
|
||||
const _instance = new PluginManager();
|
||||
|
||||
module.exports = { PluginManager: _instance }
|
Loading…
Reference in New Issue