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 Icon

Methods

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 a BufferedImage, or null if an error occurs.


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 to 5.0 if not provided.

Returns:

  • BufferedImage: The server icon as a BufferedImage, or null if an error occurs.


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.


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 to 5.0 if not provided.

Returns:

  • String: The URL of the server icon.


Usage Example

Example 1: Fetching the Server Icon as a BufferedImage

Example 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 timeout parameter in the methods is optional and defaults to 5.0 seconds if not provided.

Last updated