feat: 添加接口 兼容MOD服
This commit is contained in:
parent
fad15751dc
commit
c28b2f93aa
@ -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) {
|
function get(name) {
|
||||||
return commandMap.getCommand(name);
|
return commandMap.getCommand(name);
|
||||||
}
|
}
|
||||||
@ -61,17 +70,21 @@ function on(jsp, name, exec) {
|
|||||||
var c = get(name) || create(jsp, name);
|
var c = get(name) || create(jsp, name);
|
||||||
console.debug('插件 %s 设置命令 %s(%s) 执行器 ...'.format(jsp.description.name, name, c));
|
console.debug('插件 %s 设置命令 %s(%s) 执行器 ...'.format(jsp.description.name, name, c));
|
||||||
if (exec.cmd) {
|
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 {
|
try {
|
||||||
return exec.cmd(sender, command, args);
|
return exec.cmd(sender, command, args);
|
||||||
} catch (ex) {
|
} 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.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);
|
console.ex(ex);
|
||||||
}
|
}
|
||||||
});
|
}}));
|
||||||
}
|
}
|
||||||
if (exec.tab) {
|
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 {
|
try {
|
||||||
var completions = new ArrayList();
|
var completions = new ArrayList();
|
||||||
var token = args[args.length - 1];
|
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.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);
|
console.ex(ex);
|
||||||
}
|
}
|
||||||
});
|
}}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user