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