# ServerInfoHelper

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

**Since:** 1.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)](../../../../../../../../libraries/com/jsmacrosce/jsmacros/client/api/library/impl/FClient.md#com.jsmacrosce.jsmacros.client.api.library.impl.FClient_ping-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 {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_constructor-ServerData-}

```js
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 {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_getAddress-}

```js
getAddress(): String
```

The configured server address.

**Returns:** the entry's address.

**Since:** 1.6.5

### getIcon {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_getIcon-}

```js
getIcon(): byte[]
```

The server-list icon bytes, or `null` if no icon is stored.

**Returns:** the downloaded icon bytes, or `null` if there is no icon.

**Since:** 1.6.5

### getLabel {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_getLabel-}

```js
getLabel(): TextHelper
```

The server's description (MOTD) returned by the last ping.

**Returns:** the server's description, as text.

**Since:** 1.6.5

### getName {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_getName-}

```js
getName(): String
```

The configured server-list name; this is not the name reported by the server.

**Returns:** the entry's name.

**Since:** 1.6.5

### getNbt {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_getNbt-}

```js
getNbt(): NBTElementHelper.NBTCompoundHelper
```

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.

**Since:** 1.6.5

### getPing {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_getPing-}

```js
getPing(): long
```

The client's measured duration of the last ping, in milliseconds; zero before a ping.

**Returns:** the measured ping in milliseconds.

**Since:** 1.6.5

### getPlayerCountLabel {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_getPlayerCountLabel-}

```js
getPlayerCountLabel(): TextHelper
```

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.

**Since:** 1.6.5

### getPlayerListSummary {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_getPlayerListSummary-}

```js
getPlayerListSummary(): List<TextHelper>
```

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.

**Since:** 1.6.5

### getProtocolVersion {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_getProtocolVersion-}

```js
getProtocolVersion(): int
```

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.

**Since:** 1.6.5

### getVersion {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_getVersion-}

```js
getVersion(): TextHelper
```

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.

**Since:** 1.6.5

### isLocal {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_isLocal-}

```js
isLocal(): boolean
```

Whether this entry is a LAN entry.

**Returns:** `true` if this entry is a local network entry.

**Since:** 1.6.5

### isOnline {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_isOnline-}

```js
isOnline(): boolean
```

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.

**Since:** 1.6.5

### resourcePackPolicy {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_resourcePackPolicy-}

```js
resourcePackPolicy(): String
```

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.

**Since:** 1.6.5

### toString {#com.jsmacrosce.jsmacros.client.api.helper.world.ServerInfoHelper_toString-}

```js
toString(): String
```

Returns a diagnostic representation containing this entry's NBT representation.

**Returns:** diagnostic representation of the wrapped server entry
