feat: 添加插件管理相关 移动测试类
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
2228863d56
commit
4a6cc97f8a
@ -6,13 +6,30 @@
|
|||||||
|
|
||||||
/*global Java, base, module, exports, require, __FILE__*/
|
/*global Java, base, module, exports, require, __FILE__*/
|
||||||
var Bukkit = Java.type("org.bukkit.Bukkit");
|
var Bukkit = Java.type("org.bukkit.Bukkit");
|
||||||
|
// noinspection JSUnresolvedVariable
|
||||||
var PluginManager = Bukkit.pluginManager;
|
var PluginManager = Bukkit.pluginManager;
|
||||||
|
/**
|
||||||
|
* 插件管理
|
||||||
|
* @type {{manager: *, get: exports.plugin.get, load: exports.plugin.load}}
|
||||||
|
*/
|
||||||
exports.plugin = {
|
exports.plugin = {
|
||||||
|
/**
|
||||||
|
* 插件管理工具
|
||||||
|
*/
|
||||||
manager: PluginManager,
|
manager: PluginManager,
|
||||||
|
/**
|
||||||
|
* 获得插件实例
|
||||||
|
* @param name 插件名称
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
get: function (name) {
|
get: function (name) {
|
||||||
return PluginManager.getPlugin(name);
|
return PluginManager.getPlugin(name);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 载入插件 并且返回结果
|
||||||
|
* @param name 插件名称
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
load: function (name) {
|
load: function (name) {
|
||||||
var plugin = this.get(name);
|
var plugin = this.get(name);
|
||||||
if (ext.notNull(plugin) && !plugin.isEnabled()) {
|
if (ext.notNull(plugin) && !plugin.isEnabled()) {
|
||||||
@ -21,6 +38,10 @@ exports.plugin = {
|
|||||||
return PluginManager.isPluginEnabled(name);
|
return PluginManager.isPluginEnabled(name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 公告
|
||||||
|
* @param message 消息
|
||||||
|
*/
|
||||||
exports.broadcast = function (message) {
|
exports.broadcast = function (message) {
|
||||||
Bukkit.broadcastMessage(message);
|
Bukkit.broadcastMessage(message);
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
var papi = require("modules/ext/papi");
|
var papi = require("modules/ext/papi");
|
||||||
var event = require('modules/event');
|
var event = require('modules/event');
|
||||||
var joinCancel;
|
var join;
|
||||||
/*global Java, base, module, exports, require*/
|
/*global Java, base, module, exports, require*/
|
||||||
var description = {
|
var description = {
|
||||||
name: 'HelloWorld',
|
name: 'HelloWorld',
|
||||||
@ -18,15 +18,15 @@ function load() {
|
|||||||
|
|
||||||
function enable() {
|
function enable() {
|
||||||
log.i('启用 Hello Wrold 测试插件!');
|
log.i('启用 Hello Wrold 测试插件!');
|
||||||
joinCancel = event.on('playerloginevent', function (event) {
|
join = event.on('playerloginevent', function (event) {
|
||||||
// noinspection JSUnresolvedVariable
|
// noinspection JSUnresolvedVariable
|
||||||
event.player.sendMessage('§a欢迎来到 §bMiaoScript §a的世界!');
|
event.player.sendMessage(papi.$(event.player, "§a欢迎来到 §bMiaoScript §a的世界! 当前在线: %server_onlone%"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function disable() {
|
function disable() {
|
||||||
log.i('卸载 Hello Wrold 测试插件!');
|
log.i('卸载 Hello Wrold 测试插件!');
|
||||||
event.off(joinCancel);
|
event.off(join);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports = {
|
exports = {
|
||||||
|
Loading…
Reference in New Issue
Block a user