feat: use inversify autoProvide inject
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { command, plugin } from "@ms/api";
|
||||
import { inject, injectable } from "@ms/container";
|
||||
import * as ref from '@ms/common/dist/reflect'
|
||||
import { inject, provideSingleton } from "@ms/container";
|
||||
|
||||
const Arrays = Java.type('java.util.Arrays')
|
||||
const Command = Java.extend(Java.type('net.md_5.bungee.api.plugin.Command'), Java.type('net.md_5.bungee.api.plugin.TabExecutor'));
|
||||
@@ -13,26 +12,7 @@ const createCommand = eval(`
|
||||
}
|
||||
`)
|
||||
|
||||
class SimpleCommand {
|
||||
public callable: any;
|
||||
private name: string;
|
||||
private executor: Function;
|
||||
private tabComplete: Function = () => [];
|
||||
|
||||
constructor(command: string) {
|
||||
this.name = command;
|
||||
this.callable = createCommand(Command, command,
|
||||
(sender, args) => this.executor(sender, '', command, args),
|
||||
(sender, args) => Arrays.asList(this.tabComplete(sender, '', command, args))
|
||||
);
|
||||
}
|
||||
|
||||
setExecutor = (executor: Function) => this.executor = executor;
|
||||
setTabComplete = (tabComplete: Function) => this.tabComplete = tabComplete;
|
||||
toString = () => `Bungee SimpleCommand(${this.name})`
|
||||
}
|
||||
|
||||
@injectable()
|
||||
@provideSingleton(command.Command)
|
||||
export class BungeeCommand extends command.Command {
|
||||
@inject(plugin.PluginInstance)
|
||||
private pluginInstance: any;
|
||||
@@ -64,3 +44,22 @@ export class BungeeCommand extends command.Command {
|
||||
return plugin.description.name.toLowerCase() + ":" + command;
|
||||
}
|
||||
}
|
||||
|
||||
class SimpleCommand {
|
||||
public callable: any;
|
||||
private name: string;
|
||||
private executor: Function;
|
||||
private tabComplete: Function = () => [];
|
||||
|
||||
constructor(command: string) {
|
||||
this.name = command;
|
||||
this.callable = createCommand(Command, command,
|
||||
(sender, args) => this.executor(sender, '', command, args),
|
||||
(sender, args) => Arrays.asList(this.tabComplete(sender, '', command, args))
|
||||
);
|
||||
}
|
||||
|
||||
setExecutor = (executor: Function) => this.executor = executor;
|
||||
setTabComplete = (tabComplete: Function) => this.tabComplete = tabComplete;
|
||||
toString = () => `Bungee SimpleCommand(${this.name})`
|
||||
}
|
||||
Reference in New Issue
Block a user