summaryrefslogtreecommitdiffstats
path: root/EssentialsUpdate/src/com/earth2me/essentials
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-10-23 23:20:18 +0200
committersnowleo <schneeleo@gmail.com>2011-10-23 23:20:18 +0200
commit9c793208adc9205c28ae12512dad2604c4876a40 (patch)
treeefe3ee8eff61d731d5983b4828e6a881f6c1ff7e /EssentialsUpdate/src/com/earth2me/essentials
parentb07b3fc37329165923fccc1a923cdc195f8ca4e8 (diff)
downloadEssentials-9c793208adc9205c28ae12512dad2604c4876a40.tar
Essentials-9c793208adc9205c28ae12512dad2604c4876a40.tar.gz
Essentials-9c793208adc9205c28ae12512dad2604c4876a40.tar.lz
Essentials-9c793208adc9205c28ae12512dad2604c4876a40.tar.xz
Essentials-9c793208adc9205c28ae12512dad2604c4876a40.zip
Minor changes because we use a map instead of a list
Diffstat (limited to 'EssentialsUpdate/src/com/earth2me/essentials')
-rw-r--r--EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java b/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java
index 79492a232..fdbcb8cce 100644
--- a/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java
+++ b/EssentialsUpdate/src/com/earth2me/essentials/update/states/StateMachine.java
@@ -2,6 +2,8 @@ package com.earth2me.essentials.update.states;
import com.earth2me.essentials.update.WorkListener;
import com.earth2me.essentials.update.VersionInfo;
+import java.util.Collections;
+import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -24,7 +26,7 @@ public class StateMachine extends WorkListener
states.clear();
states.add(new EssentialsChat(states));
states.add(new EssentialsProtect(states));
- current = states.get(0);
+ current = states.values().iterator().next();
}
public MachineResult askQuestion()
@@ -58,16 +60,17 @@ public class StateMachine extends WorkListener
current = next;
return askQuestion();
}
- private int position = 0;
+ private transient Iterator<AbstractState> iterator;
public void startWork()
{
+ iterator = states.values().iterator();
callStateWork();
}
private void callStateWork()
{
- if (position > states.size())
+ if (!iterator.hasNext())
{
if (player.isOnline())
{
@@ -75,14 +78,13 @@ public class StateMachine extends WorkListener
}
return;
}
- final AbstractState state = states.get(position);
+ final AbstractState state = iterator.next();
state.doWork(this);
}
@Override
public void onWorkAbort(final String message)
{
- position = 0;
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
@Override
@@ -99,7 +101,6 @@ public class StateMachine extends WorkListener
@Override
public void onWorkDone(final String message)
{
- position++;
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
@Override