TabooLib v4.25
+ 新增 TConfiguration 工具,与 TConfigWatcher 联动创建能够自动重载的配置文件。(尚未测试) + 新增 TFunction 注解,自动执行载入与卸载方法。(变懒第一步,放弃注册步骤) + 调整 TLogger 工具,允许以自定义名称创建,并支持在 BungeeCord 下使用。 + 调整 TListener 与 Instantiable 注解,不会再重复读取插件类了。 + 调整 ReflectionUtils 工具,对部分语法进行了修改。 + 调整 TabooLib 类下的 isSpigot 与 getVersion 算法。 + 重做 AnvilContainerAPI 工具,现在可以正常使用了。(丢人玩意儿终于重写了) + InstanceHandler 类更名为 InstantiableLoader + MsgUtils 类被赋予尊贵的 @Deprecated
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package me.skymc.taboolib.object;
|
||||
|
||||
import com.ilummc.tlib.util.Ref;
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.fileutils.FileUtils;
|
||||
import me.skymc.taboolib.TabooLibLoader;
|
||||
import me.skymc.taboolib.listener.TListener;
|
||||
import me.skymc.taboolib.methods.ReflectionUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -19,11 +19,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @Since 2018-08-27 10:04
|
||||
*/
|
||||
@TListener
|
||||
public class InstanceHandler implements Listener {
|
||||
public class InstantiableLoader implements Listener {
|
||||
|
||||
private static ConcurrentHashMap<String, Object> instance = new ConcurrentHashMap<>();
|
||||
|
||||
public InstanceHandler() {
|
||||
public InstantiableLoader() {
|
||||
loadInstantiable();
|
||||
}
|
||||
|
||||
@@ -52,19 +52,18 @@ public class InstanceHandler implements Listener {
|
||||
}
|
||||
|
||||
public static void loadInstantiable(Plugin plugin) {
|
||||
if (!(plugin.equals(TabooLib.instance()) || TabooLib.isDependTabooLib(plugin))) {
|
||||
return;
|
||||
}
|
||||
for (Class pluginClass : FileUtils.getClasses(plugin)) {
|
||||
if (pluginClass.isAnnotationPresent(Instantiable.class)) {
|
||||
Instantiable instantiable = (Instantiable) pluginClass.getAnnotation(Instantiable.class);
|
||||
try {
|
||||
instance.put(instantiable.value(), pluginClass.newInstance());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
TabooLibLoader.getPluginClasses(plugin).ifPresent(classes -> {
|
||||
for (Class pluginClass : classes) {
|
||||
if (pluginClass.isAnnotationPresent(Instantiable.class)) {
|
||||
Instantiable instantiable = (Instantiable) pluginClass.getAnnotation(Instantiable.class);
|
||||
try {
|
||||
instance.put(instantiable.value(), ReflectionUtils.instantiateObject(pluginClass));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// *********************************
|
||||
Reference in New Issue
Block a user