feat: 添加补丁扩展 添加异步执行

merge/1/MERGE
coding 2017-10-14 06:32:50 +00:00
parent 52d665c6e6
commit 21cca40534
2 changed files with 15 additions and 4 deletions

View File

@ -31,6 +31,8 @@ function loadCore() {
// 加载基础模块
load(core_dir + '/ext.js');
load(core_dir + '/console.js');
// 加载补丁和扩展
load(core_dir + '/patch.js');
}
/**
@ -44,14 +46,14 @@ function loadRequire() {
function loadLib4Bukkit() {
require('modules/event');
var task = require('modules/task');
global.setTimeout = function (func, time) {
return task.later(func, time)
global.setTimeout = function (func, time, async) {
return async ? task.laterAsync(func, time) : task.later(func, time);
};
global.clearTimeout = function (task) {
task.cancel();
};
global.setInterval = function (func, time) {
return task.timer(func, time)
global.setInterval = function (func, time, async) {
return async ? task.timerAsync(func, time) : task.timer(func, time);
};
global.clearInterval = function (task) {
task.cancel();

View File

@ -0,0 +1,9 @@
/**
* 补丁和方法扩展
*/
// JSON快捷方法
Object.prototype.toJson = function(){ return JSON.stringify(this); }
// YAML快速生成
Object.prototype.toYaml = function(){ return require('modules/yaml').safeDump(plugin.config); }