| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -3,12 +3,7 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				package cn.citycraft.Yum.manager;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.io.BufferedReader;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.io.IOException;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.io.InputStreamReader;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.net.URL;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.util.ArrayList;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.util.HashMap;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.util.Iterator;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.util.List;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.util.Map;
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -18,14 +13,14 @@ import org.bukkit.Bukkit;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import org.bukkit.command.CommandSender;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import org.bukkit.configuration.file.FileConfiguration;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import com.google.common.base.Charsets;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import com.google.gson.Gson;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import com.google.gson.JsonSyntaxException;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import com.google.gson.reflect.TypeToken;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cn.citycraft.Yum.manager.Repositories.PackageInfo;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cn.citycraft.Yum.manager.Repositories.Plugin;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cn.citycraft.Yum.manager.Repositories.Repository;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cn.citycraft.PluginHelper.jsonresult.JsonResult;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cn.citycraft.PluginHelper.utils.IOUtil;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cn.citycraft.Yum.manager.RepoSerialization.PackageInfo;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cn.citycraft.Yum.manager.RepoSerialization.Plugin;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cn.citycraft.Yum.manager.RepoSerialization.Repositories;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cn.citycraft.Yum.manager.RepoSerialization.Repository;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				/**
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 * 仓库管理类
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -33,21 +28,17 @@ import cn.citycraft.Yum.manager.Repositories.Repository;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 * @author 蒋天蓓
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				public class RepositoryManager {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Gson gson;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					JsonResult jr = JsonResult.newJsonResult();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					org.bukkit.plugin.Plugin main;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Map<String, PluginInfo> plugins;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					List<String> repos;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					RepoCache repocache;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public RepositoryManager(final org.bukkit.plugin.Plugin plugin) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						this.main = plugin;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						gson = new Gson();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						plugins = new HashMap<String, PluginInfo>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						repos = new ArrayList<String>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						repocache = new RepoCache();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public boolean addPackage(final CommandSender sender, final String urlstring) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final String json = getHtml(urlstring);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final String json = IOUtil.getData(urlstring);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (json == null || json.isEmpty()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -68,33 +59,28 @@ public class RepositoryManager {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (!url.endsWith("repo.info")) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							url = url + "/repo.info";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (urllength == 0 || repos.contains(url)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final Repositories repo = repocache.addRepo(urlstring);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (repo == null) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						repos.add(urlstring);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return updateRepositories(sender, urlstring);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return updateRepositories(sender, repo);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public void cacheToJson(final FileConfiguration config) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						config.set("repocache", gson.toJson(repos));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						config.set("plugincache", gson.toJson(plugins));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						config.set("reposcache", repocache.toString());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public void clean() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						plugins.clear();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						repocache.getPlugins().clear();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public boolean delRepositories(final CommandSender sender, final String urlstring) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (urlstring.isEmpty() || !repos.contains(urlstring)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						repos.remove(urlstring);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return repocache.removeRepo(urlstring);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public List<PluginInfo> getAllPlugin() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final List<PluginInfo> li = new ArrayList<PluginInfo>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (final Entry<String, PluginInfo> plugin : plugins.entrySet()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (final Entry<String, PluginInfo> plugin : repocache.getPlugins().entrySet()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							li.add(plugin.getValue());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return li;
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -102,7 +88,7 @@ public class RepositoryManager {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public List<String> getAllPluginName() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final List<String> li = new ArrayList<String>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (final Entry<String, PluginInfo> plugin : plugins.entrySet()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (final Entry<String, PluginInfo> plugin : repocache.getPlugins().entrySet()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							li.add(plugin.getValue().plugin.name);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return li;
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -110,30 +96,15 @@ public class RepositoryManager {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public List<String> getAllPluginsInfo() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final List<String> li = new ArrayList<String>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (final Entry<String, PluginInfo> plugin : plugins.entrySet()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (final Entry<String, PluginInfo> plugin : repocache.getPlugins().entrySet()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							final Plugin pl = plugin.getValue().plugin;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							li.add(String.format("§d%s §a%s(%s) §6- §e%s", plugin.getValue().repo, pl.name, pl.version, pl.description));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return li;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public String getHtml(final String urlstring) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						String html = "";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						try {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							final URL url = new URL(urlstring);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							final BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), Charsets.UTF_8));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							String line;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							while ((line = br.readLine()) != null) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								html += line;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return html;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						} catch (final IOException e) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return null;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public PluginInfo getPlugin(final String name) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (final Entry<String, PluginInfo> plugin : plugins.entrySet()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (final Entry<String, PluginInfo> plugin : repocache.getPlugins().entrySet()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (plugin.getValue().plugin.name.equalsIgnoreCase(name)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								return plugin.getValue();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -143,7 +114,7 @@ public class RepositoryManager {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public List<PluginInfo> getPluginInfo(final String name) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final List<PluginInfo> li = new ArrayList<PluginInfo>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (final Entry<String, PluginInfo> plugin : plugins.entrySet()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (final Entry<String, PluginInfo> plugin : repocache.getPlugins().entrySet()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (plugin.getValue().plugin.name.equalsIgnoreCase(name)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								li.add(plugin.getValue());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -152,50 +123,39 @@ public class RepositoryManager {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public PluginInfo getPluginInfo(final String groupId, final String artifactId) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return plugins.get(groupId + "." + artifactId);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return repocache.getPlugins().get(groupId + "." + artifactId);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public Map<String, PluginInfo> getPlugins() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return plugins;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return repocache.getPlugins();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public List<String> getRepos() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return repos;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public Map<String, Repositories> getRepos() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return repocache.getRepos();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public boolean jsonToCache(final FileConfiguration config) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final String repocache = config.getString("repocache");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final String plugincache = config.getString("plugincache");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						try {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (repocache != null && !repocache.isEmpty()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								repos = gson.fromJson(repocache, new TypeToken<List<String>>() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								}.getType());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							final String reposcache = config.getString("reposcache");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (reposcache != null && !reposcache.isEmpty()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								repocache = RepoCache.fromJson(reposcache);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								return true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (plugincache != null && !plugincache.isEmpty()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								plugins = gson.fromJson(plugincache, new TypeToken<Map<String, PluginInfo>>() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								}.getType());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						} catch (final JsonSyntaxException e) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						} catch (final Exception e) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public PackageInfo jsonToPackage(final String json) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						try {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return gson.fromJson(json, PackageInfo.class);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return jr.fromJson(json, PackageInfo.class);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						} catch (final JsonSyntaxException e) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return null;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public List<Repository> jsonToRepositories(final String json) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						try {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return gson.fromJson(json, new TypeToken<List<Repository>>() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}.getType());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						} catch (final JsonSyntaxException e) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return new ArrayList<Repository>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public Repositories jsonToRepositories(final String json) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return jr.fromJson(json, Repositories.class);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public void updatePackage(final CommandSender sender, final PackageInfo pkg) {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -204,43 +164,39 @@ public class RepositoryManager {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							pi.plugin = plugin;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							pi.url = pkg.url;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							pi.repo = pkg.name;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							plugins.put(plugin.groupId + "." + plugin.artifactId, pi);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							repocache.getPlugins().put(plugin.groupId + "." + plugin.artifactId, pi);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						sender.sendMessage("§6仓库: §e" + pkg.name + " §a更新成功!");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public boolean updateRepositories(final CommandSender sender) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						plugins.clear();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (repos.isEmpty()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							repos.add("http://citycraft.cn/repo/repo.info");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						repocache.getPlugins().clear();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (repocache.getRepos().isEmpty()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							repocache.addRepo("http://citycraft.cn/yumcenter/repo.info");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final Iterator<String> keys = repos.iterator();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final Iterator<Entry<String, Repositories>> keys = repocache.getRepos().entrySet().iterator();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						while (keys.hasNext()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							final String string = keys.next();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (updateRepositories(sender, string)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								sender.sendMessage("§6源: §e" + string + " §a更新成功!");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							final Entry<String, Repositories> string = keys.next();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							final Repositories repo = repocache.getRepo(string.getKey());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if (updateRepositories(sender, repo)) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								sender.sendMessage("§6源: §e" + repo.name + " §a更新成功!");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							} else {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								sender.sendMessage("§6源: §e" + string + " §c未找到任何仓库信息 已删除!");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								sender.sendMessage("§6源: §e" + string.getKey() + " §c未找到任何仓库信息 已删除!");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								keys.remove();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public boolean updateRepositories(CommandSender sender, final String urlstring) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					public boolean updateRepositories(CommandSender sender, final Repositories repocenter) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (sender == null) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							sender = Bukkit.getConsoleSender();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final String json = getHtml(urlstring);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (json == null || json.isEmpty()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (repocenter == null || repocenter.repos.isEmpty()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						final List<Repository> lrepo = jsonToRepositories(json);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (lrepo == null || lrepo.isEmpty()) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							return true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (final Repository repository : lrepo) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							addPackage(sender, repository.url);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (final Repository repo : repocenter.repos) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							addPackage(sender, repo.url);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				 
 |