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