style: 格式化代码

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2017-11-15 21:00:07 +08:00
parent 612d4ee856
commit dc716dc87c
7 changed files with 43 additions and 38 deletions

View File

@ -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) {

View File

@ -18,7 +18,7 @@
var yaml = require('modules/yaml');
Object.prototype.toYaml = function () {
return yaml.safeDump(this);
}
};
/**
* 日期格式化
@ -36,7 +36,7 @@
"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)));

View File

@ -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);

View File

@ -79,7 +79,8 @@ 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);
}
}}));
}
}));
}
if (exec.tab) {
// 必须指定需要实现的接口类型 否则MOD服会报错
@ -94,7 +95,8 @@ 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);
}
}}));
}
}));
}
}

View File

@ -17,7 +17,7 @@ var Material = Java.type('org.bukkit.Material');
*/
item.create = function () {
var idOrType = arguments[0];
if (isNaN(new Number(idOrType))) {
if (isNaN(Number(idOrType))) {
idOrType = Material[idOrType];
}
switch (arguments.length) {
@ -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);
}

View File

@ -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;

View File

@ -123,7 +123,7 @@ function newItemFromConfig(config) {
function enable() {
command.on(this, 'l', {
cmd: function (sender, command, args) {
if(!sender.openInventory){
if (!sender.openInventory) {
console.sender(sender, "§4当前用户无法使用该命令!");
}
var inv = bukkit.$.createInventory(null, 54, config.title);