mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-05-29 18:47:32 +00:00
Basic automatic updates downloader
This commit is contained in:
parent
d5cb9ab965
commit
e8b8d26bdb
1 changed files with 31 additions and 5 deletions
|
@ -1,9 +1,14 @@
|
||||||
package com.earth2me.essentials.update;
|
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;
|
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)
|
public UpdatesDownloader(final Plugin plugin, final VersionInfo newVersionInfo)
|
||||||
{
|
{
|
||||||
|
@ -12,17 +17,38 @@ public class UpdatesDownloader extends WorkListener
|
||||||
|
|
||||||
public void start()
|
public void start()
|
||||||
{
|
{
|
||||||
|
iterator = getNewVersionInfo().getModules().entrySet().iterator();
|
||||||
|
Bukkit.getScheduler().scheduleAsyncDelayedTask(getPlugin(), this);
|
||||||
|
}
|
||||||
|
private transient Iterator<Entry<String, ModuleInfo>> iterator;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
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
|
@Override
|
||||||
public void onWorkAbort(String message)
|
public void onWorkAbort(final String message)
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
Bukkit.getLogger().log(Level.SEVERE, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWorkDone(String message)
|
public void onWorkDone(final String message)
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
Bukkit.getLogger().log(Level.INFO, message);
|
||||||
|
Bukkit.getScheduler().scheduleAsyncDelayedTask(getPlugin(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue