summaryrefslogtreecommitdiffstats
path: root/EssentialsUpdate/src/net/ess3/update/states/EssentialsGeoIP.java
blob: 6d91a0cb913bf6b03f0a703a4afe8e9496f32b80 (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
package net.ess3.update.states;

import net.ess3.update.AbstractWorkListener;
import net.ess3.update.tasks.InstallModule;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;


public class EssentialsGeoIP extends AbstractYesNoState
{
	public EssentialsGeoIP(final StateMap states)
	{
		super(states, null);
	}

	@Override
	public boolean guessAnswer()
	{
		final Plugin plugin = Bukkit.getPluginManager().getPlugin("EssentialsGeoIP");
		if (plugin != null)
		{
			setAnswer(true);
			return true;
		}
		return false;
	}

	@Override
	public void askQuestion(final Player sender)
	{
		sender.sendMessage("Do you want to install EssentialsGeoIP? (yes/no)");
		sender.sendMessage("EssentialsGeoIP performs a IP lookup on joining players");
		sender.sendMessage("It allows you get a rough idea of where a player is from.");
	}

	@Override
	public void doWork(final AbstractWorkListener listener)
	{
		if (getAnswer())
		{
			new InstallModule(listener, "EssentialsGeoIP").start();
			return;
		}
		listener.onWorkDone();
	}
}