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"); /** * 创建任务对象