diff options
author | snowleo <schneeleo@gmail.com> | 2011-10-26 22:14:24 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-10-26 22:14:24 +0200 |
commit | 72596decbae18e2f59fdd5f1fff78b304ca2e114 (patch) | |
tree | 973b898ef48e48f99e6ed6854737e1b79ad96f2d /EssentialsUpdate/src/com/earth2me/essentials/update/states/UpdateOrInstallation.java | |
parent | e8b8d26bdbe935fff57ab3ded6902e576355f995 (diff) | |
download | Essentials-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.java | 59 |
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; + } +} |