MyMCLib Library Documentation

Java Library for My-MC.Link API

Home

Overview

The MyMCLib library provides a convenient way to interact with the My-MC.Link API for managing Minecraft servers. It includes methods for performing various actions such as retrieving server information, managing server settings, controlling gameplay, and interacting with players.

Installation

To use the MyMCLib library in your project, install it via Maven:

<dependency>
    <groupId>io.github.mrmasrozytlive</groupId>
    <artifactId>mymc-java-lib</artifactId>
    <version>1.2.0</version>
</dependency>

or via Gradle:

implementation group: 'io.github.mrmasrozytlive', name: 'mymc-java-lib', version: '1.2.0'

For other ways, visit:
https://central.sonatype.com/artifact/io.github.mrmasrozytlive/mymc-java-lib.

Usage

First, import the library into your project:

import net.mitask.MyMCLib;

Then, create an instance of MyMCLib by providing your API token:

MyMCLib myMcLink = new MyMCLib("API_KEY_HERE");

Example Usage

import net.mitask.MyMCLib;

public class YourClass {
  public void yourMethod() {
    MyMCLib myMcLink = new MyMCLib("API_KEY_HERE");
    
    // Will print information about API key expiration date
    System.out.println(myMcLink.getTime().toString()); 
  }
}

Output:

{
  success: true,
  keyexpireString: 'Tue Apr 15 2025 06:14:59 GMT-0400 (Eastern Daylight Time)',
  expireDate: '2025-04-15T10:14:59.000Z',
  expireEpoch: 1744712099000
}

Code Examples

Getting Server Time

JSONObject timeData = myMcLink.getTime();
System.out.println(timeData.toString());

Getting Server Statistics

JSONObject statsData = myMcLink.getStats();
System.out.println(statsData.toString());

Getting Server Logs

JSONObject logData = myMcLink.getLog();
System.out.println(logData.toString());

Starting the Minecraft Server

JSONObject startResult = myMcLink.startServer();
System.out.println(startResult.toString());

Stopping the Minecraft Server

JSONObject stopResult = myMcLink.stopServer();
System.out.println(stopResult.toString());

Restarting the Minecraft Server

JSONObject restartResult = myMcLink.restartServer();
System.out.println(restartResult.toString());

Getting Connection Hash

JSONObject hashData = myMcLink.getConnectionHash();
System.out.println(hashData.toString());

Getting SFTP Connection Hash

JSONObject sftpHashData = myMcLink.getConnectionHashSFTP();
System.out.println(sftpHashData.toString());

Getting Online Players

JSONObject playersData = myMcLink.getOnlinePlayers();
System.out.println(playersData.toString());

Getting Server's Website URL

JSONObject websiteURL = myMcLink.getWebsiteURL();
System.out.println(websiteURL.toString());

Getting Server's Map URL

JSONObject mapURL = myMcLink.getMapURL();
System.out.println(mapURL.toString());

Banning a Player

JSONObject banResult = myMcLink.postBan("username");
System.out.println(banResult.toString());

Unbanning a Player

JSONObject unbanResult = myMcLink.postUnban("username");
System.out.println(unbanResult.toString());

Sending a Message to All Players

JSONObject sayResult = myMcLink.postSay("Hello, everyone!");
System.out.println(sayResult.toString());

Sending a Private Message to a Player

JSONObject tellResult = myMcLink.postTell("username", "Hey, how are you?");
System.out.println(tellResult.toString());

Executing a Command in Server Console

JSONObject consoleResult = myMcLink.postConsole("say Hello, world!");
System.out.println(consoleResult.toString());

Giving an Item to a Player

JSONObject giveResult = myMcLink.postGive("username", "item", 1);
System.out.println(giveResult.toString());

Installing a Mod by ID

String modID = "exampleMod123";
JSONObject installResult = myMcLink.installMod(modID);
System.out.println(installResult.toString());

Uninstalling a Mod by ID

String modID = "exampleMod123";
JSONObject uninstallResult = myMcLink.uninstallMod(modID);
System.out.println(uninstallResult.toString());

Retrieving a List of Installed Mods

JSONObject installedMods = myMcLink.getInstalledMods();
System.out.println(installedMods.toString());

API Reference

MyMCLib Class

Constructor

public MyMCLib(String token)

Creates an instance of the MyMCLib class with the provided API token.

Methods

ApiUtils Class

Methods

Explore More

Ready to automate your server?
Join our community, dive into our resources, and start building with the My-MC.Link API and MyMCLib.