修复:几个加载插件时的异常
This commit is contained in:
parent
b22ade7cff
commit
7758ac2241
@ -22,7 +22,7 @@ public class TLib {
|
|||||||
@Logger("§8[§3§lTabooLib§8][§r{1}§8] §f{2}")
|
@Logger("§8[§3§lTabooLib§8][§r{1}§8] §f{2}")
|
||||||
private TLogger tLogger;
|
private TLogger tLogger;
|
||||||
|
|
||||||
private TLibConfig config;
|
private TLibConfig config = new TLibConfig();
|
||||||
|
|
||||||
private TConfigWatcher configWatcher = new TConfigWatcher();
|
private TConfigWatcher configWatcher = new TConfigWatcher();
|
||||||
|
|
||||||
@ -75,5 +75,4 @@ public class TLib {
|
|||||||
return downloadPoolSize;
|
return downloadPoolSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ public class TDependency {
|
|||||||
try {
|
try {
|
||||||
downloadFinish = downloadMaven(repo, arr[0], arr[1], arr[2], file, url);
|
downloadFinish = downloadMaven(repo, arr[0], arr[1], arr[2], file, url);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
ignored.printStackTrace();
|
||||||
}
|
}
|
||||||
if (downloadFinish) {
|
if (downloadFinish) {
|
||||||
TDependencyLoader.addToPath(Main.getInst(), file);
|
TDependencyLoader.addToPath(Main.getInst(), file);
|
||||||
@ -63,7 +64,7 @@ public class TDependency {
|
|||||||
ReentrantLock lock = new ReentrantLock();
|
ReentrantLock lock = new ReentrantLock();
|
||||||
AtomicBoolean failed = new AtomicBoolean(false);
|
AtomicBoolean failed = new AtomicBoolean(false);
|
||||||
EagletTask task = new EagletTask()
|
EagletTask task = new EagletTask()
|
||||||
.url(dl == null ? url + "/" + groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + ".jar" : dl)
|
.url(dl.length() == 0 ? url + "/" + groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + ".jar" : dl)
|
||||||
.file(target)
|
.file(target)
|
||||||
.setThreads(TLib.getTLib().getConfig().getDownloadPoolSize())
|
.setThreads(TLib.getTLib().getConfig().getDownloadPoolSize())
|
||||||
.setOnStart(event -> lock.lock())
|
.setOnStart(event -> lock.lock())
|
||||||
|
@ -9,16 +9,27 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class DependencyInjector {
|
public class DependencyInjector {
|
||||||
|
|
||||||
public static void inject(Plugin plugin, Object o) {
|
public static void inject(Plugin plugin, Object o) {
|
||||||
injectLogger(plugin, o);
|
try {
|
||||||
injectPluginInstance(plugin, o);
|
injectConfig(plugin, o);
|
||||||
injectDependencies(plugin, o);
|
} catch (NoClassDefFoundError ignored) {
|
||||||
injectConfig(plugin, o);
|
}
|
||||||
|
try {
|
||||||
|
injectLogger(plugin, o);
|
||||||
|
} catch (NoClassDefFoundError ignored) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
injectPluginInstance(plugin, o);
|
||||||
|
} catch (NoClassDefFoundError ignored) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
injectDependencies(plugin, o);
|
||||||
|
} catch (NoClassDefFoundError ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void injectOnEnable(Plugin plugin) {
|
static void injectOnEnable(Plugin plugin) {
|
||||||
@ -26,11 +37,17 @@ public class DependencyInjector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void onDisable(Plugin plugin) {
|
static void onDisable(Plugin plugin) {
|
||||||
ejectConfig(plugin, plugin);
|
try {
|
||||||
|
ejectConfig(plugin, plugin);
|
||||||
|
} catch (NoClassDefFoundError ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void eject(Plugin plugin, Object o) {
|
public static void eject(Plugin plugin, Object o) {
|
||||||
ejectConfig(plugin, o);
|
try {
|
||||||
|
ejectConfig(plugin, o);
|
||||||
|
} catch (NoClassDefFoundError ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ejectConfig(Plugin plugin, Object o) {
|
private static void ejectConfig(Plugin plugin, Object o) {
|
||||||
@ -79,7 +96,7 @@ public class DependencyInjector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,15 +112,15 @@ public class DependencyInjector {
|
|||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(o, tLogger);
|
field.set(o, tLogger);
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void injectPluginInstance(Plugin plugin, Object o) {
|
private static void injectPluginInstance(Plugin plugin, Object o) {
|
||||||
try {
|
for (Field field : o.getClass().getDeclaredFields()) {
|
||||||
for (Field field : o.getClass().getDeclaredFields()) {
|
try {
|
||||||
PluginInstance instance;
|
PluginInstance instance;
|
||||||
if ((instance = field.getAnnotation(PluginInstance.class)) != null) {
|
if ((instance = field.getAnnotation(PluginInstance.class)) != null) {
|
||||||
if (!field.isAccessible())
|
if (!field.isAccessible())
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
@ -120,8 +137,8 @@ public class DependencyInjector {
|
|||||||
if (pl != null)
|
if (pl != null)
|
||||||
field.set(o, pl);
|
field.set(o, pl);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ignored) {
|
||||||
} catch (Exception ignored) {
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user