Class Documentation: Icon
The Icon class is a Java utility for retrieving the server icon of a Minecraft Java Edition server using the mcstatus.io API. It provides methods to fetch the server icon as a BufferedImage or as a URL.
Class Overview
Package
package io.github.undeffineddev.mcstatusio.java.icon;Class Declaration
public class IconMethods
getServerIcon(String address)
getServerIcon(String address)Retrieves the server icon as a BufferedImage with a default timeout of 5 seconds.
Parameters:
address(String): The server address (e.g.,"example.com"or"192.168.1.1:25565").
Returns:
BufferedImage: The server icon as aBufferedImage, ornullif an error occurs.
getServerIcon(String address, double timeout)
getServerIcon(String address, double timeout)Retrieves the server icon as a BufferedImage with a specified timeout.
Parameters:
address(String): The server address.timeout(double, optional): The timeout in seconds for the API request. Defaults to5.0if not provided.
Returns:
BufferedImage: The server icon as aBufferedImage, ornullif an error occurs.
getServerIconAsLink(String address)
getServerIconAsLink(String address)Retrieves the URL of the server icon with a default timeout of 5 seconds.
Parameters:
address(String): The server address.
Returns:
String: The URL of the server icon.
getServerIconAsLink(String address, double timeout)
getServerIconAsLink(String address, double timeout)Retrieves the URL of the server icon with a specified timeout.
Parameters:
address(String): The server address.timeout(double, optional): The timeout in seconds for the API request. Defaults to5.0if not provided.
Returns:
String: The URL of the server icon.
Usage Example
Example 1: Fetching the Server Icon as a BufferedImage
BufferedImageExample 2: Fetching the Server Icon URL
Example 3: Using a Custom Timeout
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 methods is optional and defaults to5.0seconds if not provided.
Last updated