完善了一下下载库以及 TLib 类
This commit is contained in:
@@ -1,28 +1,51 @@
|
||||
package com.ilummc.tlib;
|
||||
|
||||
import com.ilummc.tlib.annotations.Dependency;
|
||||
import com.ilummc.tlib.annotations.Logger;
|
||||
import com.ilummc.tlib.inject.DependencyInjector;
|
||||
import com.ilummc.tlib.inject.TLibPluginManager;
|
||||
import com.ilummc.tlib.util.TLogger;
|
||||
import me.skymc.taboolib.Main;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.ow2.asm:asm:6.1.1")
|
||||
@Dependency(type = Dependency.Type.LIBRARY, maven = "com.zaxxer:HikariCP:3.0.0")
|
||||
public class TLib {
|
||||
|
||||
private static TLib tLib;
|
||||
|
||||
@Logger("§3[§6TLib§3|{1}§3] §f{2}")
|
||||
private TLogger tLogger;
|
||||
|
||||
private TLib() {
|
||||
}
|
||||
|
||||
public TLogger getLogger() {
|
||||
return tLogger;
|
||||
}
|
||||
|
||||
public static TLib getTLib() {
|
||||
return tLib;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public static void init() {
|
||||
new File(Main.getInst().getDataFolder(), "/libs").mkdirs();
|
||||
tLib = new TLib();
|
||||
DependencyInjector.inject(Main.getInst(), tLib);
|
||||
// 注入 PluginLoader 用于加载依赖
|
||||
try {
|
||||
Field field = Bukkit.getServer().getClass().getDeclaredField("pluginManager");
|
||||
field.setAccessible(true);
|
||||
field.set(Bukkit.getServer(), new TLibPluginManager());
|
||||
MsgUtils.send("注入成功");
|
||||
tLib.getLogger().info("注入成功");
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
MsgUtils.warn("注入失败");
|
||||
tLib.getLogger().fatal("注入失败");
|
||||
}
|
||||
new File(Main.getInst().getDataFolder(), "/libs").mkdirs();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user