Class Documentation: JavaStatus
Last updated
Last updated
The JavaStatus
class is a Java utility for fetching and retrieving the status of a Minecraft Java Edition server using the . It provides methods to access various server details such as online status, player count, version, MOTD, mods, plugins, and more.
JavaStatus(String address)
Fetches the status of a Java server with default settings (query enabled and a timeout of 5 seconds).
Parameters:
address
(String): The server address (e.g., "example.com"
or "192.168.1.1:25565"
).
Throws:
IllegalArgumentException
: If the server address is null or empty.
RuntimeException
: If an error occurs during the API request.
JavaStatus(String address, boolean query, double timeout)
Fetches the status of a Java server with custom query and timeout settings.
Parameters:
address
(String): The server address.
query
(boolean, optional): Whether to query the server for additional details. Defaults to true
if not provided.
timeout
(double, optional): The timeout in seconds for the API request. Defaults to 5.0
if not provided.
Throws:
IllegalArgumentException
: If the server address is null or empty.
RuntimeException
: If an error occurs during the API request.
isOnline()
Checks if the server is online.
Returns:
boolean
: true
if the server is online, false
otherwise.
getHost()
Gets the server's host address.
Returns:
String
: The server's host address.
getPort()
Gets the server's port.
Returns:
int
: The server's port.
getIpAddress()
Gets the server's IP address.
Returns:
String
: The server's IP address, or null
if not available.
isEulaBlocked()
Checks if the server is blocked due to EULA violations.
Returns:
boolean
: true
if the server is EULA blocked, false
otherwise.
getRetrievedAt()
Gets the timestamp when the data was retrieved.
Returns:
long
: The timestamp in milliseconds.
getExpiresAt()
Gets the timestamp when the data expires.
Returns:
long
: The timestamp in milliseconds.
getSrvRecord()
Gets the SRV record of the server.
Returns:
String
: The SRV record, or null
if not available.
getVersionNameRaw()
Gets the raw version name of the server.
Returns:
String
: The raw version name, or null
if the server is offline.
getVersionNameClean()
Gets the clean version name of the server.
Returns:
String
: The clean version name, or null
if the server is offline.
getVersionNameHtml()
Gets the HTML version name of the server.
Returns:
String
: The HTML version name, or null
if the server is offline.
getVersionProtocol()
Gets the protocol version of the server.
Returns:
int
: The protocol version, or -1
if the server is offline.
getPlayersOnline()
Gets the number of players currently online.
Returns:
int
: The number of players online, or 0
if the server is offline.
getMaxPlayers()
Gets the maximum number of players allowed on the server.
Returns:
int
: The maximum number of players, or 0
if the server is offline.
getPlayersList()
Gets the list of players currently online.
Returns:
JSONArray
: A JSONArray of players, or null
if the server is offline or no players are online.
getPlayerNames()
Gets the list of player names currently online.
Returns:
ArrayList<String>
: A list of player names, or an empty list if the server is offline or no players are online.
getPlayerNamesRaw()
Gets the list of player names with formatting.
Returns:
ArrayList<String>
: A list of player names with formatting, or an empty list if the server is offline or no players are online.
getMotdRaw()
Gets the raw MOTD (Message of the Day) of the server.
Returns:
String
: The raw MOTD, or null
if the server is offline.
getMotdClean()
Gets the clean MOTD (Message of the Day) of the server.
Returns:
String
: The clean MOTD, or null
if the server is offline.
getMotdHtml()
Gets the HTML MOTD (Message of the Day) of the server.
Returns:
String
: The HTML MOTD, or null
if the server is offline.
getIcon()
Gets the server's icon.
Returns:
String
: The server's icon as a Base64 string, or null
if the server is offline or no icon is available.
getMods()
Gets the list of mods installed on the server.
Returns:
JSONArray
: A JSONArray of mods, or null
if the server is offline or no mods are installed.
getModNames()
Gets the list of mod names installed on the server.
Returns:
ArrayList<String>
: A list of mod names, or an empty list if the server is offline or no mods are installed.
getModsWithVersions()
Gets the list of mods with their versions.
Returns:
HashMap<String, String>
: A map of mod names to their versions, or an empty map if the server is offline or no mods are installed.
getSoftware()
Gets the software running on the server.
Returns:
String
: The server software, or null
if the server is offline or no software information is available.
getPlugins()
Gets the list of plugins installed on the server.
Returns:
JSONArray
: A JSONArray of plugins, or null
if the server is offline or no plugins are installed.
getPluginNames()
Gets the list of plugin names installed on the server.
Returns:
ArrayList<String>
: A list of plugin names, or an empty list if the server is offline or no plugins are installed.
getPluginsWithVersions()
Gets the list of plugins with their versions.
Returns:
HashMap<String, String>
: A map of plugin names to their versions, or an empty map if the server is offline or no plugins are installed.
⚠️ Alert: The
JSONArray
objects returned by the API contain raw JSON data.
Ensure the server address is valid and reachable.
The API request may fail if the server is offline or the address is incorrect.
The query
and timeout
parameters in the constructor are optional and default to true
and 5.0
seconds, respectively.