mirror of
				https://e.coding.net/circlecloud/YumCore.git
				synced 2025-11-03 23:06:02 +00:00 
			
		
		
		
	@@ -6,6 +6,7 @@ import java.lang.reflect.Field;
 | 
				
			|||||||
import java.lang.reflect.InvocationTargetException;
 | 
					import java.lang.reflect.InvocationTargetException;
 | 
				
			||||||
import java.lang.reflect.Method;
 | 
					import java.lang.reflect.Method;
 | 
				
			||||||
import java.net.URL;
 | 
					import java.net.URL;
 | 
				
			||||||
 | 
					import java.net.URLDecoder;
 | 
				
			||||||
import java.util.jar.JarFile;
 | 
					import java.util.jar.JarFile;
 | 
				
			||||||
import java.util.logging.Logger;
 | 
					import java.util.logging.Logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -128,10 +129,22 @@ public class P {
 | 
				
			|||||||
     *            目录
 | 
					     *            目录
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static void saveFile(final String... dirs) {
 | 
					    public static void saveFile(final String... dirs) {
 | 
				
			||||||
 | 
					        saveFile(false, dirs);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 保存文件
 | 
				
			||||||
 | 
					     * 
 | 
				
			||||||
 | 
					     * @param replace
 | 
				
			||||||
 | 
					     *            是否替换
 | 
				
			||||||
 | 
					     * @param dirs
 | 
				
			||||||
 | 
					     *            目录
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static void saveFile(boolean replace, final String... dirs) {
 | 
				
			||||||
        URL url = instance.getClass().getClassLoader().getResource("plugin.yml");
 | 
					        URL url = instance.getClass().getClassLoader().getResource("plugin.yml");
 | 
				
			||||||
        if (url == null) { return; }
 | 
					        if (url == null) { return; }
 | 
				
			||||||
        String upath = url.getFile().substring(url.getFile().indexOf("/") + 1);
 | 
					        String upath = url.getFile().substring(url.getFile().indexOf("/") + 1);
 | 
				
			||||||
        String jarPath = upath.substring(0, upath.indexOf('!'));
 | 
					        String jarPath = URLDecoder.decode(upath.substring(0, upath.indexOf('!')));
 | 
				
			||||||
        if (!new File(jarPath).exists()) {
 | 
					        if (!new File(jarPath).exists()) {
 | 
				
			||||||
            jarPath = "/" + jarPath;
 | 
					            jarPath = "/" + jarPath;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -139,9 +152,16 @@ public class P {
 | 
				
			|||||||
            jar.stream().forEach(je -> {
 | 
					            jar.stream().forEach(je -> {
 | 
				
			||||||
                if (!je.isDirectory()) {
 | 
					                if (!je.isDirectory()) {
 | 
				
			||||||
                    for (final String dir : dirs) {
 | 
					                    for (final String dir : dirs) {
 | 
				
			||||||
                        if (je.getName().startsWith(dir) && !new File(getDataFolder(), je.getName()).exists()) {
 | 
					                        if (je.getName().startsWith(dir)) {
 | 
				
			||||||
 | 
					                            if (!replace) {
 | 
				
			||||||
 | 
					                                // 不替换 并且文件不存在
 | 
				
			||||||
 | 
					                                if (!new File(getDataFolder(), je.getName()).exists()) {
 | 
				
			||||||
                                    instance.saveResource(je.getName(), false);
 | 
					                                    instance.saveResource(je.getName(), false);
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
 | 
					                            } else {
 | 
				
			||||||
 | 
					                                instance.saveResource(je.getName(), true);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user