feat: support online load plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
1a546470a5
commit
695a490296
@ -79,7 +79,12 @@ export class MiaoScriptPackageManager extends interfaces.Plugin {
|
|||||||
|
|
||||||
main(sender: any, command: string, args: string[]) {
|
main(sender: any, command: string, args: string[]) {
|
||||||
let cmdKey = 'cmd' + args[0]
|
let cmdKey = 'cmd' + args[0]
|
||||||
if (!this[cmdKey] || args[0] === 'help') {
|
if (!this[cmdKey]) {
|
||||||
|
this.logger.sender(sender, '§4未知的子命令: §c' + args[0])
|
||||||
|
this.logger.sender(sender, '§6请执行 §b/' + command + ' §ahelp §6查看帮助!')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (args[0] === 'help') {
|
||||||
this.logger.sender(sender, help);
|
this.logger.sender(sender, help);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -87,6 +92,15 @@ export class MiaoScriptPackageManager extends interfaces.Plugin {
|
|||||||
this[cmdKey](sender, ...args);
|
this[cmdKey](sender, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmdload(sender: any, name: string) {
|
||||||
|
let pluginFile = fs.concat(__dirname + '', name);
|
||||||
|
if (!fs.exists(pluginFile)) {
|
||||||
|
this.logger.sender(sender, '§4插件 §c' + pluginFile + ' §4不存在!')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.pluginManager.loadFromFile(fs.file(pluginFile));
|
||||||
|
}
|
||||||
|
|
||||||
cmdlist(sender: any, type: string = 'cloud') {
|
cmdlist(sender: any, type: string = 'cloud') {
|
||||||
if (type == "install") {
|
if (type == "install") {
|
||||||
this.i18n(sender, 'list.install.header')
|
this.i18n(sender, 'list.install.header')
|
||||||
@ -163,6 +177,7 @@ export class MiaoScriptPackageManager extends interfaces.Plugin {
|
|||||||
try {
|
try {
|
||||||
this.logger.sender(sender, '§6Reloading §3MiaoScript Engine...');
|
this.logger.sender(sender, '§6Reloading §3MiaoScript Engine...');
|
||||||
ScriptEngineContextHolder.disableEngine();
|
ScriptEngineContextHolder.disableEngine();
|
||||||
|
Packages.java.lang.System.gc();
|
||||||
ScriptEngineContextHolder.enableEngine();
|
ScriptEngineContextHolder.enableEngine();
|
||||||
this.logger.sender(sender, '§3MiaoScript Engine §6Reload §aSuccessful...');
|
this.logger.sender(sender, '§3MiaoScript Engine §6Reload §aSuccessful...');
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user