public class DefaultCrossfireServerConnection extends AbstractCrossfireServerConnection
CrossfireServerConnection
.Modifier and Type | Field and Description |
---|---|
private static byte[] |
ACCOUNT_ADD_PLAYER_PREFIX
The command prefix for the "accountaddplayer" command.
|
private static byte[] |
ACCOUNT_LOGIN_PREFIX
The command prefix for the "accountlogin" command.
|
private static byte[] |
ACCOUNT_NEW_PREFIX
The command prefix for the "accountnew" command.
|
private static byte[] |
ACCOUNT_PASSWORD_PREFIX
The command prefix for the "accountpw" command.
|
private static byte[] |
ACCOUNT_PLAY_PREFIX
The command prefix for the "accountplay" command.
|
private java.lang.String |
accountName
The account name.
|
private static int |
ACL_CLASS
Parameter type in the "accountplayers" command.
|
private static int |
ACL_FACE
Parameter type in the "accountplayers" command.
|
private static int |
ACL_FACE_NUM
Parameter type in the "accountplayers" command.
|
private static int |
ACL_LEVEL
Parameter type in the "accountplayers" command.
|
private static int |
ACL_MAP
Parameter type in the "accountplayers" command.
|
private static int |
ACL_NAME
Parameter type in the "accountplayers" command.
|
private static int |
ACL_PARTY
Parameter type in the "accountplayers" command.
|
private static int |
ACL_RACE
Parameter type in the "accountplayers" command.
|
private static byte[] |
ADDME_PREFIX
The command prefix for the "addme" command.
|
private static byte[] |
APPLY_PREFIX
The command prefix for the "apply" command.
|
private static byte[] |
ASKFACE_PREFIX
The command prefix for the "askface" command.
|
private java.nio.ByteBuffer |
byteBuffer
A byte buffer using
writeBuffer to store the data. |
private ClientSocketListener |
clientSocketListener
The
ClientSocketListener attached to the server socket. |
private ClientSocketState |
clientSocketState
The current connection state.
|
private static byte[] |
CREATE_PLAYER_PREFIX
The command prefix for the "createplayer" command.
|
private CrossfireUpdateMapListener |
crossfireUpdateMapListener
The
CrossfireUpdateMapListener to be notified. |
private int |
currentMapHeight
The currently active map height.
|
private int |
currentMapWidth
The currently active map width.
|
private DebugWriter |
debugProtocol
The appender to write protocol commands to.
|
private static int |
DEFAULT_MAP_HEIGHT
The default map height when no "setup mapsize" command has been sent.
|
private static int |
DEFAULT_MAP_WIDTH
The default map width when no "setup mapsize" command has been sent.
|
private DefaultServerConnection |
defaultServerConnection
The physical server connection.
|
private static byte[] |
EXAMINE_PREFIX
The command prefix for the "examine" command.
|
private static int |
INFO_MAP_ARCH_NAME
Archetype name of a "replyinfo startingmap" entry.
|
private static int |
INFO_MAP_DESCRIPTION
Description of a "replyinfo startingmap" entry.
|
private static int |
INFO_MAP_NAME
Proper name of a "replyinfo startingmap" entry.
|
private static byte[] |
LOCK_PREFIX
The command prefix for the "lock" command.
|
private int |
loginMethod
The login method version supported by the server we're connected to.
|
private static byte[] |
LOOKAT_PREFIX
The command prefix for the "lookat" command.
|
private static byte[] |
MARK_PREFIX
The command prefix for the "mark" command.
|
private Model |
model
The
Model instance that is updated. |
private static byte[] |
MOVE_PREFIX
The command prefix for the "move" command.
|
private static byte[] |
NCOM_PREFIX
The command prefix for the "ncom" command.
|
private NumLookObjects |
numLookObjects
The
NumLookObjects instance for negotiating the size of the
ground view. |
private int |
packet
The packet id for the next "ncom" command to send.
|
private static java.util.regex.Pattern |
PATTERN_BAR
Pattern to split a string by "|".
|
private static java.util.regex.Pattern |
PATTERN_DOT
Pattern to split a string by ":".
|
private static java.util.regex.Pattern |
PATTERN_SPACE
Pattern to split a string by spaces.
|
private int |
pendingMapHeight
The map height that is being negotiated with the server.
|
private int |
pendingMapWidth
The map width that is being negotiated with the server.
|
private java.util.List<java.lang.String> |
pendingRequestInfos
Pending "requestinfo" commands that will be sent as soon
sendingRequestInfo is unset. |
private int |
preferredMapHeight
The map height in tiles that is negotiated with the server.
|
private int |
preferredMapWidth
The map width in tiles that is negotiated with the server.
|
private static byte[] |
REPLY_PREFIX
The command prefix for the "reply" command.
|
private static byte[] |
REQUESTINFO_PREFIX
The command prefix for the "requestinfo" command.
|
private java.lang.String |
sendingRequestInfo
If non-
null : the last sent "requestinfo" command for which no
"replyinfo" response has been received yet. |
private static byte[] |
SETUP_PREFIX
The command prefix for the "setup" command.
|
private static byte[] |
TOGGLEEXTENDEDTEXT_PREFIX
The command prefix for the "toggleextendedtext" command.
|
private java.lang.String |
version
The version information to send when connecting to the server.
|
private static byte[] |
VERSION_PREFIX
The command prefix for the "version" command.
|
private byte[] |
writeBuffer
Buffer to build commands to send.
|
UTF8
Constructor and Description |
---|
DefaultCrossfireServerConnection(Model model,
DebugWriter debugProtocol,
java.lang.String version)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addClientSocketListener(ClientSocketListener clientSocketListener)
Adds a
ClientSocketListener to notify. |
private void |
cmdMap2Coordinate(java.nio.ByteBuffer packet,
int x,
int y)
Processes the payload data for a map2 coordinate command.
|
private void |
cmdMap2CoordinateClearSpace(int x,
int y,
int len)
Processes the payload data for a map2 coordinate "clear_space"
sub-command.
|
private void |
cmdMap2CoordinateDarkness(java.nio.ByteBuffer packet,
int x,
int y,
int len)
Processes the payload data for a map2 coordinate "darkness" sub-command.
|
private void |
cmdMap2CoordinateLayer(java.nio.ByteBuffer packet,
int x,
int y,
int len,
int layer)
Processes the payload data for a map2 coordinate "layer" sub-command.
|
private void |
cmdMap2CoordinateLayer3(java.nio.ByteBuffer packet,
Location location,
int face)
Processes the additional payload data for a map2 coordinate "layer"
sub-command having 4 bytes payload.
|
private void |
cmdMap2CoordinateLayer4(java.nio.ByteBuffer packet,
Location location,
int face)
Processes the additional payload data for a map2 coordinate "layer"
sub-command having 4 bytes payload.
|
private void |
cmdReplyinfo(java.lang.String infoType,
java.nio.ByteBuffer packet)
Handles the replyinfo server to client command.
|
void |
connect(java.lang.String hostname,
int port)
Attempts to connect the client to a server.
|
private void |
connected()
Called after the server connection has been established.
|
void |
disconnect(java.lang.String reason)
Disconnects from the server.
|
protected void |
fireAddAnimation(int animation,
int flags,
int[] faces) |
protected void |
fireMagicMap(int x,
int y,
byte[][] data) |
protected void |
fireMapAnimation(Location location,
int animationNum,
int animationType) |
protected void |
fireMapAnimationSpeed(Location location,
int animSpeed) |
protected void |
fireMapClear(int x,
int y) |
protected void |
fireMapDarkness(int x,
int y,
int darkness) |
protected void |
fireMapFace(Location location,
int face) |
protected void |
fireMapSmooth(Location location,
int smooth) |
private void |
fireNewMap()
Notifies all listeners that a "newmap" command has been received.
|
java.lang.String |
getAccountName()
Returns the current account name.
|
int |
getCurrentNumLookObjects()
Returns the currently negotiated setup value of "num_look_objects".
|
private static int |
getInt1(java.nio.ByteBuffer byteBuffer)
Extracts and removes a 1 byte integer from a
ByteBuffer at it's
current position. |
private static int |
getInt2(java.nio.ByteBuffer byteBuffer)
Extracts and removes a 2 byte integer from a
ByteBuffer at it's
current position. |
private static int |
getInt4(java.nio.ByteBuffer byteBuffer)
Extracts and removes a 4 byte integer from a
ByteBuffer at it's
current position. |
private static long |
getInt8(java.nio.ByteBuffer byteBuffer)
Extracts and removes an 8 byte integer from a
ByteBuffer at it's
current position. |
private static java.lang.String |
getString(java.nio.ByteBuffer byteBuffer,
int len)
Extracts and removes a string from a
ByteBuffer at it's current
position. |
private static java.lang.String |
getStringDelimiter(java.nio.ByteBuffer byteBuffer,
char delimiter)
Extracts and removes a string from a
ByteBuffer at it's current
position. |
private static java.lang.String |
hexDump(java.nio.ByteBuffer byteBuffer)
Returns a hex-dump of a
ByteBuffer . |
private void |
negotiateMapSize(int mapWidth,
int mapHeight)
Requests a change of the map size from the server.
|
private CharacterInformation |
parseAccountPlayer(java.nio.ByteBuffer packet,
AccountPlayerBuilder accountPlayerBuilder)
Processes one account entry of an 'accountplayers' server command.
|
private static void |
parseClassRaceInfoChoice(java.nio.ByteBuffer packet,
ClassRaceInfoBuilder rb)
Parses a "choice" entry of a "replyinfo race_info" or "replyinfo
class_info" packet.
|
private static void |
parseClassRaceInfoStats(java.nio.ByteBuffer packet,
ClassRaceInfoBuilder rb)
Parses a "stats" entry of a "replyinfo race_info" or "replyinfo
class_info" packet.
|
private static int |
parseDigit(byte ch)
Parses a character into an integer.
|
private static void |
parseNewCharInfoInformational(java.lang.String variableName,
java.lang.String values)
Parses an 'I' entry of a "replyinfo newcharinfo" packet.
|
private static void |
parseNewCharInfoValue(NewCharInfoBuilder newCharInfoBuilder,
boolean required,
java.lang.String variableName,
java.lang.String values)
Parses an 'R' or 'O' entry of a "replyinfo newcharinfo" packet.
|
private static void |
parseNewCharInfoValues(NewCharInfoBuilder newCharInfoBuilder,
java.lang.String variableName,
java.lang.String values)
Parses a 'V' entry of a "replyinfo newcharinfo" packet.
|
private void |
processAccountPlayers(java.nio.ByteBuffer packet)
Processes an 'accountplayers' server command.
|
private void |
processAddKnowledge(java.nio.ByteBuffer packet)
Processes an "addacknowledge" block.
|
private void |
processAddmeFailed(java.nio.ByteBuffer packet)
Processes an 'account_failed' server command.
|
private void |
processAddmeSuccess(java.nio.ByteBuffer packet)
Processes an 'account_success' server command.
|
private void |
processAddQuest(java.nio.ByteBuffer packet)
Processes an 'addquest' server command.
|
private void |
processAddSpell(java.nio.ByteBuffer packet)
Processes an 'addspell' server command.
|
private void |
processAnim(java.nio.ByteBuffer packet)
Processes an 'anim' server command.
|
private void |
processClassListReplyinfo(java.nio.ByteBuffer packet)
Processes a "replyinfo class_list" block.
|
private void |
processClassRaceInfoReplyinfo(java.nio.ByteBuffer packet,
boolean raceInfo)
Processes a "replyinfo race_info" or "replyinfo class_info" block.
|
private void |
processComc(java.nio.ByteBuffer packet)
Processes a 'comc' server command.
|
private void |
processDelInv(java.nio.ByteBuffer packet)
Processes a 'delinv' server command.
|
private void |
processDelItem(java.nio.ByteBuffer packet)
Processes a 'delitem' server command.
|
private void |
processDelSpell(java.nio.ByteBuffer packet)
Processes a 'delspell' server command.
|
private void |
processDrawExtInfo(java.nio.ByteBuffer packet)
Processes a 'drawextinfo' server command.
|
private void |
processDrawInfo(java.nio.ByteBuffer packet)
Processes a 'drawinfo' server command.
|
private void |
processExpTableReplyinfo(java.nio.ByteBuffer packet)
Processes a "replyinfo exp_table" block.
|
private void |
processExtendedInfoSet(java.nio.ByteBuffer packet)
Processes an 'ExtendedInfoSet' server command.
|
private void |
processExtendedTextSet(java.nio.ByteBuffer packet)
Processes an 'ExtendedTextSet' server command.
|
private void |
processFace2(java.nio.ByteBuffer packet)
Processes a 'face2' server command.
|
private void |
processFailure(java.nio.ByteBuffer packet)
Processes a 'failure' server command.
|
private void |
processGoodbye(java.nio.ByteBuffer packet)
Processes a 'goodbye' server command.
|
private void |
processImage2(java.nio.ByteBuffer packet)
Processes an 'image2' server command.
|
private static void |
processImageInfoReplyinfo(java.nio.ByteBuffer packet)
Processes a "replyinfo image_info" block.
|
private void |
processItem2(java.nio.ByteBuffer packet)
Processes an 'item2' server command.
|
private void |
processKnowledgeInfoReplyinfo(java.nio.ByteBuffer packet)
Processes a "replyinfo knowledge_info" block.
|
private void |
processMagicMap(java.nio.ByteBuffer packet)
Processes a 'magicmap' server command.
|
private void |
processMap2(java.nio.ByteBuffer packet)
Processes a 'map2' server command.
|
private void |
processMapExtended(java.nio.ByteBuffer packet)
Processes a 'mapextended' server command.
|
private void |
processMusic(java.nio.ByteBuffer packet)
Processes a 'music' server command.
|
private void |
processNewCharInfoReplyinfo(java.nio.ByteBuffer packet)
Processes a "replyinfo newcharinfo" block.
|
private void |
processNewMap(java.nio.ByteBuffer packet)
Processes a 'newmap' server command.
|
private void |
processPacket(java.nio.ByteBuffer packet)
Processes a received packet.
|
private void |
processPickup(java.nio.ByteBuffer packet)
Processes a 'pickup' server command.
|
private void |
processPlayer(java.nio.ByteBuffer packet)
Processes a 'pickup' server command.
|
private void |
processQuery(java.nio.ByteBuffer packet)
Processes a 'pickup' server command.
|
private void |
processRaceListReplyinfo(java.nio.ByteBuffer packet)
Processes a "replyinfo race_list" block.
|
private void |
processReplyInfo(java.nio.ByteBuffer packet)
Processes a 'replyinfo' server command.
|
private void |
processSetup(java.nio.ByteBuffer packet)
Processes a 'replyinfo' server command.
|
private void |
processSkillInfoReplyinfo(java.nio.ByteBuffer packet)
Processes a "replyinfo skill_info" block.
|
private void |
processSmooth(java.nio.ByteBuffer packet)
Processes a 'smooth' server command.
|
private void |
processSound(java.nio.ByteBuffer packet)
Processes a 'sound' server command.
|
private void |
processSound2(java.nio.ByteBuffer packet)
Processes a 'sound2' server command.
|
private void |
processStartingMapReplyinfo(java.nio.ByteBuffer packet)
Processes a "replyinfo startingmap" block.
|
private void |
processStats(java.nio.ByteBuffer packet)
Processes a 'stats' server command.
|
private void |
processTick(java.nio.ByteBuffer packet)
Processes a 'tick' server command.
|
private void |
processUpdItem(java.nio.ByteBuffer packet)
Processes an 'upditem' server command.
|
private void |
processUpdQuest(java.nio.ByteBuffer packet)
Processes an 'updquest' server command.
|
private void |
processUpdSpell(java.nio.ByteBuffer packet)
Processes an 'updspell' server command.
|
private void |
processVersion(java.nio.ByteBuffer packet)
Processes a 'version' server command.
|
private void |
putDecimal(int value)
Appends an integer in decimal ASCII representation to
byteBuffer . |
void |
removeClientSocketListener(ClientSocketListener clientSocketListener)
Removes a
ClientSocketListener to notify. |
void |
sendAccountCharacterCreate(java.lang.String login,
java.lang.String password)
Sends a request to create a new character associated to the account.
|
void |
sendAccountCreate(java.lang.String login,
java.lang.String password)
Sends a request to create a new account.
|
void |
sendAccountLink(int force,
java.lang.String login,
java.lang.String password)
Sends a request to add an existing character to an account.
|
void |
sendAccountLogin(java.lang.String login,
java.lang.String password)
Asks for an account login.
|
void |
sendAccountPassword(java.lang.String currentPassword,
java.lang.String newPassword)
Sends a request to change the account's password.
|
void |
sendAccountPlay(java.lang.String name)
Sends a request to play a character from an account.
|
void |
sendAddme()
Sends an "addme" command to the server.
|
void |
sendApply(int tag)
Sends an "apply" command to the server.
|
void |
sendAskface(int faceNum)
Sends an "askface" command.
|
void |
sendExamine(int tag)
Sends an "examine" command to the server.
|
void |
sendLock(boolean val,
int tag)
Sends a "lock" command to the server.
|
void |
sendLookat(int dx,
int dy)
Sends a "lookat" command to the server.
|
void |
sendMark(int tag)
Sends a "mark" command to the server.
|
void |
sendMove(int to,
int tag,
int nrof)
Sends a "move" command to the server.
|
int |
sendNcom(int repeat,
java.lang.String command)
Sends a "ncom" command to the server.
|
private void |
sendPendingRequestInfo()
Sends the next asynchronous "requestinfo" packet if possible.
|
private void |
sendQueuedRequestinfo(java.lang.String infoType)
Sends a "requestinfo" packet asynchronously.
|
void |
sendReply(java.lang.String text)
Sends a "reply" command to the server.
|
void |
sendRequestinfo(java.lang.String infoType)
Sends a "requestinfo" command to the server.
|
void |
sendSetup(java.lang.String... options)
Sends a "setup" command to the server.
|
void |
sendToggleextendedtext(int... types)
Sends a "toggleextendedtext" command to the server.
|
void |
sendVersion(int csval,
int scval,
java.lang.String vinfo)
Sends a "version" command to the server.
|
private void |
setClientSocketState(ClientSocketState prevState,
ClientSocketState nextState)
Updates the
clientSocketState . |
void |
setCrossfireUpdateMapListener(CrossfireUpdateMapListener listener)
Sets a listener to be notified about map changes.
|
private void |
setCurrentMapSize(int currentMapWidth,
int currentMapHeight)
Sets the current map size as negotiated with the server.
|
void |
setPreferredMapSize(int preferredMapWidth,
int preferredMapHeight)
Sets the preferred map size.
|
void |
setPreferredNumLookObjects(int preferredNumLookObjects)
Sets the maximum number of objects in the ground view.
|
void |
start()
Starts operation.
|
void |
stop()
Stops operation.
|
void |
waitForCurrentNumLookObjectsValid()
Waits until
getCurrentNumLookObjects() is stable. |
addCrossfireAccountListener, addCrossfireComcListener, addCrossfireDrawextinfoListener, addCrossfireDrawinfoListener, addCrossfireFailureListener, addCrossfireMagicmapListener, addCrossfireMusicListener, addCrossfirePickupListener, addCrossfireQueryListener, addCrossfireSoundListener, addCrossfireTickListener, addCrossfireUpdateItemListener, addPacketWatcherListener, addSentReplyListener, clearFailure, drawextinfo, drawInfo, drawInfoSetDebugMode, extractCommand, fireAddAccount, fireAddItemReceived, fireCommandComcReceived, fireCommandQueryReceived, fireCommandSound2Received, fireCommandSoundReceived, fireDelinvReceived, fireDelitemReceived, fireEndAccountList, fireFaceReceived, fireFailure, fireMagicMap, fireManageAccount, fireMusicReceived, firePickupChanged, firePlayerReceived, fireReplySent, fireSelectCharacter, fireStartAccountList, fireStartPlaying, fireTick, fireUpditemReceived, newString, notifyPacketWatcherListenersAscii, notifyPacketWatcherListenersEmpty, notifyPacketWatcherListenersIntArray, notifyPacketWatcherListenersMixed, notifyPacketWatcherListenersNoData, notifyPacketWatcherListenersShortArray, notifyPacketWatcherListenersShortInt, notifyPacketWatcherListenersStats, removeCrossfireAccountListener, removeCrossfireDrawextinfoListener, removeCrossfireDrawinfoListener, removeCrossfireFailureListener, removeCrossfireMagicmapListener, removeCrossfirePickupListener, removeCrossfireQueryListener, removeCrossfireUpdateItemListener, removePacketWatcherListener, removeSentReplyListener
@NotNull private static final byte[] ACCOUNT_ADD_PLAYER_PREFIX
@NotNull private static final byte[] ACCOUNT_LOGIN_PREFIX
@NotNull private static final byte[] ACCOUNT_NEW_PREFIX
@NotNull private static final byte[] ACCOUNT_PASSWORD_PREFIX
@NotNull private static final byte[] ACCOUNT_PLAY_PREFIX
@Nullable private java.lang.String accountName
null
if no account name is known.private static final int ACL_CLASS
private static final int ACL_FACE
private static final int ACL_FACE_NUM
private static final int ACL_LEVEL
private static final int ACL_MAP
private static final int ACL_NAME
private static final int ACL_PARTY
private static final int ACL_RACE
@NotNull private static final byte[] ADDME_PREFIX
@NotNull private static final byte[] APPLY_PREFIX
@NotNull private static final byte[] ASKFACE_PREFIX
@NotNull private final java.nio.ByteBuffer byteBuffer
writeBuffer
to store the data.@NotNull private final ClientSocketListener clientSocketListener
ClientSocketListener
attached to the server socket.@NotNull private ClientSocketState clientSocketState
@NotNull private static final byte[] CREATE_PLAYER_PREFIX
@Nullable private CrossfireUpdateMapListener crossfireUpdateMapListener
CrossfireUpdateMapListener
to be notified. Set to null
if unset.private int currentMapHeight
private int currentMapWidth
@Nullable private final DebugWriter debugProtocol
null
to not
write anything.private static final int DEFAULT_MAP_HEIGHT
private static final int DEFAULT_MAP_WIDTH
@NotNull private final DefaultServerConnection defaultServerConnection
@NotNull private static final byte[] EXAMINE_PREFIX
private static final int INFO_MAP_ARCH_NAME
private static final int INFO_MAP_DESCRIPTION
private static final int INFO_MAP_NAME
@NotNull private static final byte[] LOCK_PREFIX
private int loginMethod
@NotNull private static final byte[] LOOKAT_PREFIX
@NotNull private static final byte[] MARK_PREFIX
@NotNull private static final byte[] MOVE_PREFIX
@NotNull private static final byte[] NCOM_PREFIX
@NotNull private final NumLookObjects numLookObjects
NumLookObjects
instance for negotiating the size of the
ground view.private int packet
@NotNull private static final java.util.regex.Pattern PATTERN_BAR
@NotNull private static final java.util.regex.Pattern PATTERN_DOT
@NotNull private static final java.util.regex.Pattern PATTERN_SPACE
private int pendingMapHeight
0
when not negotiating.private int pendingMapWidth
0
when not negotiating.@NotNull private final java.util.List<java.lang.String> pendingRequestInfos
sendingRequestInfo
is unset.private int preferredMapHeight
private int preferredMapWidth
@NotNull private static final byte[] REPLY_PREFIX
@NotNull private static final byte[] REQUESTINFO_PREFIX
@Nullable private java.lang.String sendingRequestInfo
null
: the last sent "requestinfo" command for which no
"replyinfo" response has been received yet.@NotNull private static final byte[] SETUP_PREFIX
@NotNull private static final byte[] TOGGLEEXTENDEDTEXT_PREFIX
@NotNull private final java.lang.String version
@NotNull private static final byte[] VERSION_PREFIX
@NotNull private final byte[] writeBuffer
public DefaultCrossfireServerConnection(@NotNull Model model, @Nullable DebugWriter debugProtocol, @NotNull java.lang.String version) throws java.io.IOException
model
- the model instance to updatedebugProtocol
- if non-null
, write all protocol commands to
this writerversion
- the version information to send to the server when
connectingjava.io.IOException
- if an internal error occurspublic void addClientSocketListener(@NotNull ClientSocketListener clientSocketListener)
ClientSocketListener
to notify.clientSocketListener
- the client socket listener to addprivate void cmdMap2Coordinate(@NotNull java.nio.ByteBuffer packet, int x, int y) throws UnknownCommandException
packet
- the packet contentsx
- the x-coordinate of the currently processed squarey
- the y-coordinate of the currently processed squareUnknownCommandException
- if the command cannot be parsedprivate void cmdMap2CoordinateClearSpace(int x, int y, int len) throws UnknownCommandException
x
- the x-coordinate of the currently processed squarey
- the y-coordinate of the currently processed squarelen
- the payload lengthUnknownCommandException
- if the command cannot be parsedprivate void cmdMap2CoordinateDarkness(@NotNull java.nio.ByteBuffer packet, int x, int y, int len) throws UnknownCommandException
packet
- the packet contentsx
- the x-coordinate of the currently processed squarey
- the y-coordinate of the currently processed squarelen
- the payload lengthUnknownCommandException
- if the command cannot be parsedprivate void cmdMap2CoordinateLayer(@NotNull java.nio.ByteBuffer packet, int x, int y, int len, int layer) throws UnknownCommandException
packet
- the packet contentsx
- the x-coordinate of the currently processed squarey
- the y-coordinate of the currently processed squarelen
- the payload lengthlayer
- the layer to updateUnknownCommandException
- if the command cannot be parsedprivate void cmdMap2CoordinateLayer3(@NotNull java.nio.ByteBuffer packet, @NotNull Location location, int face) throws UnknownCommandException
packet
- the packet contentslocation
- the locationface
- the face numberUnknownCommandException
- if the command cannot be parsedprivate void cmdMap2CoordinateLayer4(@NotNull java.nio.ByteBuffer packet, @NotNull Location location, int face) throws UnknownCommandException
packet
- the packet contentslocation
- the locationface
- the face numberUnknownCommandException
- if the command cannot be parsedprivate void cmdReplyinfo(@NotNull java.lang.String infoType, java.nio.ByteBuffer packet) throws java.io.IOException, UnknownCommandException
infoType
- the info_type parameterpacket
- the packet payload datajava.io.IOException
- if an I/O error occursUnknownCommandException
- if the packet cannot be parsedpublic void connect(@NotNull java.lang.String hostname, int port)
hostname
- the hostname to connect toport
- the port to connect toprivate void connected()
public void disconnect(@NotNull java.lang.String reason)
reason
- the reason for the disconnectprotected void fireAddAnimation(int animation, int flags, @NotNull int[] faces)
protected void fireMagicMap(int x, int y, @NotNull byte[][] data)
protected void fireMapAnimation(@NotNull Location location, int animationNum, int animationType)
protected void fireMapAnimationSpeed(@NotNull Location location, int animSpeed)
protected void fireMapClear(int x, int y)
protected void fireMapDarkness(int x, int y, int darkness)
protected void fireMapFace(@NotNull Location location, int face)
protected void fireMapSmooth(@NotNull Location location, int smooth)
private void fireNewMap()
@Nullable public java.lang.String getAccountName()
null
public int getCurrentNumLookObjects()
private static int getInt1(@NotNull java.nio.ByteBuffer byteBuffer)
ByteBuffer
at it's
current position.byteBuffer
- the byte bufferprivate static int getInt2(@NotNull java.nio.ByteBuffer byteBuffer)
ByteBuffer
at it's
current position.byteBuffer
- the byte bufferprivate static int getInt4(@NotNull java.nio.ByteBuffer byteBuffer)
ByteBuffer
at it's
current position.byteBuffer
- the byte bufferprivate static long getInt8(@NotNull java.nio.ByteBuffer byteBuffer)
ByteBuffer
at it's
current position.byteBuffer
- the byte buffer@NotNull private static java.lang.String getString(@NotNull java.nio.ByteBuffer byteBuffer, int len)
ByteBuffer
at it's current
position.byteBuffer
- the byte bufferlen
- the length of the string@NotNull private static java.lang.String getStringDelimiter(@NotNull java.nio.ByteBuffer byteBuffer, char delimiter)
ByteBuffer
at it's current
position.byteBuffer
- the byte bufferdelimiter
- the delimiter that ends the string@NotNull private static java.lang.String hexDump(@NotNull java.nio.ByteBuffer byteBuffer)
ByteBuffer
.byteBuffer
- the byte bufferprivate void negotiateMapSize(int mapWidth, int mapHeight)
mapWidth
- the map width to requestmapHeight
- the map height to request@NotNull private CharacterInformation parseAccountPlayer(@NotNull java.nio.ByteBuffer packet, @NotNull AccountPlayerBuilder accountPlayerBuilder) throws UnknownCommandException
packet
- the packet's payloadaccountPlayerBuilder
- the account player builder to useUnknownCommandException
- if the account entry cannot be parsedprivate static void parseClassRaceInfoChoice(@NotNull java.nio.ByteBuffer packet, @NotNull ClassRaceInfoBuilder rb)
packet
- the packet's contentsrb
- the race class race info builder to updateprivate static void parseClassRaceInfoStats(@NotNull java.nio.ByteBuffer packet, @NotNull ClassRaceInfoBuilder rb) throws UnknownCommandException
packet
- the packet's contentsrb
- the class race info builder to updateUnknownCommandException
- if the packet cannot be parsedprivate static int parseDigit(byte ch) throws UnknownCommandException
ch
- the character to parseUnknownCommandException
- if ch
is not a digitprivate static void parseNewCharInfoInformational(@NotNull java.lang.String variableName, @NotNull java.lang.String values)
variableName
- the variable name of the entryvalues
- the values of the variableprivate static void parseNewCharInfoValue(@NotNull NewCharInfoBuilder newCharInfoBuilder, boolean required, @NotNull java.lang.String variableName, @NotNull java.lang.String values) throws UnknownCommandException
newCharInfoBuilder
- the new char info builder instance to updaterequired
- whether the entry is required or optionalvariableName
- the variable name of the entryvalues
- the values of the variableUnknownCommandException
- if the entry cannot be parsedprivate static void parseNewCharInfoValues(@NotNull NewCharInfoBuilder newCharInfoBuilder, @NotNull java.lang.String variableName, @NotNull java.lang.String values) throws UnknownCommandException
newCharInfoBuilder
- the new char info builder instance to updatevariableName
- the variable name of the entryvalues
- the values of the variableUnknownCommandException
- if the entry cannot be parsedprivate void processAccountPlayers(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processAddKnowledge(@NotNull java.nio.ByteBuffer packet)
packet
- the packet to processprivate void processAddmeFailed(@NotNull java.nio.ByteBuffer packet)
packet
- the packet's payloadprivate void processAddmeSuccess(@NotNull java.nio.ByteBuffer packet)
packet
- the packet's payloadprivate void processAddQuest(@NotNull java.nio.ByteBuffer packet)
packet
- the packet's payloadprivate void processAddSpell(@NotNull java.nio.ByteBuffer packet)
packet
- the packet's payloadprivate void processAnim(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processClassListReplyinfo(@NotNull java.nio.ByteBuffer packet)
packet
- the packet to processprivate void processClassRaceInfoReplyinfo(@NotNull java.nio.ByteBuffer packet, boolean raceInfo) throws UnknownCommandException
packet
- the packet to processraceInfo
- if set, a "race_info" packet is parsed; if unset, a
"class_info" packet is parsedUnknownCommandException
- if the packet cannot be parsedprivate void processComc(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processDelInv(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processDelItem(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processDelSpell(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processDrawExtInfo(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processDrawInfo(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processExpTableReplyinfo(@NotNull java.nio.ByteBuffer packet)
packet
- the packet to processprivate void processExtendedInfoSet(@NotNull java.nio.ByteBuffer packet)
packet
- the packet's payloadprivate void processExtendedTextSet(@NotNull java.nio.ByteBuffer packet)
packet
- the packet's payloadprivate void processFace2(@NotNull java.nio.ByteBuffer packet)
packet
- the packet's payloadprivate void processFailure(@NotNull java.nio.ByteBuffer packet)
packet
- the packet's payloadprivate void processGoodbye(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processImage2(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate static void processImageInfoReplyinfo(@NotNull java.nio.ByteBuffer packet) throws java.io.IOException
packet
- the packet to processjava.io.IOException
- if the packet cannot be parsedprivate void processItem2(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processKnowledgeInfoReplyinfo(@NotNull java.nio.ByteBuffer packet) throws java.io.IOException
packet
- the packet to processjava.io.IOException
- if the packet cannot be parsedprivate void processMagicMap(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processMap2(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processMapExtended(@NotNull java.nio.ByteBuffer packet)
packet
- the packet's payloadprivate void processMusic(@NotNull java.nio.ByteBuffer packet)
packet
- the packet's payloadprivate void processNewCharInfoReplyinfo(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet to processUnknownCommandException
- if the packet cannot be parsedprivate void processNewMap(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processPacket(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
try...catch
clause is used to detect invalid packets.packet
- the packet's payloadUnknownCommandException
- if the packet cannot be parsedprivate void processPickup(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processPlayer(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processQuery(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processRaceListReplyinfo(@NotNull java.nio.ByteBuffer packet)
packet
- the packet to processprivate void processReplyInfo(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processSetup(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processSkillInfoReplyinfo(@NotNull java.nio.ByteBuffer packet) throws java.io.IOException
packet
- the packet to processjava.io.IOException
- if the packet cannot be parsedprivate void processSmooth(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processSound(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processSound2(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processStartingMapReplyinfo(@NotNull java.nio.ByteBuffer packet)
packet
- the packet to processprivate void processStats(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processTick(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processUpdItem(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processUpdQuest(@NotNull java.nio.ByteBuffer packet)
packet
- the packet's payloadprivate void processUpdSpell(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void processVersion(@NotNull java.nio.ByteBuffer packet) throws UnknownCommandException
packet
- the packet's payloadUnknownCommandException
- if the packet is invalidprivate void putDecimal(int value)
byteBuffer
.value
- the value to appendpublic void removeClientSocketListener(@NotNull ClientSocketListener clientSocketListener)
ClientSocketListener
to notify.clientSocketListener
- the client socket listener to removepublic void sendAccountCharacterCreate(@NotNull java.lang.String login, @NotNull java.lang.String password)
login
- the character's namepassword
- the character's passwordpublic void sendAccountCreate(@NotNull java.lang.String login, @NotNull java.lang.String password)
login
- the account loginpassword
- the account passwordpublic void sendAccountLink(int force, @NotNull java.lang.String login, @NotNull java.lang.String password)
force
- 0 to allow failure, 1 to force in certain situationslogin
- the character's loginpassword
- the character's passwordpublic void sendAccountLogin(@NotNull java.lang.String login, @NotNull java.lang.String password)
login
- the account loginpassword
- the account passwordpublic void sendAccountPassword(@NotNull java.lang.String currentPassword, @NotNull java.lang.String newPassword)
currentPassword
- current account passwordnewPassword
- new account passwordpublic void sendAccountPlay(@NotNull java.lang.String name)
name
- the character's name to playpublic void sendAddme()
public void sendApply(int tag)
tag
- the item to applypublic void sendAskface(int faceNum)
faceNum
- the face number to requestpublic void sendExamine(int tag)
tag
- the item to examinepublic void sendLock(boolean val, int tag)
val
- whether to lock the itemtag
- the item to lockpublic void sendLookat(int dx, int dy)
dx
- the x-coordinate in tiles, relative to the playerdy
- the y-coordinate in tiles, relative to the playerpublic void sendMark(int tag)
tag
- the item to markpublic void sendMove(int to, int tag, int nrof)
to
- the destination locationtag
- the item to movenrof
- the number of items to movepublic int sendNcom(int repeat, @NotNull java.lang.String command)
repeat
- the repeat countcommand
- the commandprivate void sendPendingRequestInfo()
private void sendQueuedRequestinfo(@NotNull java.lang.String infoType)
infoType
- the packet's payloadpublic void sendReply(@NotNull java.lang.String text)
text
- the text to replypublic void sendRequestinfo(@NotNull java.lang.String infoType)
infoType
- the info type to requestpublic void sendSetup(@NotNull java.lang.String... options)
options
- the option/value pairs to sendpublic void sendToggleextendedtext(@NotNull int... types)
types
- the types to requestpublic void sendVersion(int csval, int scval, @NotNull java.lang.String vinfo)
csval
- the client version numberscval
- the server version numbervinfo
- the client identification stringprivate void setClientSocketState(@NotNull ClientSocketState prevState, @NotNull ClientSocketState nextState)
clientSocketState
.prevState
- the expected current statenextState
- the next statepublic void setCrossfireUpdateMapListener(@Nullable CrossfireUpdateMapListener listener)
listener
- the listener to set or null
to unset itprivate void setCurrentMapSize(int currentMapWidth, int currentMapHeight)
currentMapWidth
- the new map widthcurrentMapHeight
- the new map heightpublic void setPreferredMapSize(int preferredMapWidth, int preferredMapHeight)
preferredMapWidth
- the preferred map width in tiles; must be oddpreferredMapHeight
- the preferred map height in tiles; must be oddpublic void setPreferredNumLookObjects(int preferredNumLookObjects)
preferredNumLookObjects
- the number of objectspublic void start()
public void stop() throws java.lang.InterruptedException
java.lang.InterruptedException
- if stopping was interruptedpublic void waitForCurrentNumLookObjectsValid() throws java.lang.InterruptedException
getCurrentNumLookObjects()
is stable. This function
returns as soon as the negotiation with the Crossfire server is
complete.java.lang.InterruptedException
- if the current thread was interrupted