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