clean up manager...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-09-22 20:32:17 +08:00
parent 39f72995a2
commit acf587b022
2 changed files with 7 additions and 8 deletions

View File

@ -527,7 +527,6 @@ public class PluginsManager {
} catch (InvalidDescriptionException e) { } catch (InvalidDescriptionException e) {
sender.sendMessage("§4异常: §c" + e.getMessage()); sender.sendMessage("§4异常: §c" + e.getMessage());
sender.sendMessage("§4文件: §c" + file.getName() + " 的plugin.yml文件存在错误!"); sender.sendMessage("§4文件: §c" + file.getName() + " 的plugin.yml文件存在错误!");
continue;
} }
} }
sender.sendMessage("§6升级: §a所有插件升级完毕!"); sender.sendMessage("§6升级: §a所有插件升级完毕!");

View File

@ -46,7 +46,7 @@ public class RepositoryManager {
public boolean addPackage(CommandSender sender, String urlstring) { public boolean addPackage(CommandSender sender, String urlstring) {
String json = getHtml(urlstring); String json = getHtml(urlstring);
if (json == "") if (json.isEmpty())
return false; return false;
PackageInfo pkg = jsonToPackage(json); PackageInfo pkg = jsonToPackage(json);
if (pkg == null) if (pkg == null)
@ -56,7 +56,7 @@ public class RepositoryManager {
} }
public boolean addRepositories(CommandSender sender, String urlstring) { public boolean addRepositories(CommandSender sender, String urlstring) {
if (urlstring == null || urlstring.isEmpty()) if (urlstring.isEmpty())
return false; return false;
repos.add(urlstring); repos.add(urlstring);
return updateRepositories(sender, urlstring); return updateRepositories(sender, urlstring);
@ -131,10 +131,10 @@ public class RepositoryManager {
String repocache = config.getString("repocache"); String repocache = config.getString("repocache");
String plugincache = config.getString("plugincache"); String plugincache = config.getString("plugincache");
try { try {
if (repocache != null && repocache != "") if (!repocache.isEmpty())
repos = gson.fromJson(repocache, new TypeToken<List<String>>() { repos = gson.fromJson(repocache, new TypeToken<List<String>>() {
}.getType()); }.getType());
if (plugincache != null && plugincache != "") if (!plugincache.isEmpty())
plugins = gson.fromJson(plugincache, new TypeToken<HashMap<String, PluginInfo>>() { plugins = gson.fromJson(plugincache, new TypeToken<HashMap<String, PluginInfo>>() {
}.getType()); }.getType());
return true; return true;
@ -156,7 +156,7 @@ public class RepositoryManager {
return gson.fromJson(json, new TypeToken<List<Repository>>() { return gson.fromJson(json, new TypeToken<List<Repository>>() {
}.getType()); }.getType());
} catch (JsonSyntaxException e) { } catch (JsonSyntaxException e) {
return null; return new ArrayList<Repository>();
} }
} }
@ -187,10 +187,10 @@ public class RepositoryManager {
if (!urlstring.endsWith("repo.info")) if (!urlstring.endsWith("repo.info"))
urlstring = urlstring + "/repo.info"; urlstring = urlstring + "/repo.info";
String json = getHtml(urlstring); String json = getHtml(urlstring);
if (json == "") if (json.isEmpty())
return false; return false;
List<Repository> lrepo = jsonToRepositories(json); List<Repository> lrepo = jsonToRepositories(json);
if (lrepo == null) if (lrepo.isEmpty())
return false; return false;
for (Repository repository : lrepo) for (Repository repository : lrepo)
addPackage(sender, repository.url); addPackage(sender, repository.url);