de.stefan1200.jts3serverquery

## Class JTS3ServerQuery

- java.lang.Object
- - de.stefan1200.jts3serverquery.JTS3ServerQuery

-     public class JTS3ServerQuery
      extends Object

  JTS3ServerQuery library version 2.0.6
  This library allows you to create a query connection to the Teamspeak 3 telnet interface. Almost anything is supported: Query lists or just information, get log entries, receiving events, add or delete complains, kick or move clients and of course send own commands.
  This library is free for use, but please notify me if you found a bug or if you have some suggestion. The author of this library is not responsible for any damage or data loss! It is not allowed to sell this library for money, it has to be free to get!
  E-Mail:
  info@stefan1200.de
  Homepage:
  http://www.stefan1200.de
  Version:
    2.0.6 (20.11.2016)
  Author:
    Stefan Martens

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `boolean` | `DEBUG` Setting DEBUG to `true` will write every internal exception into an error log file and write the communication log file.
    `String` | `DEBUG_COMMLOG_PATH` Set the path to the communication log file or `null` to disable writing of this log file.
    `String` | `DEBUG_ERRLOG_PATH` Set the path to the error log file or `null` to disable writing of this log file.
    `static int` | `EVENT_MODE_CHANNEL` Event mode for addEventNotify() to add channel events (like clients join or left the channel).
    `static int` | `EVENT_MODE_SERVER` Event mode for addEventNotify() to add server events (like clients join or left the server).
    `static int` | `EVENT_MODE_TEXTCHANNEL` Event mode for addEventNotify() to add channel chat events (like receiving or sending chat messages).
    `static int` | `EVENT_MODE_TEXTPRIVATE` Event mode for addEventNotify() to add private chat events (like receiving or sending chat messages).
    `static int` | `EVENT_MODE_TEXTSERVER` Event mode for addEventNotify() to add server chat events (like receiving or sending chat messages).
    `static int` | `INFOMODE_CHANNELINFO` Info mode for getInfo(), use this mode to get information about a channel.
    `static int` | `INFOMODE_CLIENTDBINFO` Info mode for getInfo(), use this mode to get information about a client from the database.
    `static int` | `INFOMODE_CLIENTINFO` Info mode for getInfo(), use this mode to get information about a client.
    `static int` | `INFOMODE_SERVERINFO` Info mode for getInfo(), use this mode to get information about the current selected server.
    `static int` | `LISTMODE_BANLIST` List mode for getList(), use this mode to get a list of bans.
    `static int` | `LISTMODE_CHANNELGROUPLIST` List mode for getList(), use this mode to get a list of channel groups.
    `static int` | `LISTMODE_CHANNELLIST` List mode for getList(), use this mode to get a list of current channels.
    `static int` | `LISTMODE_CLIENTDBLIST` List mode for getList(), use this mode to get a list of all clients in database.
    `static int` | `LISTMODE_CLIENTLIST` List mode for getList(), use this mode to get a list of clients currently online.
    `static int` | `LISTMODE_COMPLAINLIST` List mode for getList(), use this mode to get a list of complains.
    `static int` | `LISTMODE_PERMISSIONLIST` List mode for getList(), use this mode to get a list of permissions.
    `static int` | `LISTMODE_SERVERGROUPCLIENTLIST` List mode for getList(), use this mode to get a list of server group members.
    `static int` | `LISTMODE_SERVERGROUPLIST` List mode for getList(), use this mode to get a list of server groups.
    `static int` | `LISTMODE_SERVERGROUPSBYCLIENTID` List mode for getList(), use this mode to get a list of server groups from a client.
    `static int` | `LISTMODE_SERVERLIST` List mode for getList(), use this mode to get a list of virtual servers.
    `static int` | `PERMLISTMODE_CHANNEL` Permission list mode for getPermissionList(), use this mode to get a list of channel permissions.
    `static int` | `PERMLISTMODE_CLIENT` Permission list mode for getPermissionList(), use this mode to get a list of client permissions.
    `static int` | `PERMLISTMODE_SERVERGROUP` Permission list mode for getPermissionList(), use this mode to get a list of server group permissions.
    `static int` | `TEXTMESSAGE_TARGET_CHANNEL` Text message target mode for sendTextMessage() to send a message to a channel.
    `static int` | `TEXTMESSAGE_TARGET_CLIENT` Text message target mode for sendTextMessage() to send a message to a single client.
    `static int` | `TEXTMESSAGE_TARGET_GLOBAL` Text message target mode for sendTextMessage() to send a message to all virtual servers.
    `static int` | `TEXTMESSAGE_TARGET_VIRTUALSERVER` Text message target mode for sendTextMessage() to send a message to a virtual server.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JTS3ServerQuery()`
    `JTS3ServerQuery(String threadName)` New JTS3ServerQuery object which allows to set a prefix for the handleAction thread name.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addEventNotify(int eventMode, int channelID)` Activate a Teamspeak event notify.
    `void` | `changeThreadName(String threadName)` Set a new thread name prefix
    `void` | `closeTS3Connection()` Close the query connection.
    `void` | `complainAdd(int clientDBID, String msg)` Add a complain to a client.
    `void` | `complainDelete(int clientDBID, int deleteClientDBID)` Deletes complains from a client (from a specified sender).
    `void` | `connectTS3Query(String ip, int queryport)` Open a query connection to the TS3 server.
    `void` | `connectTS3Query(String ip, int queryport, String localIP, int localPort)` Open a query connection to the TS3 server, you can set a local IP and port to bind the socket to it.
    `String` | `decodeTS3String(String str)` Convert escaped characters to normal characters.
    `void` | `deleteChannel(int channelID, boolean forceDelete)` Delete a channel of the server.
    `HashMap<String,String>` | `doCommand(String command)` Send a single command to the TS3 server and read the response.
    `String` | `encodeTS3String(String str)` Escape all special characters for the TS3 server.
    `int` | `getClientDBIDFromUID(String uniqueID)` Get the client database id of a client unique id.
    `int` | `getCurrentQueryClientChannelID()` Returns the current channel ID of the query client.
    `int` | `getCurrentQueryClientDatabaseID()` Returns the current client database ID of the query connection.
    `int` | `getCurrentQueryClientID()` Returns the current client ID of the query connection.
    `String` | `getCurrentQueryClientName()` Returns the current client name of the query client.
    `int` | `getCurrentQueryClientServerID()` Returns the current virtual server ID of the query connection.
    `int` | `getCurrentQueryClientServerPort()` Returns the current virtual server port of the query connection.
    `String` | `getCurrentQueryClientUniqueID()` Returns the current client unique ID of the query connection.
    `HashMap<String,String>` | `getInfo(int infoMode, int objectID)` Get information about a server, channel or client.
    `Vector<HashMap<String,String>>` | `getList(int listMode)` Get a list from the TS3 server.
    `Vector<HashMap<String,String>>` | `getList(int listMode, String arguments)` Get a list from the TS3 server.
    `Vector<HashMap<String,String>>` | `getLogEntries(int linesCount, boolean reverse, boolean masterlog, int beginpos)` Returns log entries.
    `HashMap<String,String>` | `getPermissionInfo(int permID)` Get information about a permission ID.
    `Vector<HashMap<String,String>>` | `getPermissionList(int permListMode, int targetID)` Get a list of permissions of a server group / channel / client.
    `boolean` | `isConnected()` Check if connected to the TS3 server.
    `void` | `kickClient(int clientID, boolean onlyChannelKick, String kickReason)` Kick a client from channel or from server.
    `void` | `loginTS3(String loginname, String password)` Login with an account.
    `void` | `moveClient(int clientID, int channelID, String channelPassword)` Move a client into another channel.
    `HashMap<String,String>` | `parseLine(String line)` Parse an unformatted single line response from TS3 server, like from the doCommand method.
    `Vector<HashMap<String,String>>` | `parseRawData(String rawData)` Parse unformatted response from TS3 server, like from the doCommand method.
    `void` | `pokeClient(int clientID, String msg)` Poke a client.
    `void` | `removeAllEvents()` Removes all activated events.
    `void` | `removeTeamspeakActionListener()` Remove the class from receiving Teamspeak events.
    `Vector<Integer>` | `searchClientDB(String search, boolean isUID)` Searching for clients in the TS3 client database, useful for the getInfo() method to request more information.
    `void` | `selectVirtualServer(int serverID)` Select a virtual server to work with.
    `void` | `selectVirtualServer(int server, boolean selectPort)` Select a virtual server to work with.
    `void` | `selectVirtualServer(int server, boolean selectPort, boolean virtual)` Select a virtual server to work with.
    `void` | `sendTextMessage(int targetID, int targetMode, String msg)` Sends a text message to a client / channel / virtual server / global (all virtual servers).
    `void` | `sendTextMessage(int targetID, int targetMode, String msg, String channelPassword)` Sends a text message to a client / channel / virtual server / global (all virtual servers).
    `void` | `setDisplayName(String displayName)` Change the display name on the Teamspeak 3 server of this query connection.
    `void` | `setTeamspeakActionListener(TeamspeakActionListener listenerClass)` Set a class that should receive the Teamspeak events.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEBUG

          public boolean DEBUG

      Setting DEBUG to `true` will write every internal exception into an error log file and write the communication log file. It is also possible to set the filename and path to the communication and error log file, see DEBUG_COMMLOG_PATH and DEBUG_ERRLOG_PATH.
      Since:
        1.0.4
      See Also:
        `DEBUG_COMMLOG_PATH`, `DEBUG_ERRLOG_PATH`

    - #### DEBUG_COMMLOG_PATH

          public String DEBUG_COMMLOG_PATH

      Set the path to the communication log file or `null` to disable writing of this log file. This will be used only if DEBUG is set to `true`. In the communication log file you can see any outgoing and incoming messages between this library and the TS3 server.
      Since:
        1.0.4
      See Also:
        `DEBUG`

    - #### DEBUG_ERRLOG_PATH

          public String DEBUG_ERRLOG_PATH

      Set the path to the error log file or `null` to disable writing of this log file. This will be used only if DEBUG is set to `true`. In the error log file you can see all internal exceptions thrown by this library.
      Since:
        1.0.10
      See Also:
        `DEBUG`

    - #### EVENT_MODE_CHANNEL

          public static final int EVENT_MODE_CHANNEL

      Event mode for addEventNotify() to add channel events (like clients join or left the channel).
      Notice:
      This mode also need to set a channel ID.
      Since:
        0.7
      See Also:
        `addEventNotify(int, int)`, Constant Field Values

    - #### EVENT_MODE_SERVER

          public static final int EVENT_MODE_SERVER

      Event mode for addEventNotify() to add server events (like clients join or left the server).
      Since:
        0.7
      See Also:
        `addEventNotify(int, int)`, Constant Field Values

    - #### EVENT_MODE_TEXTCHANNEL

          public static final int EVENT_MODE_TEXTCHANNEL

      Event mode for addEventNotify() to add channel chat events (like receiving or sending chat messages).
      Since:
        0.7
      See Also:
        `addEventNotify(int, int)`, Constant Field Values

    - #### EVENT_MODE_TEXTPRIVATE

          public static final int EVENT_MODE_TEXTPRIVATE

      Event mode for addEventNotify() to add private chat events (like receiving or sending chat messages).
      Since:
        0.7
      See Also:
        `addEventNotify(int, int)`, Constant Field Values

    - #### EVENT_MODE_TEXTSERVER

          public static final int EVENT_MODE_TEXTSERVER

      Event mode for addEventNotify() to add server chat events (like receiving or sending chat messages).
      Since:
        0.7
      See Also:
        `addEventNotify(int, int)`, Constant Field Values

    - #### INFOMODE_CHANNELINFO

          public static final int INFOMODE_CHANNELINFO

      Info mode for getInfo(), use this mode to get information about a channel. The second parameter has to be a channel id.
      See Also:
        `getInfo(int, int)`, Constant Field Values

    - #### INFOMODE_CLIENTDBINFO

          public static final int INFOMODE_CLIENTDBINFO

      Info mode for getInfo(), use this mode to get information about a client from the database. The second parameter has to be a client database id.
      Since:
        2.0.2
      See Also:
        `getInfo(int, int)`, Constant Field Values

    - #### INFOMODE_CLIENTINFO

          public static final int INFOMODE_CLIENTINFO

      Info mode for getInfo(), use this mode to get information about a client. The second parameter has to be a client id.
      See Also:
        `getInfo(int, int)`, Constant Field Values

    - #### INFOMODE_SERVERINFO

          public static final int INFOMODE_SERVERINFO

      Info mode for getInfo(), use this mode to get information about the current selected server. The second parameter is not needed, just use a number like 0.
      See Also:
        `getInfo(int, int)`, Constant Field Values

    - #### LISTMODE_BANLIST

          public static final int LISTMODE_BANLIST

      List mode for getList(), use this mode to get a list of bans.
      See Also:
        `getList(int)`, `getList(int, String)`, Constant Field Values

    - #### LISTMODE_CHANNELGROUPLIST

          public static final int LISTMODE_CHANNELGROUPLIST

      List mode for getList(), use this mode to get a list of channel groups.
      Since:
        2.0.5
      See Also:
        `getList(int)`, `getList(int, String)`, Constant Field Values

    - #### LISTMODE_CHANNELLIST

          public static final int LISTMODE_CHANNELLIST

      List mode for getList(), use this mode to get a list of current channels.
      Possible optional arguments:
      `-topic
      -flags
      -voice
      -limits
      -icon
      -secondsempty`
      See Also:
        `getList(int)`, `getList(int, String)`, Constant Field Values

    - #### LISTMODE_CLIENTDBLIST

          public static final int LISTMODE_CLIENTDBLIST

      List mode for getList(), use this mode to get a list of all clients in database. By default only the first 25 entries will be returned.
      Possible optional arguments:
      `start=<number>
      duration=<number>
      -count`
      For example:
      `start=0
      duration=25`
      Important:
      Requesting to many clients at once make the TS3 server unstable.
      See Also:
        `getList(int)`, `getList(int, String)`, Constant Field Values

    - #### LISTMODE_CLIENTLIST

          public static final int LISTMODE_CLIENTLIST

      List mode for getList(), use this mode to get a list of clients currently online.
      Possible optional arguments:
      `-uid
      -away
      -voice
      -times
      -groups
      -info
      -icon
      -country
      -ip`
      See Also:
        `getList(int)`, `getList(int, String)`, Constant Field Values

    - #### LISTMODE_COMPLAINLIST

          public static final int LISTMODE_COMPLAINLIST

      List mode for getList(), use this mode to get a list of complains. Without arguments you get a list of all complains on the server. Use the optional argument to get complains of only one client.
      Possible optional arguments:
      `tcldbid=<client database ID>`
      For example:
      `tcldbid=2`
      Since:
        1.0
      See Also:
        `getList(int)`, `getList(int, String)`, Constant Field Values

    - #### LISTMODE_PERMISSIONLIST

          public static final int LISTMODE_PERMISSIONLIST

      List mode for getList(), use this mode to get a list of permissions.
      See Also:
        `getList(int)`, `getList(int, String)`, Constant Field Values

    - #### LISTMODE_SERVERGROUPCLIENTLIST

          public static final int LISTMODE_SERVERGROUPCLIENTLIST

      List mode for getList(), use this mode to get a list of server group members.
      Required argument:
      `sgid=<server group ID>`
      For example:
      `sgid=6`
      Possible optional argument:
      `-names`
      Since:
        2.0.1
      See Also:
        `getList(int)`, `getList(int, String)`, Constant Field Values

    - #### LISTMODE_SERVERGROUPLIST

          public static final int LISTMODE_SERVERGROUPLIST

      List mode for getList(), use this mode to get a list of server groups.
      See Also:
        `getList(int)`, `getList(int, String)`, Constant Field Values

    - #### LISTMODE_SERVERGROUPSBYCLIENTID

          public static final int LISTMODE_SERVERGROUPSBYCLIENTID

      List mode for getList(), use this mode to get a list of server groups from a client.
      Required argument:
      `cldbid=<client database ID>`
      For example:
      `cldbid=159`
      Since:
        2.0.3
      See Also:
        `getList(int)`, `getList(int, String)`, Constant Field Values

    - #### LISTMODE_SERVERLIST

          public static final int LISTMODE_SERVERLIST

      List mode for getList(), use this mode to get a list of virtual servers.
      Possible optional arguments:
      `-all
      -onlyoffline
      -short
      -uid`
      See Also:
        `getList(int)`, `getList(int, String)`, Constant Field Values

    - #### PERMLISTMODE_CHANNEL

          public static final int PERMLISTMODE_CHANNEL

      Permission list mode for getPermissionList(), use this mode to get a list of channel permissions. The second parameter has to be a channel id.
      See Also:
        `getPermissionList(int, int)`, Constant Field Values

    - #### PERMLISTMODE_CLIENT

          public static final int PERMLISTMODE_CLIENT

      Permission list mode for getPermissionList(), use this mode to get a list of client permissions. The second parameter has to be a client database id.
      See Also:
        `getPermissionList(int, int)`, Constant Field Values

    - #### PERMLISTMODE_SERVERGROUP

          public static final int PERMLISTMODE_SERVERGROUP

      Permission list mode for getPermissionList(), use this mode to get a list of server group permissions. The second parameter has to be a server group id.
      See Also:
        `getPermissionList(int, int)`, Constant Field Values

    - #### TEXTMESSAGE_TARGET_CHANNEL

          public static final int TEXTMESSAGE_TARGET_CHANNEL

      Text message target mode for sendTextMessage() to send a message to a channel.
      See Also:
        `sendTextMessage(int, int, String)`, Constant Field Values

    - #### TEXTMESSAGE_TARGET_CLIENT

          public static final int TEXTMESSAGE_TARGET_CLIENT

      Text message target mode for sendTextMessage() to send a message to a single client.
      See Also:
        `sendTextMessage(int, int, String)`, Constant Field Values

    - #### TEXTMESSAGE_TARGET_GLOBAL

          public static final int TEXTMESSAGE_TARGET_GLOBAL

      Text message target mode for sendTextMessage() to send a message to all virtual servers.
      See Also:
        `sendTextMessage(int, int, String)`, Constant Field Values

    - #### TEXTMESSAGE_TARGET_VIRTUALSERVER

          public static final int TEXTMESSAGE_TARGET_VIRTUALSERVER

      Text message target mode for sendTextMessage() to send a message to a virtual server.
      See Also:
        `sendTextMessage(int, int, String)`, Constant Field Values

  - ### Constructor Detail

    - #### JTS3ServerQuery

          public JTS3ServerQuery()

    - #### JTS3ServerQuery

          public JTS3ServerQuery(String threadName)

      New JTS3ServerQuery object which allows to set a prefix for the handleAction thread name.
      Parameters:
        `threadName` - Prefix of the thread name
      Since:
        1.0.8

  - ### Method Detail

    - #### addEventNotify

          public void addEventNotify(int eventMode,
                                     int channelID)
                              throws TS3ServerQueryException

      Activate a Teamspeak event notify.
      Notice:
      You have to use setTeamspeakActionListener() first!
      Parameters:
        `eventMode` - Use an EVENT_MODE constant
        `channelID` - A channel ID, only needed for EVENT_MODE_CHANNEL. Use any number for any other EVENT_MODE.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server or no TeamspeakActionListener class was set using setTeamspeakActionListener().
        `IllegalArgumentException` - If invalid eventMode was given.
      Since:
        0.7
      See Also:
        `EVENT_MODE_CHANNEL`, `EVENT_MODE_SERVER`, `EVENT_MODE_TEXTCHANNEL`, `EVENT_MODE_TEXTPRIVATE`, `EVENT_MODE_TEXTSERVER`, `setTeamspeakActionListener(TeamspeakActionListener)`

    - #### changeThreadName

          public void changeThreadName(String threadName)

      Set a new thread name prefix
      Parameters:
        `threadName` - - The new prefix
      Since:
        1.0.8

    - #### closeTS3Connection

          public void closeTS3Connection()

      Close the query connection.

    - #### complainAdd

          public void complainAdd(int clientDBID,
                                  String msg)
                           throws TS3ServerQueryException

      Add a complain to a client.
      Parameters:
        `clientDBID` - The client database ID, which should get the complain.
        `msg` - The message of the complain.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.
        `IllegalArgumentException` - If no message given.
      Since:
        1.0

    - #### complainDelete

          public void complainDelete(int clientDBID,
                                     int deleteClientDBID)
                              throws TS3ServerQueryException

      Deletes complains from a client (from a specified sender).
      Parameters:
        `clientDBID` - The client database ID, which should get a complain removed.
        `deleteClientDBID` - Delete complains submitted from this client database ID.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.
        `IllegalArgumentException` - If no message given.
      Since:
        1.0

    - #### connectTS3Query

          public void connectTS3Query(String ip,
                                      int queryport)
                               throws Exception

      Open a query connection to the TS3 server.
      Parameters:
        `ip` - IP or Host address to the TS3 server
        `queryport` - Query Port of the TS3 server
      Throws:
        `IllegalStateException` - If already connected or an invalid response detected.
        `EOFException` - If the connection was closed unexpected (maybe banned by the TS3 server).
        `IOException` - If an I/O error occurs when creating the socket or streams.
        `UnsupportedEncodingException` - If the UTF-8 charset is not supported.
        `Exception`

    - #### connectTS3Query

          public void connectTS3Query(String ip,
                                      int queryport,
                                      String localIP,
                                      int localPort)
                               throws Exception

      Open a query connection to the TS3 server, you can set a local IP and port to bind the socket to it.
      Parameters:
        `ip` - IP or Host address to the TS3 server
        `queryport` - Query Port of the TS3 server
        `localIP` - Local IP address to bind the socket or `null` to bind to default IP. localPort must be set to use localIP.
        `localPort` - Local Port to bind the socket, localIP must be set to use localPort.
      Throws:
        `IllegalStateException` - If already connected or an invalid response detected.
        `EOFException` - If the connection was closed unexpected (maybe banned by the TS3 server).
        `IOException` - If an I/O error occurs when creating the socket or streams.
        `UnsupportedEncodingException` - If the UTF-8 charset is not supported.
        `Exception`
      Since:
        1.0.4

    - #### decodeTS3String

          public String decodeTS3String(String str)

      Convert escaped characters to normal characters.
      Use this for received String values after using doCommand()
      Important:
      Almost all functions in this library do this already if needed. You only need this if you want to read the server response after using doCommand() without using parseRawData().
      Parameters:
        `str` - The String which should be unescaped.
      Returns:
        The unescaped String
      Since:
        0.5
      See Also:
        `doCommand(String)`, `parseRawData(String)`

    - #### deleteChannel

          public void deleteChannel(int channelID,
                                    boolean forceDelete)
                             throws TS3ServerQueryException

      Delete a channel of the server.
      Parameters:
        `channelID` - The Channel ID to be deleted
        `forceDelete` - `true` for a force channel delete (kicks also clients out of it), `false` to delete only an empty channel
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.

    - #### doCommand

          public HashMap<String,String> doCommand(String command)

      Send a single command to the TS3 server and read the response.
      Notice:
      You can use parseRawData() to get the response String in a HashMap.
      The returned HashMap can also contain a library error id and error message, if the connection to the Teamspeak 3 Server got lost while reading the response.
      Important:
      Do not use the following commands here:
      `channeldelete`
      `clientmove`
      `use`
      Please use deleteChannel(), moveClient() or selectVirtualServer() instead!
      Parameters:
        `command` - Any TS3 telnet command, see TS3 documentation or use the `help` command.
      Returns:
        An HashMap with 3 keys: `id` (error id), `msg` (error message) and `response` (unformatted server response).
      Throws:
        `IllegalArgumentException` - If command missing or not allowed.
        `IllegalStateException` - If not connected to a TS3 server or connection was closed while receiving the response.
      See Also:
        `deleteChannel(int, boolean)`, `moveClient(int, int, String)`, `selectVirtualServer(int)`

    - #### encodeTS3String

          public String encodeTS3String(String str)

      Escape all special characters for the TS3 server.
      Use this for all Strings you use as value while using doCommand()!
      Important:
      Almost all functions in this library do this already if needed. You only need this if you want to send an own command with doCommand().
      Parameters:
        `str` - The String which should be escaped.
      Returns:
        The escaped String
      Since:
        0.5
      See Also:
        `doCommand(String)`

    - #### getClientDBIDFromUID

          public int getClientDBIDFromUID(String uniqueID)
                                   throws TS3ServerQueryException

      Get the client database id of a client unique id.
      Parameters:
        `uniqueID` - The client unique id.
      Returns:
        The client db id as int.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server or invalid server response received.
        `IllegalArgumentException` - If uniqueID argument is invalid or missing.
        `NumberFormatException` - If the TS3 server sends an invalid client db id.
      Since:
        2.0.3

    - #### getCurrentQueryClientChannelID

          public int getCurrentQueryClientChannelID()

      Returns the current channel ID of the query client.
      Returns:
        The channel ID or -1 if unknown.
      Since:
        0.6

    - #### getCurrentQueryClientDatabaseID

          public int getCurrentQueryClientDatabaseID()

      Returns the current client database ID of the query connection. You need this maybe to identify the client or something else.
      Returns:
        The client database ID or -1 if unknown.
      Since:
        2.0.6

    - #### getCurrentQueryClientID

          public int getCurrentQueryClientID()

      Returns the current client ID of the query connection. You need this maybe to move the client or something else.
      Returns:
        The client ID or -1 if unknown.
      Since:
        0.6

    - #### getCurrentQueryClientName

          public String getCurrentQueryClientName()

      Returns the current client name of the query client.
      Returns:
        The client name or `null` if nothing set.
      Since:
        2.0

    - #### getCurrentQueryClientServerID

          public int getCurrentQueryClientServerID()

      Returns the current virtual server ID of the query connection.
      Returns:
        The virtual server ID or -1 if unknown.
      Since:
        0.6

    - #### getCurrentQueryClientServerPort

          public int getCurrentQueryClientServerPort()

      Returns the current virtual server port of the query connection.
      Returns:
        The virtual server port or -1 if unknown.
      Since:
        2.0

    - #### getCurrentQueryClientUniqueID

          public String getCurrentQueryClientUniqueID()

      Returns the current client unique ID of the query connection. You need this maybe to identify the client or something else.
      Returns:
        The client unique ID or null if unknown.
      Since:
        2.0.6

    - #### getInfo

          public HashMap<String,String> getInfo(int infoMode,
                                                int objectID)
                                         throws TS3ServerQueryException

      Get information about a server, channel or client.
      Notice:
      If you want server information, the server will return information only about the current selected virtual server. To get information about another virtual server, just select first.
      Parameters:
        `infoMode` - An INFOMODE constant.
        `objectID` - A channel or client ID, use any number for server information.
      Returns:
        A HashMap with the information as key / value pairs like in the TS3 server response.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server or invalid server response received.
        `IllegalArgumentException` - If infoMode argument is invalid.
      See Also:
        `INFOMODE_CHANNELINFO`, `INFOMODE_CLIENTINFO`, `INFOMODE_CLIENTDBINFO`, `INFOMODE_SERVERINFO`, `selectVirtualServer(int)`

    - #### getList

          public Vector<HashMap<String,String>> getList(int listMode)
                                                 throws TS3ServerQueryException

      Get a list from the TS3 server. Use LISTMODE constants to get the wanted list.
      Parameters:
        `listMode` - Use a LISTMODE constant
      Returns:
        A Vector which contains a HashMap for each entry with the keys given by the TS3 Server.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server or invalid server response received.
        `IllegalArgumentException` - If listMode argument is invalid.
      See Also:
        `LISTMODE_BANLIST`, `LISTMODE_CHANNELLIST`, `LISTMODE_CLIENTDBLIST`, `LISTMODE_CLIENTLIST`, `LISTMODE_COMPLAINLIST`, `LISTMODE_PERMISSIONLIST`, `LISTMODE_SERVERGROUPLIST`, `LISTMODE_SERVERLIST`, `LISTMODE_SERVERGROUPCLIENTLIST`, `LISTMODE_SERVERGROUPSBYCLIENTID`

    - #### getList

          public Vector<HashMap<String,String>> getList(int listMode,
                                                        String arguments)
                                                 throws TS3ServerQueryException

      Get a list from the TS3 server. Use LISTMODE constants to get the wanted list.
      This method allows to pass many arguments separated with comma, see LISTMODE comments for possible arguments.
      Parameters:
        `listMode` - Use a LISTMODE constant
        `arguments` - A comma separated list of arguments or a single argument for the LISTMODE. Or just `null` if no arguments needed.
      Returns:
        A Vector which contains a HashMap for each entry with the keys given by the TS3 Server.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server or invalid server response received.
        `IllegalArgumentException` - If listMode argument is invalid.
      See Also:
        `LISTMODE_BANLIST`, `LISTMODE_CHANNELLIST`, `LISTMODE_CLIENTDBLIST`, `LISTMODE_CLIENTLIST`, `LISTMODE_COMPLAINLIST`, `LISTMODE_PERMISSIONLIST`, `LISTMODE_SERVERGROUPLIST`, `LISTMODE_SERVERLIST`, `LISTMODE_SERVERGROUPCLIENTLIST`, `LISTMODE_SERVERGROUPSBYCLIENTID`

    - #### getLogEntries

          public Vector<HashMap<String,String>> getLogEntries(int linesCount,
                                                              boolean reverse,
                                                              boolean masterlog,
                                                              int beginpos)
                                                       throws TS3ServerQueryException

      Returns log entries.
      Parameters:
        `linesCount` - How many log entries should be returned, has to be between 1 and 100.
        `reverse` - Return lines in reverse order of the log (newest entry first)?
        `masterlog` - Return lines from master instance log? Set to false to get the log entries of the selected server!
        `beginpos` - Start position in bytes, default is 0.
      Returns:
        A Vector which contains a HashMap for each entry with the keys given by the TS3 Server.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server or invalid server response received.
        `IllegalArgumentException` - If listLimitCount or beginpos argument is invalid.
      Since:
        0.4

    - #### getPermissionInfo

          public HashMap<String,String> getPermissionInfo(int permID)
                                                   throws TS3ServerQueryException

      Get information about a permission ID.
      If the permission ID was found, the HashMap will contain the following keys:
      `permid` with the permission ID
      `permname` with the permission name
      `permdesc` with the permission description (may be empty, if not exist)
      Parameters:
        `permID` - A permission ID
      Returns:
        A HashMap with the information about the permission ID.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server or invalid server response received.

    - #### getPermissionList

          public Vector<HashMap<String,String>> getPermissionList(int permListMode,
                                                                  int targetID)
                                                           throws TS3ServerQueryException

      Get a list of permissions of a server group / channel / client.
      Parameters:
        `permListMode` - A PERMLISTMODE constant
        `targetID` - A channel, client or server group ID
      Returns:
        A Vector which contains a HashMap for each entry with the keys given by the TS3 Server.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server or invalid server response received.
        `IllegalArgumentException` - If permListMode argument is invalid.
      See Also:
        `PERMLISTMODE_CHANNEL`, `PERMLISTMODE_CLIENT`, `PERMLISTMODE_SERVERGROUP`

    - #### isConnected

          public boolean isConnected()

      Check if connected to the TS3 server.
      Returns:
        `true` if connected, `false` if not.

    - #### kickClient

          public void kickClient(int clientID,
                                 boolean onlyChannelKick,
                                 String kickReason)
                          throws TS3ServerQueryException

      Kick a client from channel or from server.
      Parameters:
        `clientID` - The Client ID to be kicked
        `onlyChannelKick` - `true` for a channel kick, `false` for a server kick
        `kickReason` - The kick reason
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.

    - #### loginTS3

          public void loginTS3(String loginname,
                               String password)
                        throws TS3ServerQueryException

      Login with an account.
      Parameters:
        `loginname` - Login name
        `password` - Login password
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.
      Since:
        0.8

    - #### moveClient

          public void moveClient(int clientID,
                                 int channelID,
                                 String channelPassword)
                          throws TS3ServerQueryException

      Move a client into another channel.
      Parameters:
        `clientID` - Current Client ID
        `channelID` - Target Channel ID
        `channelPassword` - Password of the target channel or `null` if no password needed
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.

    - #### parseLine

          public HashMap<String,String> parseLine(String line)

      Parse an unformatted single line response from TS3 server, like from the doCommand method.
      Notice:
      Don't use this for help messages, since they are already formatted by the TS3 server!
      Also don't use this for lists, use getList() or parseRawData() instead!
      Parameters:
        `line` - The unformatted single line TS3 server response
      Returns:
        A HashMap with the keys given by the TS3 Server.
      Throws:
        `NullPointerException` - If line is `null`.
      See Also:
        `getList(int)`, `getList(int, String)`, `parseRawData(String)`

    - #### parseRawData

          public Vector<HashMap<String,String>> parseRawData(String rawData)

      Parse unformatted response from TS3 server, like from the doCommand method.
      Notice:
      Don't use this for help messages, since they are already formatted by the TS3 server!
      If you only have a single line response, you can also use the parseLine() method!
      Parameters:
        `rawData` - The unformatted TS3 server response.
      Returns:
        A Vector which contains a HashMap for each entry with the keys given by the TS3 Server.
      Throws:
        `NullPointerException` - If rawData is `null`.
      See Also:
        `parseLine(String)`

    - #### pokeClient

          public void pokeClient(int clientID,
                                 String msg)
                          throws TS3ServerQueryException

      Poke a client. This opens a message dialog at the selected Teamspeak 3 client with the given message.
      Parameters:
        `clientID` - The client ID, which should get the message.
        `msg` - The message for the message dialog.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.
        `IllegalArgumentException` - If no message given.
      Since:
        0.4

    - #### removeAllEvents

          public void removeAllEvents()
                               throws TS3ServerQueryException

      Removes all activated events.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.
      Since:
        0.7

    - #### removeTeamspeakActionListener

          public void removeTeamspeakActionListener()
                                             throws TS3ServerQueryException

      Remove the class from receiving Teamspeak events. This function also call removeAllEvents(), if needed.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
      Since:
        0.7

    - #### searchClientDB

          public Vector<Integer> searchClientDB(String search,
                                                boolean isUID)
                                         throws TS3ServerQueryException

      Searching for clients in the TS3 client database, useful for the getInfo() method to request more information.
      Parameters:
        `search` - The search string, you can use the % character as wildcard.
        `isUID` - If the search string is a unique id, set `true` here. If not, set `false`.
      Returns:
        A Vector containing Integer numbers with the client database id.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
      Since:
        2.0.2
      See Also:
        `getInfo(int, int)`

    - #### selectVirtualServer

          public void selectVirtualServer(int serverID)
                                   throws TS3ServerQueryException

      Select a virtual server to work with.
      Parameters:
        `serverID` - A virtual server id
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.

    - #### selectVirtualServer

          public void selectVirtualServer(int server,
                                          boolean selectPort)
                                   throws TS3ServerQueryException

      Select a virtual server to work with. This method allows to select the virtual server by id or port.
      Parameters:
        `server` - A virtual server id or port
        `selectPort` - `true` if `server` is the virtual server port, `false` if `server` is the virtual server id.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.
      Since:
        0.9

    - #### selectVirtualServer

          public void selectVirtualServer(int server,
                                          boolean selectPort,
                                          boolean virtual)
                                   throws TS3ServerQueryException

      Select a virtual server to work with. This method allows to select the virtual server by id or port. If the virtual server is offline, you can select the server in virtual mode.
      Parameters:
        `server` - A virtual server id or port
        `selectPort` - `true` if `server` is the virtual server port, `false` if `server` is the virtual server id.
        `virtual` - `true` if you want to select the virtual server in virtual mode (use this if the server is offline).
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.
      Since:
        1.0.10

    - #### sendTextMessage

          public void sendTextMessage(int targetID,
                                      int targetMode,
                                      String msg)
                               throws TS3ServerQueryException

      Sends a text message to a client / channel / virtual server / global (all virtual servers).
      Notice:
      If you use a channel or virtual server id, which is not currently used by this connection, sendTextMessage() work as follow:
      Switch to the channel or virtual server, sends the text message and switch back to old channel or virtual server.
      If you want to send more messages to this channel or virtual server, just use selectVirtualServer() or moveClient() first.
      Parameters:
        `targetID` - The client, channel or virtual server id. Use any number for a global message.
        `targetMode` - A text message target mode constant
        `msg` - The message to be send
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.
        `IllegalArgumentException` - If no message or an invalid targetMode given.
      See Also:
        `TEXTMESSAGE_TARGET_CLIENT`, `TEXTMESSAGE_TARGET_CHANNEL`, `TEXTMESSAGE_TARGET_VIRTUALSERVER`, `TEXTMESSAGE_TARGET_GLOBAL`, `moveClient(int, int, String)`, `selectVirtualServer(int)`

    - #### sendTextMessage

          public void sendTextMessage(int targetID,
                                      int targetMode,
                                      String msg,
                                      String channelPassword)
                               throws TS3ServerQueryException

      Sends a text message to a client / channel / virtual server / global (all virtual servers).
      Notice:
      If you use a channel or virtual server id, which is not currently used by this connection, sendTextMessage() work as follow:
      Switch to the channel or virtual server, sends the text message and switch back to old channel or virtual server.
      If you want to send more messages to this channel or virtual server, just use selectVirtualServer() or moveClient() first.
      Parameters:
        `targetID` - The client, channel or virtual server id. Use any number for a global message.
        `targetMode` - A text message target mode constant
        `msg` - The message to be send
        `channelPassword` - Channel password, is only needed for a text message to channel. Use `null` if channel has no password or not a channel text message.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.
        `IllegalArgumentException` - If no message or an invalid targetMode given.
      Since:
        0.6
      See Also:
        `TEXTMESSAGE_TARGET_CLIENT`, `TEXTMESSAGE_TARGET_CHANNEL`, `TEXTMESSAGE_TARGET_VIRTUALSERVER`, `TEXTMESSAGE_TARGET_GLOBAL`, `moveClient(int, int, String)`, `selectVirtualServer(int)`

    - #### setDisplayName

          public void setDisplayName(String displayName)
                              throws TS3ServerQueryException

      Change the display name on the Teamspeak 3 server of this query connection. This name will be displayed on many actions like kickClient(), moveClient(), pokeClient() and sendTextMessage().
      Parameters:
        `displayName` - A String with the new display name of this connection.
      Throws:
        `TS3ServerQueryException` - If the TS3 server is returning an error code/message.
        `IllegalStateException` - If not connected to a TS3 server.
        `IllegalArgumentException` - If displayName is `null` or shorter than 3 characters.
      Since:
        0.8

    - #### setTeamspeakActionListener

          public void setTeamspeakActionListener(TeamspeakActionListener listenerClass)

      Set a class that should receive the Teamspeak events. This class must implement the TeamspeakActionListener interface.
      Parameters:
        `listenerClass` - - A class that implements the TeamspeakActionListener interface.
      Since:
        0.7
      See Also:
        `TeamspeakActionListener`