summaryrefslogtreecommitdiffstats
path: root/EssentialsUpdate/src/com/earth2me/essentials/update/tasks/SelfUpdate.java
blob: 3baf86be7d2d6e4f52e54a6563bd4e7b80336913 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.earth2me.essentials.update.tasks;

import com.earth2me.essentials.update.AbstractWorkListener;
import org.bukkit.Bukkit;


public class SelfUpdate extends AbstractWorkListener implements Task, Runnable
{
	private final transient AbstractWorkListener listener;

	public SelfUpdate(final AbstractWorkListener 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();
			}
		});
	}
}