public class PacketWatcher
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.Collection<java.lang.String> |
commands
The commands to watch for.
|
private CrossfireServerConnection |
crossfireServerConnection
The
CrossfireServerConnection to watch. |
private java.util.regex.Pattern |
pattern
A
Pattern matching all commands . |
private ReceivedPacketListener |
receivedPacketListener
The
ReceivedPacketListener attached to crossfireServerConnection . |
private ScriptProcess |
scriptProcess
The
ScriptProcess for sending commands. |
Constructor and Description |
---|
PacketWatcher(CrossfireServerConnection crossfireServerConnection,
ScriptProcess scriptProcess)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addCommand(java.lang.String command)
Adds a command to watch for.
|
void |
destroy()
Releases allocated resources.
|
private boolean |
matchesCommand(java.lang.CharSequence command)
Returns whether a command matches the currently watched commands.
|
private void |
rebuildPattern()
|
void |
removeCommand(java.lang.String command)
Removes a command to watch for.
|
@NotNull private final java.util.Collection<java.lang.String> commands
@NotNull private final CrossfireServerConnection crossfireServerConnection
CrossfireServerConnection
to watch.@Nullable private java.util.regex.Pattern pattern
@NotNull private final ReceivedPacketListener receivedPacketListener
ReceivedPacketListener
attached to crossfireServerConnection
. It is attached if and only if pattern
is non-null
.@NotNull private final ScriptProcess scriptProcess
ScriptProcess
for sending commands.public PacketWatcher(@NotNull CrossfireServerConnection crossfireServerConnection, @NotNull ScriptProcess scriptProcess)
crossfireServerConnection
- the server connection to watchscriptProcess
- the script process for sending commandspublic void addCommand(@NotNull java.lang.String command)
command
- the commandpublic void destroy()
private boolean matchesCommand(@NotNull java.lang.CharSequence command)
command
- the commandprivate void rebuildPattern()
public void removeCommand(@NotNull java.lang.String command)
command
- the command