From c28b2f93aa050fec29dbfcd3217e3a038ff1d644 Mon Sep 17 00:00:00 2001 From: coding Date: Wed, 15 Nov 2017 11:50:08 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=8E=A5=E5=8F=A3=20?= =?UTF-8?q?=E5=85=BC=E5=AE=B9MOD=E6=9C=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/internal/bukkit/command.js | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/resources/internal/bukkit/command.js b/src/main/resources/internal/bukkit/command.js index 3a98cdf..3b2d117 100644 --- a/src/main/resources/internal/bukkit/command.js +++ b/src/main/resources/internal/bukkit/command.js @@ -35,6 +35,15 @@ function enable(jsp) { } } +function disable(jsp) { + var commands = jsp.description.commands; + if (commands) { + for (var name in commands) { + + } + } +} + function get(name) { return commandMap.getCommand(name); } @@ -61,17 +70,21 @@ function on(jsp, name, exec) { var c = get(name) || create(jsp, name); console.debug('插件 %s 设置命令 %s(%s) 执行器 ...'.format(jsp.description.name, name, c)); if (exec.cmd) { - c.setExecutor(function (sender, cmd, command, args) { + // 必须指定需要实现的接口类型 否则MOD服会报错 + c.setExecutor(new org.bukkit.command.CommandExecutor({ + onCommand: function (sender, cmd, command, args) { try { return exec.cmd(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, Java.from(args).join(' '), ex)); console.ex(ex); } - }); + }})); } if (exec.tab) { - c.setTabCompleter(function (sender, cmd, command, args) { + // 必须指定需要实现的接口类型 否则MOD服会报错 + c.setTabCompleter(new org.bukkit.command.TabCompleter({ + onTabComplete: function (sender, cmd, command, args) { try { var completions = new ArrayList(); var token = args[args.length - 1]; @@ -81,7 +94,7 @@ function on(jsp, name, exec) { console.console('§6玩家 §a%s §6执行 §b%s §6插件 §d%s %s §6补全时发生异常 §4%s'.format(sender.name, jsp.description.name, command, Java.from(args).join(' '), ex)); console.ex(ex); } - }); + }})); } }