Skip to content

ServerInfoHelper ​

com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper

Since1.6.5

A server-list entry containing its configured name and address and status information from a server ping. Scripts can obtain one with FClient.ping(java.lang.String),
which looks up a server without joining it. Before a ping, protocol defaults to the client's protocol and ping is zero before a ping; the player sample starts empty.

js
const info = Client.ping("mc.hypixel.net");  
Chat.log(`${info.getName()} at ${info.getAddress()}`);  
Chat.log(`${info.getLabel()} -- ${info.getPlayerCountLabel()}`);  
Chat.log(`version ${info.getVersion()}, protocol ${info.getProtocolVersion()}, ping ${info.getPing()}ms`);  

// the icon the client downloaded for this entry, if it got one
const icon = info.getIcon();  
if (icon !== null) {
  Chat.log(`icon is ${icon.length} bytes`);  
}

Constructors ​

new ServerInfoHelper ​

new ServerInfoHelper(ServerData base)#
Wraps the supplied server-list data without performing a ping or lookup.

Parameters:

  • base: raw server data to wrap

Methods ​

getAddress ​

getAddress(): StringSince1.6.5#
The configured server address.
Returns: the entry's address.

getIcon ​

getIcon(): byte[]Since1.6.5#
The server-list icon bytes, or null if no icon is stored.
Returns: the downloaded icon bytes, or null if there is no icon.

getLabel ​

getLabel(): TextHelperSince1.6.5#
The server's description (MOTD) returned by the last ping.
Returns: the server's description, as text.

getName ​

getName(): StringSince1.6.5#
The configured server-list name; this is not the name reported by the server.
Returns: the entry's name.

getNbt ​

The server-list compound written by the game, containing the name, address, optional base64 icon, and resource-pack setting.
Returns: the entry as it is written to the server list file.

getPing ​

getPing(): longSince1.6.5#
The client's measured duration of the last ping, in milliseconds; zero before a ping.
Returns: the measured ping in milliseconds.

getPlayerCountLabel ​

getPlayerCountLabel(): TextHelperSince1.6.5#
The player-count status from the last ping; if no player section is supplied, the client sets a translated placeholder.
Returns: the player count line, as text.

getPlayerListSummary ​

getPlayerListSummary(): List<TextHelper>Since1.6.5#
The sample of player names supplied by the server. An empty list does not establish that no players are online; entries retain the text and formatting supplied by the server.
Returns: the sample of online names the server sent, as a list of text.

getProtocolVersion ​

getProtocolVersion(): intSince1.6.5#
The protocol version reported by the last ping, or 0 if the server is too old to report a version. Before a ping, this defaults to the running client's protocol version.
Returns: the protocol version recorded for this entry.

getVersion ​

getVersion(): TextHelperSince1.6.5#
The game version reported by the last ping, or a translated placeholder if the server is too old to report a version.
Returns: the reported version, as text.

isLocal ​

isLocal(): booleanSince1.6.5#
Whether this entry is a LAN entry.
Returns: true if this entry is a local network entry.

isOnline ​

isOnline(): booleanSince1.6.5#
Whether this entry is not a LAN entry. Realm and ordinary server entries both return true.
Returns: true if this entry is not a local network entry.

resourcePackPolicy ​

resourcePackPolicy(): StringSince1.6.5#
The translation key for this entry's resource-pack setting (enabled, disabled, or prompt).
Returns: the translation key for this entry's resource pack setting.

toString ​

toString(): String#
Returns a diagnostic representation containing this entry's NBT representation.
Returns: diagnostic representation of the wrapped server entry