feat: 优化命令注册
This commit is contained in:
		@@ -31,11 +31,11 @@ var SimpleCommandCallable = function (name) {
 | 
			
		||||
    this.callable = new CommandCallable({
 | 
			
		||||
        //CommandResult process(CommandSource source, String arguments) throws CommandException;
 | 
			
		||||
        process: function (src, args) {
 | 
			
		||||
            return that.cmd(src, null, name, args.split(" ")) ? CommandResult.success() : CommandResult.empty();
 | 
			
		||||
            return that.cmd(src, name, args.split(" ")) ? CommandResult.success() : CommandResult.empty();
 | 
			
		||||
        },
 | 
			
		||||
        //List<String> getSuggestions(CommandSource source, String arguments, @Nullable  Location<World> targetPosition) throws CommandException;
 | 
			
		||||
        getSuggestions: function (src, args, target) {
 | 
			
		||||
            return that.tab(src, null, name, args.split(" "));
 | 
			
		||||
            return that.tab(src, name, args.split(" "));
 | 
			
		||||
        },
 | 
			
		||||
        //boolean testPermission(CommandSource source);
 | 
			
		||||
        testPermission: function () {
 | 
			
		||||
@@ -93,7 +93,7 @@ function on(jsp, name, exec) {
 | 
			
		||||
    var c = create(jsp, name);
 | 
			
		||||
    console.debug('插件 %s 设置命令 %s 执行器 ...'.format(jsp.description.name, name));
 | 
			
		||||
    if (exec.cmd) {
 | 
			
		||||
        c.setExecutor(function (sender, cmd, command, args) {
 | 
			
		||||
        c.setExecutor(function (sender, command, args) {
 | 
			
		||||
            try {
 | 
			
		||||
                return exec.cmd(sender, command, args);
 | 
			
		||||
            } catch (ex) {
 | 
			
		||||
@@ -104,12 +104,10 @@ function on(jsp, name, exec) {
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    if (exec.tab) {
 | 
			
		||||
        c.setTabCompleter(function (sender, cmd, command, args) {
 | 
			
		||||
        c.setTabCompleter(function (sender, command, args) {
 | 
			
		||||
            try {
 | 
			
		||||
                var completions = new ArrayList();
 | 
			
		||||
                var token = args[args.length - 1];
 | 
			
		||||
                StringUtil.copyPartialMatches(token, Arrays.asList(exec.tab(sender, command, args)), completions);
 | 
			
		||||
                return completions;
 | 
			
		||||
                return Arrays.asList(exec.tab(sender, command, args));
 | 
			
		||||
            } catch (ex) {
 | 
			
		||||
                console.console('§6玩家 §a%s §6执行 §b%s §6插件 §d%s %s §6补全时发生异常 §4%s'.format(sender.name, jsp.description.name, command, args, ex));
 | 
			
		||||
                console.ex(ex);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user