style: 格式化代码
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
612d4ee856
commit
dc716dc87c
@ -33,7 +33,7 @@ var disable;
|
||||
|
||||
var pluginYml;
|
||||
|
||||
function checkClassLoader(){
|
||||
function checkClassLoader() {
|
||||
var classLoader = java.lang.Thread.currentThread().getContextClassLoader();
|
||||
pluginYml = classLoader.getResource("plugin.yml");
|
||||
if (pluginYml === null) {
|
||||
|
@ -18,7 +18,7 @@
|
||||
var yaml = require('modules/yaml');
|
||||
Object.prototype.toYaml = function () {
|
||||
return yaml.safeDump(this);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 日期格式化
|
||||
@ -36,10 +36,10 @@
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
|
||||
"S": this.getMilliseconds() //毫秒
|
||||
};
|
||||
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "") .substr(4 - RegExp.$1.length));
|
||||
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||||
for (var k in o) {
|
||||
if (new RegExp("(" + k + ")").test(fmt)) {
|
||||
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? o[k] : (("00" + o[k]).substr(("" + o[k]).length)));
|
||||
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? o[k] : (("00" + o[k]).substr(("" + o[k]).length)));
|
||||
}
|
||||
}
|
||||
return fmt;
|
||||
|
@ -6,10 +6,11 @@ var global = this;
|
||||
// noinspection JSUnusedLocalSymbols
|
||||
global.init = function init(root) {
|
||||
global.root = root;
|
||||
global.noop = function () {};
|
||||
global.noop = function () {
|
||||
};
|
||||
loadCore();
|
||||
loadRequire();
|
||||
try{
|
||||
try {
|
||||
loadExt();
|
||||
loadServerLib();
|
||||
loadPlugins();
|
||||
@ -17,7 +18,7 @@ var global = this;
|
||||
console.console("§4初始化插件基础系统库错误:§c", ex);
|
||||
console.ex(ex);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 初始化核心
|
||||
@ -46,7 +47,7 @@ var global = this;
|
||||
var fs = require('core/fs');
|
||||
fs.list(fs.file(root, 'core/ext')).forEach(function (path) {
|
||||
console.log('加载扩展类库', path);
|
||||
try{
|
||||
try {
|
||||
load(path.toFile());
|
||||
} catch (ex) {
|
||||
console.ex(ex);
|
||||
|
@ -73,28 +73,30 @@ function on(jsp, name, exec) {
|
||||
// 必须指定需要实现的接口类型 否则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);
|
||||
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) {
|
||||
// 必须指定需要实现的接口类型 否则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];
|
||||
StringUtil.copyPartialMatches(token, Arrays.asList(exec.tab(sender, command, args)), completions);
|
||||
return completions;
|
||||
} 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);
|
||||
try {
|
||||
var completions = new ArrayList();
|
||||
var token = args[args.length - 1];
|
||||
StringUtil.copyPartialMatches(token, Arrays.asList(exec.tab(sender, command, args)), completions);
|
||||
return completions;
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}}));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@ var Material = Java.type('org.bukkit.Material');
|
||||
*/
|
||||
item.create = function () {
|
||||
var idOrType = arguments[0];
|
||||
if (isNaN(new Number(idOrType))) {
|
||||
idOrType = Material[idOrType];
|
||||
if (isNaN(Number(idOrType))) {
|
||||
idOrType = Material[idOrType];
|
||||
}
|
||||
switch (arguments.length) {
|
||||
case 1:
|
||||
@ -87,7 +87,9 @@ item.setName = function (item, name) {
|
||||
item.setLore = item.setLores = function (item, lores) {
|
||||
if (item.getType().name() !== "AIR") {
|
||||
var meta = item.hasItemMeta() ? item.getItemMeta() : Bukkit.getItemFactory().getItemMeta(item.getType());
|
||||
if (typeof(lores) === 'string') { lores = lores.split("\n") };
|
||||
if (typeof(lores) === 'string') {
|
||||
lores = lores.split("\n")
|
||||
}
|
||||
meta.setLore(lores);
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
|
@ -20,22 +20,22 @@ var ArrayList = Java.type('java.util.ArrayList');
|
||||
var Arrays = Java.type('java.util.Arrays');
|
||||
|
||||
var SimpleCommandCallable = function () {
|
||||
this.process = function (source, arguments) {
|
||||
this.process = function (source, args) {
|
||||
|
||||
},
|
||||
this.getSuggestions = function (source, arguments, targetPosition) {
|
||||
};
|
||||
this.getSuggestions = function (source, args, targetPosition) {
|
||||
return Arrays.asList('');
|
||||
},
|
||||
};
|
||||
this.testPermission = function (source) {
|
||||
return true;
|
||||
},
|
||||
};
|
||||
this.getShortDescription = function (source) {
|
||||
return Optional.ofNullable('');
|
||||
},
|
||||
};
|
||||
this.getHelp = function (source) {
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function enable(jsp) {
|
||||
var commands = jsp.description.commands;
|
||||
|
@ -123,8 +123,8 @@ function newItemFromConfig(config) {
|
||||
function enable() {
|
||||
command.on(this, 'l', {
|
||||
cmd: function (sender, command, args) {
|
||||
if(!sender.openInventory){
|
||||
console.sender(sender, "§4当前用户无法使用该命令!");
|
||||
if (!sender.openInventory) {
|
||||
console.sender(sender, "§4当前用户无法使用该命令!");
|
||||
}
|
||||
var inv = bukkit.$.createInventory(null, 54, config.title);
|
||||
inv.setContents(items);
|
||||
|
Loading…
Reference in New Issue
Block a user