mirror of
https://github.com/essentials/Essentials.git
synced 2025-09-25 21:59:08 +02:00
The state machine now handles both manual updating and installation.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package com.earth2me.essentials.update.tasks;
|
||||
|
||||
import com.earth2me.essentials.update.WorkListener;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
||||
public class SelfUpdate extends WorkListener implements Task, Runnable
|
||||
{
|
||||
private final transient WorkListener listener;
|
||||
|
||||
public SelfUpdate(final WorkListener listener)
|
||||
{
|
||||
super(listener.getPlugin(), listener.getNewVersionInfo());
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorkAbort(final String message)
|
||||
{
|
||||
listener.onWorkAbort(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorkDone(final String message)
|
||||
{
|
||||
listener.onWorkDone(message);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Bukkit.getServer().reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(getPlugin(), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
new InstallModule(SelfUpdate.this, "EssentialsUpdate").start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user