⚒️
MCStatusIO
  • Overview
  • Class Documentation: JavaStatus
  • Class Documentation: BedrockStatus
  • Class Documentation: Icon
  • License
Powered by GitBook
On this page
  • Key Features
  • Table of Contents
  • Installation
  • Usage
  • License
  • Why Use This Library?

Overview

NextClass Documentation: JavaStatus

Last updated 4 months ago

The Java MCStatus library is a Java-based wrapper for the . It is a fork of the original node-mcstatus npm package, ported to Java to provide similar functionality for Java developers. This library allows you to easily retrieve the status of Minecraft Java and Bedrock Edition servers, including details such as player count, server version, MOTD, and more.


Key Features

  • Java and Bedrock Server Support: Retrieve status information for both Minecraft Java and Bedrock Edition servers.

  • Simple and Intuitive API: Designed to be easy to use, with methods for fetching server status, player lists, MOTD, and more.

  • Customizable Timeout: Set a custom timeout for API requests to handle slow or unresponsive servers.

  • Error Handling: Provides robust error handling for invalid server addresses or failed API requests.

  • Icon Retrieval: Fetch server icons as BufferedImage objects or URLs.


Table of Contents


Installation


Usage

Java Status

Retrieve the status of a Minecraft Java Edition server.

import io.github.undeffineddev.mcstatusio.java.JavaStatus;

public class Main {
    public static void main(String[] args) {
        try {
            JavaStatus status = new JavaStatus("demo.mcstatus.io", true, 5.0);

            System.out.println("Online: " + status.isOnline());
            System.out.println("Players Online: " + status.getPlayersOnline());
            System.out.println("Version: " + status.getVersionNameClean());
            System.out.println("MOTD: " + status.getMotdClean());
        } catch (RuntimeException e) {
            System.err.println("Error: " + e.getMessage());
        }
    }
}

Bedrock Status

Retrieve the status of a Minecraft Bedrock Edition server.

import io.github.undeffineddev.mcstatusio.bedrock.BedrockStatus;

public class Main {
    public static void main(String[] args) {
        try {
            BedrockStatus status = new BedrockStatus("demo.mcstatus.io", 19132);

            System.out.println("Online: " + status.isOnline());
            System.out.println("Players Online: " + status.getPlayersOnline());
            System.out.println("Version: " + status.getVersionName());
            System.out.println("MOTD: " + status.getMotdClean());
        } catch (RuntimeException e) {
            System.err.println("Error: " + e.getMessage());
        }
    }
}

Server Icon

Retrieve the server icon as a BufferedImage or URL.

import io.github.undeffineddev.mcstatusio.java.icon.Icon;
import java.awt.image.BufferedImage;

public class Main {
    public static void main(String[] args) {
        // Fetch the server icon as a BufferedImage
        BufferedImage icon = Icon.getServerIcon("demo.mcstatus.io");

        if (icon != null) {
            System.out.println("Server icon successfully retrieved!");
        } else {
            System.err.println("Failed to retrieve the server icon.");
        }

        // Fetch the server icon URL
        String iconUrl = Icon.getServerIconAsLink("demo.mcstatus.io");
        System.out.println("Server icon URL: " + iconUrl);
    }
}

License


Why Use This Library?

  • Familiar API: If you're coming from the Node.js or Python versions of mcstatus, you'll find the API very similar.

  • Lightweight: Designed to be minimal and easy to integrate into your Java projects.

  • Cross-Platform: Works on any platform that supports Java.


This Java MCStatus library is a powerful tool for developers who need to interact with Minecraft servers programmatically. Whether you're building a server monitoring tool, a server list, or just experimenting, this library has you covered! Let me know if you need further assistance.

To use the Java MCStatus library, include it as a dependency in your project. Download the library from Github repository,

This library is licensed under the MIT License. See the file for more details.

here
LICENSE
mcstatus.io API
License
Installation
Usage
Java Status
Bedrock Status
Server Icon
Icon Complete Example
Bedrock Complete Example
Java Complete Example