mirror of
				https://e.coding.net/circlecloud/YumCore.git
				synced 2025-11-03 23:06:02 +00:00 
			
		
		
		
	@@ -1,13 +1,15 @@
 | 
				
			|||||||
package pw.yumc.YumCore.bukkit;
 | 
					package pw.yumc.YumCore.bukkit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.File;
 | 
				
			||||||
 | 
					import java.lang.reflect.Field;
 | 
				
			||||||
 | 
					import java.lang.reflect.InvocationTargetException;
 | 
				
			||||||
 | 
					import java.lang.reflect.Method;
 | 
				
			||||||
 | 
					import java.util.logging.Logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.bukkit.command.PluginCommand;
 | 
					import org.bukkit.command.PluginCommand;
 | 
				
			||||||
import org.bukkit.plugin.PluginDescriptionFile;
 | 
					import org.bukkit.plugin.PluginDescriptionFile;
 | 
				
			||||||
import org.bukkit.plugin.java.JavaPlugin;
 | 
					import org.bukkit.plugin.java.JavaPlugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.File;
 | 
					 | 
				
			||||||
import java.lang.reflect.Field;
 | 
					 | 
				
			||||||
import java.util.logging.Logger;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 插件Instance获取类
 | 
					 * 插件Instance获取类
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -19,6 +21,10 @@ public class P {
 | 
				
			|||||||
     * 插件实例
 | 
					     * 插件实例
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static JavaPlugin instance;
 | 
					    public static JavaPlugin instance;
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 插件配置方法
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static Method getInjectConfigMethod;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static {
 | 
					    static {
 | 
				
			||||||
        Object pluginClassLoader = P.class.getClassLoader();
 | 
					        Object pluginClassLoader = P.class.getClassLoader();
 | 
				
			||||||
@@ -29,6 +35,11 @@ public class P {
 | 
				
			|||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            getInjectConfigMethod = instance.getClass().getMethod("get" + instance.getName() + "Config");
 | 
				
			||||||
 | 
					        } catch (NoSuchMethodException e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -51,6 +62,20 @@ public class P {
 | 
				
			|||||||
        return (FC) instance.getConfig();
 | 
					        return (FC) instance.getConfig();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @param <FC>
 | 
				
			||||||
 | 
					     *            注入配置源类型
 | 
				
			||||||
 | 
					     * @return 获得插件注入配置
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @SuppressWarnings("unchecked")
 | 
				
			||||||
 | 
					    public static <FC> FC getInjectConfig() {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            return (FC) getInjectConfigMethod.invoke(instance);
 | 
				
			||||||
 | 
					        } catch (IllegalAccessException | InvocationTargetException ignored) {
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return getConfig();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return 获得插件文件夹
 | 
					     * @return 获得插件文件夹
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user