mirror of
https://e.coding.net/circlecloud/Yum.git
synced 2024-11-22 14:28:46 +00:00
feat: 兼容PerWorldPlugins
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
adaff66241
commit
e65246f55e
5
pom.xml
5
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>Yum</artifactId>
|
||||
<version>2.6.6</version>
|
||||
<version>2.6.7</version>
|
||||
<name>Yum</name>
|
||||
<description>Minecraft 服务器插件管理系统</description>
|
||||
<build>
|
||||
@ -61,10 +61,9 @@
|
||||
<update.description>&a全新 2.X 版本 更多守护与优化</update.description>
|
||||
<update.changes>
|
||||
&c注意 &6- &cYum更新需要重启服务器!重启服务器!重启服务器!;
|
||||
&b2.6.7 &6- &d兼容PerWorldPlugins...;
|
||||
&b2.6.6 &6- &c修复快捷点击按钮触发命令错误...;
|
||||
&b2.6.5 &6- &c修复list命令 &a添加全局能耗统计...;
|
||||
&b2.6.4 &6- &e添加从&bBukkitDev&e下载和更新...;
|
||||
&b2.6.3 &6- &a注入操作延时执行 防止部分任务未注册 添加手动注入...;
|
||||
</update.changes>
|
||||
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package pw.yumc.Yum.inject;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -22,7 +23,7 @@ import pw.yumc.Yum.managers.MonitorManager;
|
||||
|
||||
public class ListenerInjector implements EventExecutor {
|
||||
private final static String prefix = "§6[§bYum §a事件监控§6] ";
|
||||
private final static String inject_error = prefix + "§6插件 §b%s §c注入能耗监控失败!";
|
||||
private final static String inject_error = prefix + "§6插件 §b%s §c注入能耗监控失败 §6注入类: §3%s!";
|
||||
private final static String plugin_is_null = "插件不得为NULL!";
|
||||
private final EventExecutor originalExecutor;
|
||||
|
||||
@ -40,21 +41,33 @@ public class ListenerInjector implements EventExecutor {
|
||||
|
||||
public static void inject(final Plugin plugin) {
|
||||
Validate.notNull(plugin, plugin_is_null);
|
||||
try {
|
||||
final List<RegisteredListener> listeners = HandlerList.getRegisteredListeners(plugin);
|
||||
for (final RegisteredListener listener : listeners) {
|
||||
final List<RegisteredListener> listeners = HandlerList.getRegisteredListeners(plugin);
|
||||
for (final RegisteredListener listener : listeners) {
|
||||
try {
|
||||
if (listener instanceof TimedRegisteredListener) {
|
||||
return;
|
||||
}
|
||||
final EventExecutor originalExecutor = Reflect.on(listener).get("executor");
|
||||
if (originalExecutor instanceof ListenerInjector) {
|
||||
return;
|
||||
if (listener.getClass().getName().contains("PWPRegisteredListener")) {
|
||||
final Field f = Reflect.on(listener).getDeclaredField(RegisteredListener.class, "executor");
|
||||
f.setAccessible(true);
|
||||
final EventExecutor originalExecutor = (EventExecutor) f.get(listener);
|
||||
if (originalExecutor instanceof ListenerInjector) {
|
||||
return;
|
||||
}
|
||||
final ListenerInjector listenerInjector = new ListenerInjector(originalExecutor, plugin);
|
||||
f.set(listener, listenerInjector);
|
||||
} else {
|
||||
final EventExecutor originalExecutor = Reflect.on(listener).get("executor");
|
||||
if (originalExecutor instanceof ListenerInjector) {
|
||||
return;
|
||||
}
|
||||
final ListenerInjector listenerInjector = new ListenerInjector(originalExecutor, plugin);
|
||||
Reflect.on(listener).set("executor", listenerInjector);
|
||||
}
|
||||
final ListenerInjector listenerInjector = new ListenerInjector(originalExecutor, plugin);
|
||||
Reflect.on(listener).set("executor", listenerInjector);
|
||||
} catch (final Throwable e) {
|
||||
PluginKit.sc(String.format(inject_error, plugin.getName(), listener.getClass().getName()));
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
PluginKit.sc(String.format(inject_error, plugin.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user