From 4a6cc97f8a6c1eff3152b85a78dd68f1f7cbb860 Mon Sep 17 00:00:00 2001 From: 502647092 Date: Thu, 28 Sep 2017 20:55:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=20=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- src/main/resources/modules/bukkit.js | 23 ++++++++++++++++++- src/main/resources/plugins/hello.js | 8 +++---- .../pw/yumc/MiaoScript/MiaoScriptTest.java | 0 3 files changed, 26 insertions(+), 5 deletions(-) rename src/{main => }/test/java/pw/yumc/MiaoScript/MiaoScriptTest.java (100%) diff --git a/src/main/resources/modules/bukkit.js b/src/main/resources/modules/bukkit.js index afa8a4c..3e45a40 100644 --- a/src/main/resources/modules/bukkit.js +++ b/src/main/resources/modules/bukkit.js @@ -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); }; diff --git a/src/main/resources/plugins/hello.js b/src/main/resources/plugins/hello.js index 506d930..b5713d4 100644 --- a/src/main/resources/plugins/hello.js +++ b/src/main/resources/plugins/hello.js @@ -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 = { diff --git a/src/main/test/java/pw/yumc/MiaoScript/MiaoScriptTest.java b/src/test/java/pw/yumc/MiaoScript/MiaoScriptTest.java similarity index 100% rename from src/main/test/java/pw/yumc/MiaoScript/MiaoScriptTest.java rename to src/test/java/pw/yumc/MiaoScript/MiaoScriptTest.java