ServerInfoHelper
com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper
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
getIcon
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
The server's description (MOTD) returned by the last ping.
Returns: the server's description, as text.
getName
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
The client's measured duration of the last ping, in milliseconds; zero before a ping.
Returns: the measured ping in milliseconds.
getPlayerCountLabel
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
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
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
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
Whether this entry is a LAN entry.
Returns:
true if this entry is a local network entry.isOnline
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.