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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user