 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.stats;
27 import java.awt.event.ActionListener;
28 import javax.swing.Timer;
29 import org.jetbrains.annotations.NotNull;
60 private static final String
CURE_MESSAGE =
"Your body feels cleansed";
66 private final Object
sync =
new Object();
88 @SuppressWarnings(
"FieldCanBeLocal")
92 public void commandDrawextinfoReceived(
final int color,
final int type,
final int subtype, @NotNull
final String message) {
97 public void setDebugMode(
final boolean printMessageTypes) {
107 @SuppressWarnings(
"FieldCanBeLocal")
111 public void resetBefore() {
115 public void resetAfter() {
116 synchronized (
sync) {
122 public void statChanged(
final int statNo,
final int value) {
124 synchronized (
sync) {
132 public void simpleWeaponSpeedChanged(
final boolean simpleWeaponSpeed) {
136 public void titleChanged(@NotNull
final String title) {
140 public void godNameChanged(@NotNull
final String godName) {
144 public void rangeChanged(@NotNull
final String range) {
148 public void activeSkillChanged(@NotNull
final String activeSkill) {
152 public void experienceChanged(
final long exp) {
156 public void experienceNextLevelChanged(
final long expNextLevel) {
167 synchronized (
sync) {
187 timer.setRepeats(
false);
188 crossfireServerConnection.addCrossfireDrawinfoListener((text, type) ->
check(text));
191 synchronized (
sync) {
200 private void check(@NotNull
final String message) {
201 synchronized (
sync) {
217 if (!Thread.holdsLock(
sync)) {
218 throw new IllegalStateException(
"thread should synchronize on sync");
229 if (this.active ==
active) {
final Stats stats
The stats instance to notify.
final CrossfireDrawextinfoListener drawextinfoListener
The drawextinfo listener to receive drawextinfo messages.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
static final int CF_POISONED
The CS_STAT_CHARACTER_FLAGS bit for a poisoned character.
boolean active
Whether poisoning is active.
PoisonWatcher(@NotNull final Stats stats, @NotNull final CrossfireServerConnection crossfireServerConnection)
Creates a new instance.
final StatsListener statsListener
The StatsListener registered to be notified about stat changes.
void addCrossfireStatsListener(@NotNull final StatsListener statsListener)
Adds a StatsListener to be notified about stat changes.
static final String CURE_MESSAGE
The text message the server sends when the poison is cured via a spell.
boolean serverSupportsPoisonedFlag
Whether the server supports the Stats#CF_POISONED flag.
static final int TIMEOUT_DE_ASSERT
Timeout after that the "poisoned" state is reset.
static final String DE_ASSERT_MESSAGE
The text message the server sends when the poison wears off.
void check(@NotNull final String message)
Examines a text message.
This is the representation of all the statistics of a player, like its speed or its experience.
static final String ASSERT_MESSAGE
The text message the server sends in poisoned state.
final Timer timer
The Timer for turning off the poison symbol.
Interface for listeners interested in drawextinfo messages received from the Crossfire server.
static final int C_STAT_POISONED
The "is poisoned" indicator.
final Object sync
The object used for synchronization.
final ActionListener timeoutEvent
The timeout event used to turn off poisoning if the de-assert message was missed.
static final int CS_STAT_CHARACTER_FLAGS
Flags the character's current state.
void setActive(final boolean active)
Sets the current poisoned state.
Interface for listeners interested in changes of Stats instances.
Helper class to listen on Stats#CF_POISONED.
void setStat(final int statNo, final int value)
Sets the given statistic numerical value.