package team.unstudio.udpl.util;

import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URL;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import javax.annotation.Nonnull;

import org.apache.commons.lang.Validate;
import org.bukkit.plugin.java.JavaPlugin;

public final class PluginUtils {

	private PluginUtils() {}
	
	public static void saveDirectory(@Nonnull JavaPlugin plugin,@Nonnull String resourcePath,boolean replace){
		Validate.notNull(plugin);
		Validate.notEmpty(resourcePath);
		resourcePath = resourcePath.replace('\\', '/');
		
		plugin.getLogger().info("Plugin save directory. Path: " + resourcePath);
		
		URL url = plugin.getClass().getClassLoader().getResource(resourcePath);
		if(url == null)
			throw new IllegalArgumentException("Directory isn't found. Path: "+resourcePath);
		
		JarURLConnection jarConn;
		try {
			jarConn = (JarURLConnection) url.openConnection();
			JarFile jarFile = jarConn.getJarFile();
			Enumeration<JarEntry> entrys = jarFile.entries();
			while(entrys.hasMoreElements()){
				JarEntry entry = entrys.nextElement();
				if(entry.getName().startsWith(resourcePath)&&!entry.isDirectory())
					plugin.saveResource(entry.getName(), replace);
			}
		} catch (IOException e) {
			plugin.getLogger().warning("Plugin save directory failed. Path: " + resourcePath);
			e.printStackTrace();
		}
	}
}

@@ -289,16 +289,112 @@
 idate;%0D%0A
+import org.bukkit.Bukkit;%0D%0Aimport org.bukkit.event.Listener;%0D%0Aimport org.bukkit.plugin.Plugin;%0D%0A
 import o
@@ -1542,11 +1542,150 @@
 %09%7D%0D%0A%09%7D%0D%0A
+%09%0D%0A%09public static void registerEvent(Listener listener,Plugin plugin)%7B%0D%0A%09%09Bukkit.getPluginManager().registerEvents(listener, plugin);%0D%0A%09%7D%0D%0A
 %7D%0D%0A

Update PluginUtils