22 package com.realtime.crossfire.jxclient.settings;
27 import java.util.HashMap;
29 import java.util.regex.Matcher;
30 import java.util.regex.Pattern;
31 import org.jetbrains.annotations.NotNull;
43 private static final String
REPLY_TO =
"reply_to";
49 private final Pattern
macroPattern = Pattern.compile(
"<<([a-z_]+)>>");
55 private final Map<String, String>
expansions =
new HashMap<>();
61 @SuppressWarnings(
"FieldCanBeLocal")
65 public void commandDrawextinfoReceived(
final int color,
final int type,
final int subtype, @NotNull
final String message) {
85 final int index = message.indexOf(
" tells you:");
87 final String name = message.substring(0, index);
88 expansions.put(REPLY_TO, name);
103 public void setDebugMode(
final boolean printMessageTypes) {
115 expansions.put(REPLY_TO,
"");
126 StringBuilder result = null;
128 final Matcher macroMatcher = macroPattern.matcher(
string);
129 while (macroMatcher.find()) {
130 if (result == null) {
131 result =
new StringBuilder();
134 final String name = macroMatcher.group(1);
135 String expansion = expansions.get(name);
136 if (expansion == null) {
137 expansion = macroMatcher.group();
139 result.append(
string.substring(index, macroMatcher.start()));
140 result.append(expansion);
141 index = macroMatcher.end();
143 if (result != null) {
144 result.append(
string.substring(index,
string.length()));
146 return result == null ? string : result.toString();
static final int MSG_TYPE_SKILL
drawextinfo message type: message related to using skills.
Encapsulates the message type numbers for drawextinfo messages.
static final int MSG_TYPE_CARD
drawextinfo message type: character did read a card.
static final int MSG_TYPE_MISC
drawextinfo message type: message that does not fit in any other category.
final Pattern macroPattern
The Pattern matching macro names.
final Map< String, String > expansions
The macro expansions.
static final int MSG_TYPE_MONUMENT
drawextinfo message type: character did read a monument.
static final int MSG_TYPE_PAPER
drawextinfo message type: character did read a paper.
String expandMacros(@NotNull final String string)
Expands all macro references.
final CrossfireDrawextinfoListener crossfireDrawextinfoListener
The CrossfireDrawextinfoListener for tracking tells.
static final int MSG_TYPE_COMMAND
drawextinfo message type: response to command processing.
Manages macro expansion in command strings.
static final int MSG_TYPE_ADMIN
drawextinfo message type: general server message.
static final int MSG_TYPE_ATTACK
drawextinfo message type: attack related message.
static final int MSG_TYPE_APPLY
drawextinfo message type: an object was applied.
static final String REPLY_TO
The "reply_to" macro name.
static final int MSG_TYPE_SHOP
drawextinfo message type: shop related message.
static final int MSG_TYPE_SIGN
drawextinfo message type: character did read a sign.
static final int MSG_TYPE_ITEM
drawextinfo message type: item related information.
Interface for listeners interested in drawextinfo messages received from the Crossfire server...
static final int MSG_TYPE_COMMUNICATION
drawextinfo message type: communication between players.
static final int MSG_TYPE_MOTD
drawextinfo message type: motd text.
static final int MSG_TYPE_SPELL
drawextinfo message type: spell related information.
static final int MSG_TYPE_COMMUNICATION_TELL
Macros(@NotNull final CrossfireServerConnection crossfireServerConnection)
Creates a new instance.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
static final int MSG_TYPE_DIALOG
drawextinfo message type: a NPC/magic mouth/altar/etc.
static final int MSG_TYPE_ATTRIBUTE
drawextinfo message type: attribute (stats, resistances, etc.) change message.
static final int MSG_TYPE_VICTIM
drawextinfo message type: something bad is happening to the player.
static final int MSG_TYPE_BOOK
drawextinfo message type: character did read a book.