From 0cdf1cf10607e6b5d8195581b7deb78f72e684db Mon Sep 17 00:00:00 2001 From: 502647092 Date: Mon, 9 Oct 2017 21:23:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dplugin=E4=B8=BAundefin?= =?UTF-8?q?ed=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- src/main/java/pw/yumc/MiaoScript/Base.java | 7 +++++++ src/main/resources/modules/event.js | 7 ++++--- src/main/resources/modules/task.js | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/pw/yumc/MiaoScript/Base.java b/src/main/java/pw/yumc/MiaoScript/Base.java index 156d623..01414eb 100644 --- a/src/main/java/pw/yumc/MiaoScript/Base.java +++ b/src/main/java/pw/yumc/MiaoScript/Base.java @@ -6,9 +6,12 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.stream.Collectors; +import org.bukkit.plugin.Plugin; + import lombok.val; import pw.yumc.YumCore.annotation.NotProguard; import pw.yumc.YumCore.bukkit.Log; +import pw.yumc.YumCore.bukkit.P; import pw.yumc.YumCore.bukkit.compatible.C; import pw.yumc.YumCore.mc.MinecraftTools; @@ -20,6 +23,10 @@ import pw.yumc.YumCore.mc.MinecraftTools; */ @NotProguard public class Base { + public Plugin getPlugin() { + return P.instance; + } + public Class getClass(String name) throws ClassNotFoundException { return Class.forName(name); } diff --git a/src/main/resources/modules/event.js b/src/main/resources/modules/event.js index 4d1a00a..93d8efd 100644 --- a/src/main/resources/modules/event.js +++ b/src/main/resources/modules/event.js @@ -12,7 +12,7 @@ var EventPriority = Java.type("org.bukkit.event.EventPriority"); var EventExecutor = Java.type("org.bukkit.plugin.EventExecutor"); var IllegalStateException = Java.type("java.lang.IllegalStateException"); -var mapEvent = []; +var plugin = base.plugin; /** * 扫描包 org.bukkit.event 下的所有事件 @@ -109,7 +109,7 @@ function listen(event, exec, priority, ignoreCancel) { exec(event); } }), - require('plugin').$, + plugin, ignoreCancel); // noinspection JSUnresolvedVariable log.d('注册事件 %s 方法 %s', eventCls.simpleName, exec.name === '' ? '匿名方法' : exec.name); @@ -132,9 +132,10 @@ function unlisten(listener) { log.d('注销事件 %s', eventCls.simpleName); } +var mapEvent = []; // 映射事件名称 mapEventName(); -log.i('Bukkit 事件映射完毕 共计 %s 个事件!', mapEvent.length); +// log.i('Bukkit 事件映射完毕 共计 %s 个事件!', mapEvent.length); module.exports = { on: listen, diff --git a/src/main/resources/modules/task.js b/src/main/resources/modules/task.js index 2aa30c0..3ea34b8 100644 --- a/src/main/resources/modules/task.js +++ b/src/main/resources/modules/task.js @@ -4,7 +4,7 @@ * 任务计划 * Created by 蒋天蓓 on 2017/2/9 0009. */ -var plugin = require('modules/plugin').$; +var plugin = base.plugin; var BukkitRunnable = Java.type("org.bukkit.scheduler.BukkitRunnable"); /** * 创建任务对象