@ -1,11 +1,26 @@
|
||||
'use strict';
|
||||
/**
|
||||
* Bukkit基础操作
|
||||
* Created by 蒋天蓓 on 2017/2/9 0009.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/*global Java, base, module, exports, require, __FILE__*/
|
||||
var Bukkit = Java.type("org.bukkit.Bukkit");
|
||||
var PluginManager = Bukkit.pluginManager;
|
||||
|
||||
exports.plugin = {
|
||||
manager: PluginManager,
|
||||
get: function (name) {
|
||||
return PluginManager.getPlugin(name);
|
||||
},
|
||||
load: function (name) {
|
||||
var plugin = this.get(name);
|
||||
if (ext.notNull(plugin) && !plugin.isEnabled()) {
|
||||
PluginManager.enablePlugin(plugin);
|
||||
}
|
||||
return PluginManager.isPluginEnabled(name);
|
||||
}
|
||||
};
|
||||
exports.broadcast = function (message) {
|
||||
Bukkit.broadcastMessage(message);
|
||||
};
|
||||
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Bukkit 事件相关类
|
||||
*/
|
||||
/*global Java, base, module, exports, require, __FILE__*/
|
||||
var Thread = Java.type("java.lang.Thread");
|
||||
var Bukkit = Java.type("org.bukkit.Bukkit");
|
||||
@ -37,7 +39,7 @@ function mapEventName() {
|
||||
if (isVaildEvent(clz)) {
|
||||
// noinspection JSUnresolvedVariable
|
||||
var simpleName = clz.simpleName.toLowerCase();
|
||||
log.d("Mapping Event [%s] => %s", clz.name, simpleName);
|
||||
log.fd("Mapping Event [%s] => %s", clz.name, simpleName);
|
||||
mapEvent[simpleName] = clz;
|
||||
}
|
||||
} catch (ex) {
|
||||
@ -77,7 +79,6 @@ function listen(event, exec, priority, ignoreCancel) {
|
||||
if (ignoreCancel === undefined) {
|
||||
ignoreCancel = false;
|
||||
}
|
||||
var listener = new Java.extend(Listener, {});
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
/**
|
||||
* @param event Event type to register
|
||||
@ -89,7 +90,7 @@ function listen(event, exec, priority, ignoreCancel) {
|
||||
*/
|
||||
Bukkit.getPluginManager().registerEvent(
|
||||
eventCls,
|
||||
listener,
|
||||
new Listener({}),
|
||||
EventPriority[priority],
|
||||
new Java.extend(EventExecutor, {
|
||||
execute: function (listener, event) {
|
||||
|
24
src/main/resources/modules/ext/papi.js
Normal file
24
src/main/resources/modules/ext/papi.js
Normal file
@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
/**
|
||||
* PAPI扩展类
|
||||
*/
|
||||
/*global Java, base, module, exports, require, __FILE__*/
|
||||
var PlaceholderAPI;
|
||||
var bukkit = require('modules/bukkit');
|
||||
if (bukkit.plugin.load("PlaceholderAPI")) {
|
||||
PlaceholderAPI = ext.getStatic("me.clip.placeholderapi.PlaceholderAPI");
|
||||
} else {
|
||||
log.w("PlaceholderAPI 未找到 变量替换功能失效!");
|
||||
PlaceholderAPI = {
|
||||
setPlaceholders: function () {
|
||||
return arguments[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.$ = function (player, str) {
|
||||
if (arguments.length > 1) {
|
||||
return PlaceholderAPI.setPlaceholders(arguments[0], arguments[1]);
|
||||
} else {
|
||||
return PlaceholderAPI.setPlaceholders(null, arguments[0]);
|
||||
}
|
||||
};
|
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* MiaoScript脚本插件加载类
|
||||
*/
|
||||
/*global Java, base, module, exports, require, __FILE__*/
|
||||
var zip = require("core/zip");
|
||||
var fs = require('core/fs');
|
||||
@ -25,9 +27,9 @@ function loadPlugins(path) {
|
||||
* @param path
|
||||
*/
|
||||
function updatePlugins(path) {
|
||||
var dir = fs.file(path, "update");
|
||||
fs.list(dir).forEach(function (file) {
|
||||
|
||||
var update = fs.file(path, "update");
|
||||
fs.list(update).forEach(function (file) {
|
||||
fs.move(fs.file(update, file.name), fs.file(path, file.name), true);
|
||||
})
|
||||
}
|
||||
|
||||
@ -66,6 +68,7 @@ exports.$ = undefined;
|
||||
exports.plugins = [];
|
||||
exports.init = function (plugin, path) {
|
||||
if (plugin !== null) {
|
||||
// 如果过plugin不等于null 则代表是正式环境
|
||||
exports.$ = plugin;
|
||||
log.i("Init MiaoScript Engine Version: %s", plugin.description.version);
|
||||
require('./event');
|
||||
|
Reference in New Issue
Block a user