Crossfire JXClient, Trunk
com.realtime.crossfire.jxclient.stats.PoisonWatcher Class Reference

Helper class to listen on Stats#CF_POISONED. More...

+ Collaboration diagram for com.realtime.crossfire.jxclient.stats.PoisonWatcher:

Public Member Functions

 PoisonWatcher (@NotNull final Stats stats, @NotNull final CrossfireServerConnection crossfireServerConnection)
 Creates a new instance. More...
 

Private Member Functions

void check (@NotNull final String message)
 Examines a text message. More...
 
void setActive (final boolean active)
 Sets the current poisoned state. More...
 

Private Attributes

boolean active = true
 Whether poisoning is active. More...
 
final CrossfireDrawextinfoListener drawextinfoListener
 The drawextinfo listener to receive drawextinfo messages. More...
 
boolean serverSupportsPoisonedFlag
 Whether the server supports the Stats#CF_POISONED flag. More...
 
final Stats stats
 The stats instance to notify. More...
 
final StatsListener statsListener
 The StatsListener registered to be notified about stat changes. More...
 
final Object sync = new Object()
 The object used for synchronization. More...
 
final ActionListener timeoutEvent
 The timeout event used to turn off poisoning if the de-assert message was missed. More...
 
final Timer timer = new Timer(TIMEOUT_DE_ASSERT, timeoutEvent)
 The Timer for turning off the poison symbol. More...
 

Static Private Attributes

static final String ASSERT_MESSAGE = "You feel very sick..."
 The text message the server sends in poisoned state. More...
 
static final String CURE_MESSAGE = "Your body feels cleansed"
 The text message the server sends when the poison is cured via a spell. More...
 
static final String DE_ASSERT_MESSAGE = "You feel much better now."
 The text message the server sends when the poison wears off. More...
 
static final int TIMEOUT_DE_ASSERT = 10000
 Timeout after that the "poisoned" state is reset. More...
 

Detailed Description

Helper class to listen on Stats#CF_POISONED.

If the Crossfire server does not support this flag drawinfo messages are tracked instead.

Author
Andreas Kirschbaum

Definition at line 36 of file PoisonWatcher.java.

Constructor & Destructor Documentation

◆ PoisonWatcher()

Member Function Documentation

◆ check()

void com.realtime.crossfire.jxclient.stats.PoisonWatcher.check ( @NotNull final String  message)
private

◆ setActive()

Member Data Documentation

◆ active

boolean com.realtime.crossfire.jxclient.stats.PoisonWatcher.active = true
private

Whether poisoning is active.

Definition at line 77 of file PoisonWatcher.java.

Referenced by com.realtime.crossfire.jxclient.stats.PoisonWatcher.setActive().

◆ ASSERT_MESSAGE

final String com.realtime.crossfire.jxclient.stats.PoisonWatcher.ASSERT_MESSAGE = "You feel very sick..."
staticprivate

The text message the server sends in poisoned state.

Definition at line 48 of file PoisonWatcher.java.

Referenced by com.realtime.crossfire.jxclient.stats.PoisonWatcher.check().

◆ CURE_MESSAGE

final String com.realtime.crossfire.jxclient.stats.PoisonWatcher.CURE_MESSAGE = "Your body feels cleansed"
staticprivate

The text message the server sends when the poison is cured via a spell.

Definition at line 60 of file PoisonWatcher.java.

Referenced by com.realtime.crossfire.jxclient.stats.PoisonWatcher.check().

◆ DE_ASSERT_MESSAGE

final String com.realtime.crossfire.jxclient.stats.PoisonWatcher.DE_ASSERT_MESSAGE = "You feel much better now."
staticprivate

The text message the server sends when the poison wears off.

Definition at line 54 of file PoisonWatcher.java.

Referenced by com.realtime.crossfire.jxclient.stats.PoisonWatcher.check().

◆ drawextinfoListener

final CrossfireDrawextinfoListener com.realtime.crossfire.jxclient.stats.PoisonWatcher.drawextinfoListener
private
Initial value:
= new CrossfireDrawextinfoListener() {
@Override
public void commandDrawextinfoReceived(final int color, final int type, final int subtype, @NotNull final String message) {
check(message);
}
@Override
public void setDebugMode(final boolean printMessageTypes) {
}
}

The drawextinfo listener to receive drawextinfo messages.

Definition at line 89 of file PoisonWatcher.java.

Referenced by com.realtime.crossfire.jxclient.stats.PoisonWatcher.PoisonWatcher().

◆ serverSupportsPoisonedFlag

boolean com.realtime.crossfire.jxclient.stats.PoisonWatcher.serverSupportsPoisonedFlag
private

◆ stats

final Stats com.realtime.crossfire.jxclient.stats.PoisonWatcher.stats
private

◆ statsListener

final StatsListener com.realtime.crossfire.jxclient.stats.PoisonWatcher.statsListener
private

The StatsListener registered to be notified about stat changes.

Definition at line 108 of file PoisonWatcher.java.

Referenced by com.realtime.crossfire.jxclient.stats.PoisonWatcher.PoisonWatcher().

◆ sync

final Object com.realtime.crossfire.jxclient.stats.PoisonWatcher.sync = new Object()
private

◆ TIMEOUT_DE_ASSERT

final int com.realtime.crossfire.jxclient.stats.PoisonWatcher.TIMEOUT_DE_ASSERT = 10000
staticprivate

Timeout after that the "poisoned" state is reset.

This allows to prevent a stuck poison warning if the de-assertion was missed for any reason.

Definition at line 42 of file PoisonWatcher.java.

◆ timeoutEvent

final ActionListener com.realtime.crossfire.jxclient.stats.PoisonWatcher.timeoutEvent
private
Initial value:
= e -> {
synchronized (sync) {
setActive(false);
}
}
}

The timeout event used to turn off poisoning if the de-assert message was missed.

Definition at line 166 of file PoisonWatcher.java.

◆ timer

final Timer com.realtime.crossfire.jxclient.stats.PoisonWatcher.timer = new Timer(TIMEOUT_DE_ASSERT, timeoutEvent)
private

The documentation for this class was generated from the following file:
com.realtime.crossfire.jxclient.stats.PoisonWatcher.serverSupportsPoisonedFlag
boolean serverSupportsPoisonedFlag
Whether the server supports the Stats#CF_POISONED flag.
Definition: PoisonWatcher.java:82
com.realtime.crossfire.jxclient.stats.PoisonWatcher.check
void check(@NotNull final String message)
Examines a text message.
Definition: PoisonWatcher.java:200
com.realtime.crossfire.jxclient.stats.PoisonWatcher.sync
final Object sync
The object used for synchronization.
Definition: PoisonWatcher.java:66
com.realtime.crossfire.jxclient.stats.PoisonWatcher.setActive
void setActive(final boolean active)
Sets the current poisoned state.
Definition: PoisonWatcher.java:216