完善了一下下载库以及 TLib 类
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package com.ilummc.tlib.inject;
|
||||
|
||||
import com.ilummc.tlib.TLib;
|
||||
import com.ilummc.tlib.annotations.Dependencies;
|
||||
import com.ilummc.tlib.annotations.Dependency;
|
||||
import com.ilummc.tlib.annotations.Logger;
|
||||
import com.ilummc.tlib.annotations.PluginInstance;
|
||||
import com.ilummc.tlib.dependency.TDependency;
|
||||
import com.ilummc.tlib.util.TLogger;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -19,6 +19,7 @@ public class DependencyInjector {
|
||||
injectLogger(plugin, o);
|
||||
injectPluginInstance(plugin, o);
|
||||
injectDependencies(plugin, o);
|
||||
injectConfig(plugin, o);
|
||||
}
|
||||
|
||||
static void injectOnEnable(Plugin plugin) {
|
||||
@@ -29,6 +30,10 @@ public class DependencyInjector {
|
||||
|
||||
}
|
||||
|
||||
private static void injectConfig(Plugin plugin, Object o) {
|
||||
|
||||
}
|
||||
|
||||
private static void injectLogger(Plugin plugin, Object o) {
|
||||
try {
|
||||
for (Field field : o.getClass().getDeclaredFields()) {
|
||||
@@ -56,7 +61,7 @@ public class DependencyInjector {
|
||||
Plugin pl;
|
||||
if ((pl = Bukkit.getPluginManager().getPlugin(instance.value())) == null) {
|
||||
if (!TDependency.requestPlugin(instance.value())) {
|
||||
MsgUtils.warn(plugin.getName() + " 所需的依赖插件 " + instance.value() + " 自动加载失败");
|
||||
TLib.getTLib().getLogger().warn(plugin.getName() + " 所需的依赖插件 " + instance.value() + " 自动加载失败");
|
||||
return;
|
||||
} else {
|
||||
pl = Bukkit.getPluginManager().getPlugin(instance.value());
|
||||
@@ -79,20 +84,22 @@ public class DependencyInjector {
|
||||
if (d2 != null) dependencies = new Dependency[]{d2};
|
||||
}
|
||||
if (dependencies.length != 0) {
|
||||
MsgUtils.send("正在加载 " + plugin.getName() + " 插件所需的依赖");
|
||||
TLib.getTLib().getLogger().info("正在加载 " + plugin.getName() + " 插件所需的依赖");
|
||||
for (Dependency dependency : dependencies) {
|
||||
if (dependency.type() == Dependency.Type.PLUGIN)
|
||||
if (TDependency.requestPlugin(dependency.args()))
|
||||
MsgUtils.send(plugin.getName() + " 请求的插件 " + dependency.args()[0] + " 加载成功。");
|
||||
if (TDependency.requestPlugin(dependency.plugin()))
|
||||
TLib.getTLib().getLogger().info(" " + plugin.getName() + " 请求的插件 " + dependency.plugin() + " 加载成功。");
|
||||
else
|
||||
MsgUtils.warn(plugin.getName() + " 请求的插件 " + dependency.args()[0] + " 加载失败。");
|
||||
TLib.getTLib().getLogger().warn(" " + plugin.getName() + " 请求的插件 " + dependency.plugin() + " 加载失败。");
|
||||
if (dependency.type() == Dependency.Type.LIBRARY)
|
||||
if (TDependency.requestLib(dependency.args()))
|
||||
MsgUtils.send(plugin.getName() + " 请求的库文件 " + String.join(":", dependency.args()) + " 加载成功。");
|
||||
if (TDependency.requestLib(dependency.maven(), dependency.mavenRepo(), dependency.url()))
|
||||
TLib.getTLib().getLogger().info(" " + plugin.getName() + " 请求的库文件 " + String.join(":",
|
||||
dependency.maven()) + " 加载成功。");
|
||||
else
|
||||
MsgUtils.send(plugin.getName() + " 请求的库文件 " + String.join(":", dependency.args()) + " 加载失败。");
|
||||
TLib.getTLib().getLogger().warn(" " + plugin.getName() + " 请求的库文件 " + String.join(":",
|
||||
dependency.maven()) + " 加载失败。");
|
||||
}
|
||||
MsgUtils.send("依赖加载完成");
|
||||
TLib.getTLib().getLogger().info("依赖加载完成");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.ilummc.tlib.inject;
|
||||
|
||||
public class TConfigInjector {
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user