From 7f825750f076e570ffaeecc7de6cb26f202e84ca Mon Sep 17 00:00:00 2001 From: snowleo Date: Wed, 26 Oct 2011 18:18:58 +0200 Subject: Advanced mode --- .../essentials/update/states/AbstractState.java | 9 ++++++--- .../essentials/update/states/AdvancedMode.java | 20 +++++++++++++++++++ .../update/states/EssentialsChatSettings.java | 23 +++++++++------------- 3 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 EssentialsUpdate/src/com/earth2me/essentials/update/states/AdvancedMode.java (limited to 'EssentialsUpdate/src') diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java index 5f2ff42ea..3f0c4c233 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/AbstractState.java @@ -14,7 +14,7 @@ public abstract class AbstractState this.stateMap = stateMap; } - public AbstractState getState(final Class stateClass) + public T getState(final Class stateClass) { if (!stateMap.containsKey(stateClass)) { @@ -33,7 +33,7 @@ public abstract class AbstractState throw new RuntimeException(ex); } } - return stateMap.get(stateClass); + return (T)stateMap.get(stateClass); } public abstract AbstractState getNextState(); @@ -86,7 +86,10 @@ public abstract class AbstractState /** * Do something based on the answer, that the user gave. */ - public abstract void doWork(WorkListener workListener); + public void doWork(final WorkListener listener) + { + listener.onWorkDone(); + } public boolean isAbortion() { diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/AdvancedMode.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/AdvancedMode.java new file mode 100644 index 000000000..88d9efc4a --- /dev/null +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/AdvancedMode.java @@ -0,0 +1,20 @@ +package com.earth2me.essentials.update.states; + +import org.bukkit.entity.Player; + + +public class AdvancedMode extends AbstractYesNoState +{ + public AdvancedMode(final StateMap states) + { + super(states, EssentialsChat.class); + } + + @Override + public void askQuestion(final Player sender) + { + sender.sendMessage("This installation mode has a lot of options."); + sender.sendMessage("Do you want use the advanced mode to see all questions?"); + sender.sendMessage("Otherwise the default values will be used."); + } +} diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChatSettings.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChatSettings.java index 1401f7191..6666ff371 100644 --- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChatSettings.java +++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/EssentialsChatSettings.java @@ -1,10 +1,6 @@ package com.earth2me.essentials.update.states; -import com.earth2me.essentials.update.WorkListener; -import com.earth2me.essentials.update.tasks.InstallModule; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; public class EssentialsChatSettings extends AbstractYesNoState @@ -15,20 +11,19 @@ public class EssentialsChatSettings extends AbstractYesNoState } @Override - public void askQuestion(final Player sender) + public boolean guessAnswer() { - sender.sendMessage("Would you like to configure EssentialsChat to prefix ingame messages with their group?"); + if (getState(AdvancedMode.class).getAnswer()) + { + setAnswer(false); + return true; + } + return false; } @Override - public void doWork(final WorkListener listener) + public void askQuestion(final Player sender) { - if (getAnswer()) - { - //TODO: Configure plugin - - return; - } - listener.onWorkDone(); + sender.sendMessage("Would you like to configure EssentialsChat to prefix ingame messages with their group?"); } } -- cgit v1.2.3