summaryrefslogtreecommitdiffstats
path: root/EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-10-26 22:14:24 +0200
committersnowleo <schneeleo@gmail.com>2011-10-26 22:14:24 +0200
commit72596decbae18e2f59fdd5f1fff78b304ca2e114 (patch)
tree973b898ef48e48f99e6ed6854737e1b79ad96f2d /EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java
parente8b8d26bdbe935fff57ab3ded6902e576355f995 (diff)
downloadEssentials-72596decbae18e2f59fdd5f1fff78b304ca2e114.tar
Essentials-72596decbae18e2f59fdd5f1fff78b304ca2e114.tar.gz
Essentials-72596decbae18e2f59fdd5f1fff78b304ca2e114.tar.lz
Essentials-72596decbae18e2f59fdd5f1fff78b304ca2e114.tar.xz
Essentials-72596decbae18e2f59fdd5f1fff78b304ca2e114.zip
The state machine now handles both manual updating and installation.
Diffstat (limited to 'EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java')
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java
new file mode 100644
index 000000000..5671275f0
--- /dev/null
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java
@@ -0,0 +1,59 @@
+package com.earth2me.essentials.update.states;
+
+import com.earth2me.essentials.update.UpdateCheck;
+import org.bukkit.entity.Player;
+
+
+public class UpdateOrInstallation extends AbstractState
+{
+ private final transient UpdateCheck updateCheck;
+ private transient 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;
+ }
+}