public class GuiStateManager
extends java.lang.Object
GuiState
. Notifies registered listeners about
changes.Modifier and Type | Field and Description |
---|---|
private GuiState |
guiState
The current GUI state.
|
private EventListenerList2<GuiStateListener> |
guiStateListeners
The connection state listeners to notify.
|
private java.lang.Object |
sync
The synchronization object for accessing
guiState . |
Constructor and Description |
---|
GuiStateManager() |
Modifier and Type | Method and Description |
---|---|
void |
addGuiStateListener(GuiStateListener listener)
Adds a gui state listener.
|
void |
changeGUI(GuiState guiState)
Sets a new
GuiState . |
private void |
changeGUI(GuiState guiState,
java.lang.String param)
Sets a new
GuiState . |
void |
connect(java.lang.String serverInfo)
Connects to a Crossfire server.
|
void |
disconnect()
Disconnects from the Crossfire server.
|
void |
disconnected()
Called after the connection has been closed.
|
void |
disconnecting(java.lang.String reason,
boolean isError)
Called when the connection is being teared down.
|
GuiState |
getGuiState()
Returns the current
GuiState . |
void |
removeGuiStateListener(GuiStateListener listener)
Removes a gui state listener.
|
void |
setClientSocketState(ClientSocketState clientSocketState)
Sets the new
ClientSocketState . |
@Nullable private GuiState guiState
@NotNull private final EventListenerList2<GuiStateListener> guiStateListeners
@NotNull private final java.lang.Object sync
guiState
.public void addGuiStateListener(@NotNull GuiStateListener listener)
listener
- the listener to addpublic void changeGUI(@NotNull GuiState guiState)
GuiState
.guiState
- the new gui stateprivate void changeGUI(@NotNull GuiState guiState, @NotNull java.lang.String param)
GuiState
.guiState
- the new gui stateparam
- a parameter for the new gui statepublic void connect(@NotNull java.lang.String serverInfo)
serverInfo
- the server to connect topublic void disconnect()
public void disconnected()
public void disconnecting(@NotNull java.lang.String reason, boolean isError)
reason
- the disconnect reasonisError
- whether the disconnect is unexpected@Nullable public GuiState getGuiState()
GuiState
.public void removeGuiStateListener(@NotNull GuiStateListener listener)
listener
- the listener to removepublic void setClientSocketState(@NotNull ClientSocketState clientSocketState)
ClientSocketState
.clientSocketState
- the new state