diff options
author | snowleo <schneeleo@gmail.com> | 2011-10-26 20:25:09 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-10-26 20:25:09 +0200 |
commit | da01d35e2bbafdbe39eddf92ea63a96c21b9054d (patch) | |
tree | 2d30b22e4c60f577e24fd0932f0ef95ecfe1cc42 | |
parent | c15d26acc0d044ec08be3abd65fb2dd41c0576c8 (diff) | |
download | Essentials-da01d35e2bbafdbe39eddf92ea63a96c21b9054d.tar Essentials-da01d35e2bbafdbe39eddf92ea63a96c21b9054d.tar.gz Essentials-da01d35e2bbafdbe39eddf92ea63a96c21b9054d.tar.lz Essentials-da01d35e2bbafdbe39eddf92ea63a96c21b9054d.tar.xz Essentials-da01d35e2bbafdbe39eddf92ea63a96c21b9054d.zip |
Basic automatic updates downloader
-rw-r--r-- | EssentialsUpdate/src/com/earth2me/essentials/update/UpdatesDownloader.java | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdatesDownloader.java b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdatesDownloader.java index 717163726..d13d0d41b 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/UpdatesDownloader.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/UpdatesDownloader.java @@ -1,9 +1,14 @@ package com.earth2me.essentials.update; +import com.earth2me.essentials.update.tasks.InstallModule; +import java.util.Iterator; +import java.util.Map.Entry; +import java.util.logging.Level; +import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; -public class UpdatesDownloader extends WorkListener +public class UpdatesDownloader extends WorkListener implements Runnable { public UpdatesDownloader(final Plugin plugin, final VersionInfo newVersionInfo) { @@ -12,17 +17,38 @@ public class UpdatesDownloader extends WorkListener public void start() { + iterator = getNewVersionInfo().getModules().entrySet().iterator(); + Bukkit.getScheduler().scheduleAsyncDelayedTask(getPlugin(), this); } + private transient Iterator<Entry<String, ModuleInfo>> iterator; @Override - public void onWorkAbort(String message) + public void run() { - throw new UnsupportedOperationException("Not supported yet."); + if (iterator.hasNext()) + { + final Entry<String, ModuleInfo> entry = iterator.next(); + if (Bukkit.getPluginManager().getPlugin(entry.getKey()) == null) + { + run(); + } + else + { + new InstallModule(this, entry.getKey()).start(); + } + } } @Override - public void onWorkDone(String message) + public void onWorkAbort(final String message) { - throw new UnsupportedOperationException("Not supported yet."); + Bukkit.getLogger().log(Level.SEVERE, message); + } + + @Override + public void onWorkDone(final String message) + { + Bukkit.getLogger().log(Level.INFO, message); + Bukkit.getScheduler().scheduleAsyncDelayedTask(getPlugin(), this); } } |