summaryrefslogtreecommitdiffstats
path: root/EssentialsUpdate/src/net/ess3/update/states/UpdateOrInstallation.java
blob: e8495fe2c4d95d8f5662c585d7d0eddf76db0ea2 (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
56
57
58
59
60
package net.ess3.update.states;

import net.ess3.update.UpdateCheck;
import org.bukkit.entity.Player;


public class UpdateOrInstallation extends AbstractState
{
	private final UpdateCheck updateCheck;
	private boolean update = false;

	public UpdateOrInstallation(final StateMap stateMap, final UpdateCheck updateCheck)
	{
		super(stateMap);
		this.updateCheck = updateCheck;
	}

	@Override
	public boolean guessAnswer()
	{
		if (getUpdateCheck().isEssentialsInstalled())
		{
			update = true;
		}
		return update;
	}

	@Override
	public AbstractState getNextState()
	{
		return update ? getState(Changelog.class) : getState(EssentialsChat.class);
	}

	@Override
	public void askQuestion(final Player sender)
	{
		sender.sendMessage("Thank you for choosing Essentials.");
		sender.sendMessage("The following installation wizard will guide you through the installation of Essentials.");
		sender.sendMessage("Your answers will be saved for a later update.");
		sender.sendMessage("Please answer the messages with yes or no, if not otherwise stated.");
		sender.sendMessage("Write bye/exit/quit if you want to exit the wizard at anytime.");
		sender.sendMessage("Type ok to continue...");
	}

	@Override
	public boolean reactOnAnswer(final String answer)
	{
		return answer.equalsIgnoreCase("ok") || answer.equalsIgnoreCase("k") || answer.equalsIgnoreCase("continue");
	}

	public UpdateCheck getUpdateCheck()
	{
		return updateCheck;
	}

	public boolean isUpdate()
	{
		return update;
	}
}