1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-28 23:29:08 +02:00

Moving the link between the states from the constructor of the state machine to the states classes.

This commit is contained in:
snowleo
2011-10-23 23:08:18 +02:00
parent 6974abea28
commit 8854b3f565
7 changed files with 94 additions and 27 deletions

View File

@@ -7,6 +7,17 @@ import org.bukkit.entity.Player;
public abstract class AbstractState
{
private transient boolean abortion = false;
private final transient StateMap stateMap;
public AbstractState(final StateMap stateMap)
{
this.stateMap = stateMap;
}
public AbstractState getState(final Class<? extends AbstractState> stateClass)
{
return stateMap.get(stateClass);
}
public abstract AbstractState getNextState();
@@ -40,7 +51,7 @@ public abstract class AbstractState
|| trimmedAnswer.equalsIgnoreCase("bye")
|| trimmedAnswer.equalsIgnoreCase("abort"))
{
abortion = true;
abort();
return null;
}
final boolean found = reactOnAnswer(trimmedAnswer);
@@ -64,4 +75,9 @@ public abstract class AbstractState
{
return abortion;
}
protected void abort()
{
abortion = true;
}
}