fix: command remove error
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
221b821085
commit
3cbc101eff
@ -20,11 +20,11 @@ class SimpleCommandCallable {
|
|||||||
this.callable = new CommandCallable({
|
this.callable = new CommandCallable({
|
||||||
//CommandResult process(CommandSource source, String arguments) throws CommandException;
|
//CommandResult process(CommandSource source, String arguments) throws CommandException;
|
||||||
process: (sender: any, args) => {
|
process: (sender: any, args) => {
|
||||||
return this.executor(sender, command, args.length === 0 ? [] : args.split(" ").filter(e => e)) ? CommandResult.success() : CommandResult.empty();
|
return this.executor(sender, '', command, Java.to(args.split(" ").filter(e => e))) ? CommandResult.success() : CommandResult.empty();
|
||||||
},
|
},
|
||||||
//List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) throws CommandException;
|
//List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) throws CommandException;
|
||||||
getSuggestions: (sender: any, args, target) => {
|
getSuggestions: (sender: any, args, target) => {
|
||||||
return this.tabCompleter(sender, command, args.length === 0 ? [] : args.split(" ").filter(e => e));
|
return this.tabCompleter(sender, '', command, Java.to(args.split(" ").filter(e => e)));
|
||||||
},
|
},
|
||||||
//boolean testPermission(CommandSource source);
|
//boolean testPermission(CommandSource source);
|
||||||
testPermission: () => {
|
testPermission: () => {
|
||||||
@ -54,21 +54,19 @@ class SimpleCommandCallable {
|
|||||||
export class SpongeCommand extends command.Command {
|
export class SpongeCommand extends command.Command {
|
||||||
@inject(plugin.PluginInstance)
|
@inject(plugin.PluginInstance)
|
||||||
private pluginInstance: any
|
private pluginInstance: any
|
||||||
private commandMap: any[] = [];
|
|
||||||
private commandMapping: any[] = [];
|
private commandMapping: any[] = [];
|
||||||
|
|
||||||
create(plugin: any, command: string) {
|
create(plugin: any, command: string) {
|
||||||
var commandKey = this.getCommandKey(plugin, command);
|
let commandKey = this.getCommandKey(plugin, command);
|
||||||
if (!this.commandMap[commandKey]) {
|
let commandCallable = new SimpleCommandCallable(command);
|
||||||
this.commandMap[commandKey] = new SimpleCommandCallable(command);
|
this.commandMapping[commandKey] = Sponge.getCommandManager().register(this.pluginInstance, commandCallable.callable, command, commandKey).orElse(null);
|
||||||
this.commandMapping[commandKey] = Sponge.getCommandManager().register(this.pluginInstance, this.commandMap[commandKey].callable, command, commandKey).orElse(null);
|
return commandCallable;
|
||||||
}
|
|
||||||
return this.commandMap[commandKey];
|
|
||||||
}
|
}
|
||||||
remove(plugin: any, command: string) {
|
remove(plugin: any, command: string) {
|
||||||
var commandKey = this.getCommandKey(plugin, command);
|
var commandKey = this.getCommandKey(plugin, command);
|
||||||
if (this.commandMapping[commandKey]) {
|
if (this.commandMapping[commandKey]) {
|
||||||
Sponge.getCommandManager().removeMapping(this.commandMapping[commandKey]);
|
Sponge.getCommandManager().removeMapping(this.commandMapping[commandKey]);
|
||||||
|
delete this.commandMapping[commandKey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onCommand(plugin: any, command: any, executor: Function) {
|
onCommand(plugin: any, command: any, executor: Function) {
|
||||||
|
@ -9,11 +9,11 @@ import { SpongeCommand } from './command';
|
|||||||
import { SpongeTaskManager } from './task';
|
import { SpongeTaskManager } from './task';
|
||||||
|
|
||||||
let SpongeServerType = 'sponge';
|
let SpongeServerType = 'sponge';
|
||||||
let Sponge = Java.type("org.spongepowered.api.Sponge");
|
let Sponge = org.spongepowered.api.Sponge;
|
||||||
|
|
||||||
container.bind(server.Console).toConstantValue(SpongeConsole);
|
container.bind(server.Console).toConstantValue(SpongeConsole);
|
||||||
container.bind(server.ServerType).toConstantValue(SpongeServerType);
|
container.bind(server.ServerType).toConstantValue(SpongeServerType);
|
||||||
container.bind(plugin.PluginInstance).toConstantValue(Sponge.pluginManager.getPlugin('MiaoScript').orElse(null));
|
container.bind(plugin.PluginInstance).toConstantValue(Sponge.getPluginManager().getPlugin('MiaoScript').orElse(null));
|
||||||
|
|
||||||
container.bind(event.Event).to(SpongeEvent).inSingletonScope();
|
container.bind(event.Event).to(SpongeEvent).inSingletonScope();
|
||||||
container.bind(command.Command).to(SpongeCommand).inSingletonScope();
|
container.bind(command.Command).to(SpongeCommand).inSingletonScope();
|
||||||
|
Loading…
Reference in New Issue
Block a user