style: format file

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2019-04-23 18:56:34 +08:00
parent 93d7389047
commit b611da5e27
16 changed files with 98 additions and 185 deletions

View File

@ -17,9 +17,9 @@ var permission = require('./permission');
function loadPlugins(dir) {
var plugin = fs.file(root, dir);
if (!plugin) {
console.info("首次加载 创建文件夹 %s ...".format(plugin));
console.info("First Running Create Plugins Floder %s ...".format(plugin));
} else {
console.info("开始扫描 %s 下的插件 ...".format(plugin));
console.info("Start Scan %s Plugins ...".format(plugin));
createUpdate(plugin);
var files = [];
fs.list(plugin).forEach(function searchPlugin(file) {
@ -86,7 +86,7 @@ function loadPlugin(file) {
function readPlugin(file) {
var update = fs.file(fs.file(file.parentFile, 'update'), file.name);
if (update.exists()) {
console.info('自动升级插件 %s'.format(file.name));
console.info('Auto Update Plugin %s'.format(file.name));
fs.move(update, file, true);
}
var plugin = require(file, {
@ -107,7 +107,7 @@ function initPlugin(plugin) {
} else {
internalInitPlugin(plugin);
afterLoadHook(plugin);
console.info('载入插件 %s 版本 %s By %s'.format(desc.name, desc.version || '未知', desc.author || '未知'));
console.info('Loading Plugin %s Version %s By %s'.format(desc.name, desc.version || 'Unknown', desc.author || 'Unknown'));
}
return plugin;
}
@ -250,7 +250,7 @@ function init(path) {
var plugin = exports.$;
if (plugin !== null) {
// 如果plugin不等于null 则代表是正式环境
console.info("初始化 MiaoScript 插件系统: %s".format(plugin));
console.info("Initialization MiaoScript Plugin System: %s".format(plugin));
}
loadPlugins(path);
}

View File

@ -3,7 +3,7 @@ function ServerHandlerDefault() {
/**
* 获取在线玩家
*/
this.players = function () {
this.players = function() {
switch (arguments.length) {
case 1:
if (toString.call(arguments[0]) !== "[object Function]") { throw TypeError('first argument must be a function!') }

View File

@ -8,7 +8,7 @@
* http://en.wikipedia.org/wiki/Base64
*/
(function (global) {
(function(global) {
'use strict';
// existing version for noConflict()
var _Base64 = global.Base64;
@ -24,14 +24,14 @@
// constants
// noinspection SpellCheckingInspection
var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var b64tab = function (bin) {
var b64tab = function(bin) {
var t = {};
for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
return t;
}(b64chars);
var fromCharCode = String.fromCharCode;
// encoder stuff
var cb_utob = function (c) {
var cb_utob = function(c) {
if (c.length < 2) {
var cc = c.charCodeAt(0);
return cc < 0x80 ? c
@ -51,10 +51,10 @@
}
};
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
var utob = function (u) {
var utob = function(u) {
return u.replace(re_utob, cb_utob);
};
var cb_encode = function (ccc) {
var cb_encode = function(ccc) {
var padlen = [0, 2, 1][ccc.length % 3],
ord = ccc.charCodeAt(0) << 16
| ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
@ -67,32 +67,32 @@
];
return chars.join('');
};
var btoa = global.btoa ? function (b) {
var btoa = global.btoa ? function(b) {
return global.btoa(b);
} : function (b) {
} : function(b) {
return b.replace(/[\s\S]{1,3}/g, cb_encode);
};
var _encode = buffer ?
buffer.from && buffer.from !== Uint8Array.from ? function (u) {
buffer.from && buffer.from !== Uint8Array.from ? function(u) {
return (u.constructor === buffer.constructor ? u : buffer.from(u))
.toString('base64')
}
: function (u) {
: function(u) {
return (u.constructor === buffer.constructor ? u : new buffer(u))
.toString('base64')
}
: function (u) {
: function(u) {
return btoa(utob(u))
}
;
var encode = function (u, urisafe) {
var encode = function(u, urisafe) {
return !urisafe
? _encode(String(u))
: _encode(String(u)).replace(/[+\/]/g, function (m0) {
: _encode(String(u)).replace(/[+\/]/g, function(m0) {
return m0 === '+' ? '-' : '_';
}).replace(/=/g, '');
};
var encodeURI = function (u) {
var encodeURI = function(u) {
return encode(u, true)
};
// decoder stuff
@ -101,7 +101,7 @@
'[\xE0-\xEF][\x80-\xBF]{2}',
'[\xF0-\xF7][\x80-\xBF]{3}'
].join('|'), 'g');
var cb_btou = function (cccc) {
var cb_btou = function(cccc) {
switch (cccc.length) {
case 4:
var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
@ -124,10 +124,10 @@
);
}
};
var btou = function (b) {
var btou = function(b) {
return b.replace(re_btou, cb_btou);
};
var cb_decode = function (cccc) {
var cb_decode = function(cccc) {
var len = cccc.length,
padlen = len % 4,
n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
@ -142,32 +142,32 @@
chars.length -= [0, 0, 2, 1][padlen];
return chars.join('');
};
var atob = global.atob ? function (a) {
var atob = global.atob ? function(a) {
return global.atob(a);
} : function (a) {
} : function(a) {
return a.replace(/[\s\S]{1,4}/g, cb_decode);
};
var _decode = buffer ?
buffer.from && buffer.from !== Uint8Array.from ? function (a) {
buffer.from && buffer.from !== Uint8Array.from ? function(a) {
return (a.constructor === buffer.constructor
? a : buffer.from(a, 'base64')).toString();
}
: function (a) {
: function(a) {
return (a.constructor === buffer.constructor
? a : new buffer(a, 'base64')).toString();
}
: function (a) {
: function(a) {
return btou(atob(a))
};
var decode = function (a) {
var decode = function(a) {
return _decode(
String(a).replace(/[-_]/g, function (m0) {
String(a).replace(/[-_]/g, function(m0) {
return m0 === '-' ? '+' : '/'
})
.replace(/[^A-Za-z0-9+\/]/g, '')
);
};
var noConflict = function () {
var noConflict = function() {
var Base64 = global.Base64;
global.Base64 = _Base64;
return Base64;
@ -189,20 +189,20 @@
};
// if ES5 is available, make Base64.extendString() available
if (typeof Object.defineProperty === 'function') {
var noEnum = function (v) {
return {value: v, enumerable: false, writable: true, configurable: true};
var noEnum = function(v) {
return { value: v, enumerable: false, writable: true, configurable: true };
};
global.Base64.extendString = function () {
global.Base64.extendString = function() {
Object.defineProperty(
String.prototype, 'fromBase64', noEnum(function () {
String.prototype, 'fromBase64', noEnum(function() {
return decode(this)
}));
Object.defineProperty(
String.prototype, 'toBase64', noEnum(function (urisafe) {
String.prototype, 'toBase64', noEnum(function(urisafe) {
return encode(this, urisafe)
}));
Object.defineProperty(
String.prototype, 'toBase64URI', noEnum(function () {
String.prototype, 'toBase64URI', noEnum(function() {
return encode(this, true)
}));
};
@ -214,7 +214,7 @@
}
else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], function () {
define([], function() {
return global.Base64
});
}
@ -223,4 +223,4 @@
: typeof window !== 'undefined' ? window
: typeof global !== 'undefined' ? global
: this
);
);

View File

@ -19,7 +19,7 @@ var X509TrustManager = Java.type("javax.net.ssl.X509TrustManager");
// noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols
var TrustAnyHostnameVerifier = new HostnameVerifier({
verify: function (hostname, session) {
verify: function(hostname, session) {
return true;
}
});
@ -28,12 +28,12 @@ var SSLSocketFactory = function initSSLSocketFactory() {
var sslContext = SSLContext.getInstance("TLS");
// noinspection JSUnusedGlobalSymbols
sslContext.init(null, [new X509TrustManager({
getAcceptedIssuers: function () {
getAcceptedIssuers: function() {
return null;
},
checkClientTrusted: function (chain, authType) {
checkClientTrusted: function(chain, authType) {
},
checkServerTrusted: function (chain, authType) {
checkServerTrusted: function(chain, authType) {
}
})], new java.security.SecureRandom());
return sslContext.getSocketFactory();
@ -127,7 +127,7 @@ var http = {
request: request
};
['GET', 'DELETE', 'HEAD', 'OPTIONS'].forEach(function (method) {
['GET', 'DELETE', 'HEAD', 'OPTIONS'].forEach(function(method) {
http[method.toLowerCase()] = function __likeGet__(url, data, config) {
return this.request(Object.assign(config || {}, {
url: url,
@ -137,7 +137,7 @@ var http = {
}
});
['POST', 'PUT', 'PATCH'].forEach(function (method) {
['POST', 'PUT', 'PATCH'].forEach(function(method) {
http[method.toLowerCase()] = function __likePost__(url, data, config) {
return this.request(Object.assign(config || {}, {
url: url,

View File

@ -60,7 +60,7 @@ function onCommand(jsp, c, cmd) {
// 必须指定需要实现的接口类型 否则MOD服会报错
// noinspection JSUnusedGlobalSymbols
c.setExecutor(new org.bukkit.command.CommandExecutor({
onCommand: function (sender, _, command, args) {
onCommand: function(sender, _, command, args) {
try {
return cmd(sender, command, Java.from(args));
} catch (ex) {
@ -75,7 +75,7 @@ function onTabComplete(jsp, c, tab) {
// 必须指定需要实现的接口类型 否则MOD服会报错
// noinspection JSUnusedGlobalSymbols
c.setTabCompleter(new org.bukkit.command.TabCompleter({
onTabComplete: function (sender, _, command, args) {
onTabComplete: function(sender, _, command, args) {
try {
var token = args[args.length - 1];
var complete = tab(sender, command, Java.from(args)) || [];

View File

@ -27,7 +27,7 @@ item.create = function() {
break;
case "[object Array]":
idOrType.forEach(function(type) {
var temp = Material[idOrType];
var temp = Material[type];
if (temp) {
idOrType = temp;
return;

View File

@ -1,81 +0,0 @@
interface Class {
name;
class;
static;
methods;
simpleName;
constructors;
parameterTypes;
}
interface Task {
submit(plugin);
}
interface Registration {
provider;
}
interface PluginManager {
isEnabled();
}
interface bukkit {
nmsVersion: string;
}
interface Server {
server;
service;
consoleSender;
onlinePlayers;
pluginManager;
serviceManager;
servicesManager;
}
interface Player {
handle: NMSPlayer;
getName();
openInventory();
}
interface Inventory {
setItem(index: number, item: Item);
}
interface PlayerEvent {
targetEntity;
}
interface ItemEvent {
entity: Item;
}
interface InventoryClickEvent {
inventory;
whoClicked;
rawSlot;
}
interface NMSPlayer {
playerConnection;
}
interface File {
canonicalPath;
isDirectory();
}
interface Item {
itemStack: ItemStack;
}
interface ItemStack {
typeId;
itemMeta;
amount;
}

View File

@ -1,3 +0,0 @@
interface requestConfig {
header;
}

View File

@ -7,7 +7,7 @@ var PlaceholderAPI;
var server = require('api/server');
PlaceholderAPI = {
setPlaceholders: function () {
setPlaceholders: function() {
return arguments[1].replace(/&([0-9a-fk-orA-FK-OR])/, '§$1');
}
};
@ -26,7 +26,7 @@ try {
var s = TextSerializers.formattingCode('§');
if (spongePapi) {
PlaceholderAPI = {
setPlaceholders: function () {
setPlaceholders: function() {
return s.serialize(spongePapi.replacePlaceholders(arguments[1], arguments[0], arguments[0]));
}
};

View File

@ -2,18 +2,18 @@
var chat = require('api/chat');
var server = require('api/server');
var ChatMessagePart = function () {
this.click = function (action, value) {
var ChatMessagePart = function() {
this.click = function(action, value) {
this.clickEventAction = action;
this.clickEventValue = value;
};
this.hover = function (action, value) {
this.hover = function(action, value) {
this.hoverEventAction = action;
this.hoverEventValue = value;
};
this.convert = function () {
this.convert = function() {
var str = {};
if (this.text) {
str.text = this.text;
@ -37,11 +37,11 @@ var ChatMessagePart = function () {
}
};
var Tellraw = function () {
var Tellraw = function() {
var parts = [new ChatMessagePart()];
var self = this;
this.then = function (part) {
this.then = function(part) {
if (typeof part === "string") {
var newPart = new ChatMessagePart();
newPart.text = part;
@ -57,12 +57,12 @@ var Tellraw = function () {
this.cache = null;
};
this.text = function (text) {
this.text = function(text) {
this.latest().text = text;
return this;
};
this.tip = function (str) {
this.tip = function(str) {
if (toString.call(str) === "[object Array]") {
str = str.join("\n");
}
@ -70,39 +70,39 @@ var Tellraw = function () {
return this;
};
this.item = function (str) {
this.item = function(str) {
this.latest().hover("show_item", str);
return this;
};
this.cmd = this.command = function (command) {
this.cmd = this.command = function(command) {
this.latest().click("run_command", command);
return this;
};
this.suggest = function (url) {
this.suggest = function(url) {
this.latest().click("suggest_command", url);
return this;
};
this.file = function (path) {
this.file = function(path) {
this.latest().click("open_file", path);
return this;
};
this.link = function (url) {
this.link = function(url) {
this.latest().click("open_url", url);
return this;
};
this.latest = function () {
this.latest = function() {
return parts[parts.length - 1];
};
this.json = function () {
this.json = function() {
if (!this.cache) {
var temp = [];
parts.forEach(function (t) {
parts.forEach(function(t) {
temp.push(t.convert());
});
this.cache = JSON.stringify(temp);
@ -111,18 +111,18 @@ var Tellraw = function () {
return this.cache;
};
this.send = function (player) {
this.send = function(player) {
chat.json(player, self.json());
};
this.sendAll = function () {
this.sendAll = function() {
server.players(function sendAllMessage(p) {
self.send(p);
})
}
};
Tellraw.create = function () {
Tellraw.create = function() {
return new Tellraw().then(Tellraw.duplicateChar);
};

View File

@ -17,13 +17,13 @@ function Template(tpl) {
// 创建函数:
var fn = new Function(code.join('\n'));
// 用render()调用函数并绑定this参数
this.render = function (model) {
this.render = function(model) {
return fn.apply(model);
};
}
exports = module.exports = {
create: function (tpl) {
create: function(tpl) {
return new Template(tpl);
}
}

View File

@ -13,7 +13,7 @@ function toStr(obj) {
}
function compare(prop) {
return function (obj1, obj2) {
return function(obj1, obj2) {
var val1 = obj1[prop];
var val2 = obj2[prop];
if (!isNaN(Number(val1)) && !isNaN(Number(val2))) {

View File

@ -3,7 +3,7 @@
/*global Java, base, module, exports, require, __FILE__*/
var ZipFile = Java.type("java.util.zip.ZipFile");
var fs = require('core/fs');
var fs = require('fs');
/**
* 解压文件

View File

@ -28,7 +28,7 @@ function load() {
function enable() {
// noinspection JSUnusedLocalSymbols
command.on(this, 'hello', {
cmd: function (sender, command, args) {
cmd: function(sender, command, args) {
engineLoad(fs.file(root, 'test.js'));
return true;
}
@ -51,7 +51,7 @@ function enable() {
function send(event, player) {
// noinspection JSUnresolvedVariable
console.debug('玩家', player.getName(), "触发事件", event.class.simpleName);
setTimeout(function () {
setTimeout(function() {
// noinspection JSUnresolvedVariable
player.sendMessage("§a欢迎来到 §bMiaoScript §a的世界! 当前在线: " + server.players().length)
}, 10);

View File

@ -7,8 +7,6 @@
var event = require('api/event');
var wrapper = require('api/wrapper');
var command = require('api/command');
var server = require('api/server');
var fs = require('fs');
var description = {
name: 'MiaoAuth',
@ -30,12 +28,12 @@ function load() {
function enable() {
command.on(this, 'l', {
cmd: function (sender, command, args) {
cmd: function(sender, command, args) {
return true;
}
});
command.on(this, 'r', {
cmd: function (sender, command, args) {
cmd: function(sender, command, args) {
return true;
}
});

View File

@ -10,7 +10,6 @@ var bukkit = require('api/server');
var item = require('api/item');
var Arrays = Java.type('java.util.Arrays');
var Material = Java.type('org.bukkit.Material');
var ItemStackArray = Java.type('org.bukkit.inventory.ItemStack[]');
var PANE = 'STAINED_GLASS_PANE'