synchronized add repo...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-09-01 19:47:44 +08:00
parent 58fc3a4549
commit b7c492c970

View File

@ -48,7 +48,7 @@ public class RepositoryManager {
plugins.clear(); plugins.clear();
} }
public void updatePackage(Package pkg) { public synchronized void updatePackage(Package pkg) {
for (Plugin plugin : pkg.plugins) { for (Plugin plugin : pkg.plugins) {
PluginInfo pi = new PluginInfo(); PluginInfo pi = new PluginInfo();
pi.plugin = plugin; pi.plugin = plugin;
@ -58,12 +58,12 @@ public class RepositoryManager {
} }
} }
public void cacheToJson(FileConfiguration config) { public synchronized void cacheToJson(FileConfiguration config) {
config.set("repocache", gson.toJson(repos)); config.set("repocache", gson.toJson(repos));
config.set("plugincache", gson.toJson(plugins)); config.set("plugincache", gson.toJson(plugins));
} }
public boolean jsonToCache(FileConfiguration config) { public synchronized boolean jsonToCache(FileConfiguration config) {
String repocache = config.getString("repocache"); String repocache = config.getString("repocache");
String plugincache = config.getString("plugincache"); String plugincache = config.getString("plugincache");
try { try {
@ -79,7 +79,7 @@ public class RepositoryManager {
} }
} }
public boolean updateRepositories(CommandSender sender) { public synchronized boolean updateRepositories(CommandSender sender) {
plugins.clear(); plugins.clear();
for (String string : repos) { for (String string : repos) {
if (addRepositories(string)) { if (addRepositories(string)) {
@ -91,7 +91,7 @@ public class RepositoryManager {
return true; return true;
} }
public boolean addRepositories(String urlstring) { public synchronized boolean addRepositories(String urlstring) {
String json = getHtml(urlstring); String json = getHtml(urlstring);
if (json == "") { if (json == "") {
return false; return false;
@ -107,7 +107,7 @@ public class RepositoryManager {
return true; return true;
} }
public boolean addPackage(String urlstring) { public synchronized boolean addPackage(String urlstring) {
String json = getHtml(urlstring); String json = getHtml(urlstring);
if (json == "") { if (json == "") {
return false; return false;