Class Documentation: BedrockStatus
The BedrockStatus class is a Java utility for fetching and retrieving the status of a Minecraft Bedrock Edition server using the mcstatus.io API. It provides methods to access various server details such as online status, player count, version, MOTD, and more.
Class Overview
Package
package io.github.undeffineddev.mcstatusio.bedrock;Class Declaration
public class BedrockStatusConstructors
BedrockStatus(String address)
BedrockStatus(String address)Fetches the status of a Bedrock server with a default timeout of 5 seconds.
Parameters:
address(String): The server address (e.g.,"example.com"or"192.168.1.1:19132").
Throws:
IllegalArgumentException: If the server address is null or empty.RuntimeException: If an error occurs during the API request.
BedrockStatus(String address, double timeout)
BedrockStatus(String address, double timeout)Fetches the status of a Bedrock server with a custom timeout.
Parameters:
address(String): The server address.timeout(double, optional): The timeout in seconds for the API request. Defaults to5.0if not provided.
Throws:
IllegalArgumentException: If the server address is null or empty.RuntimeException: If an error occurs during the API request.
Methods
isOnline()
isOnline()Checks if the server is online.
Returns:
boolean:trueif the server is online,falseotherwise.
getHost()
getHost()Gets the server's host address.
Returns:
String: The server's host address.
getPort()
getPort()Gets the server's port.
Returns:
int: The server's port.
getIpAddress()
getIpAddress()Gets the server's IP address.
Returns:
String: The server's IP address, ornullif not available.
isEulaBlocked()
isEulaBlocked()Checks if the server is blocked due to EULA violations.
Returns:
boolean:trueif the server is EULA blocked,falseotherwise.
getRetrievedAt()
getRetrievedAt()Gets the timestamp when the data was retrieved.
Returns:
long: The timestamp in milliseconds.
getExpiresAt()
getExpiresAt()Gets the timestamp when the data expires.
Returns:
long: The timestamp in milliseconds.
getVersionName()
getVersionName()Gets the version name of the server.
Returns:
String: The version name, ornullif the server is offline.
getVersionProtocol()
getVersionProtocol()Gets the protocol version of the server.
Returns:
int: The protocol version, or-1if the server is offline.
getPlayersOnline()
getPlayersOnline()Gets the number of players currently online.
Returns:
int: The number of players online, or0if the server is offline.
getMaxPlayers()
getMaxPlayers()Gets the maximum number of players allowed on the server.
Returns:
int: The maximum number of players, or0if the server is offline.
getMotdRaw()
getMotdRaw()Gets the raw MOTD (Message of the Day) of the server.
Returns:
String: The raw MOTD, ornullif the server is offline.
getMotdClean()
getMotdClean()Gets the clean MOTD (Message of the Day) of the server.
Returns:
String: The clean MOTD, ornullif the server is offline.
getMotdHtml()
getMotdHtml()Gets the HTML MOTD (Message of the Day) of the server.
Returns:
String: The HTML MOTD, ornullif the server is offline.
getGamemode()
getGamemode()Gets the game mode of the server.
Returns:
String: The game mode, ornullif the server is offline.
getServerId()
getServerId()Gets the server ID.
Returns:
String: The server ID, ornullif the server is offline.
getEdition()
getEdition()Gets the edition of the server (e.g., "MCPE" or "MCEE").
Returns:
String: The server edition, ornullif the server is offline.
Usage Example
Notes
Ensure the server address is valid and reachable.
The API request may fail if the server is offline or the address is incorrect.
The
timeoutparameter in the constructor is optional and defaults to5.0seconds if not provided.
Last updated