diff --git a/wiki/mymc-java/index.html b/wiki/mymc-java/index.html index 240c302..d6a7026 100644 --- a/wiki/mymc-java/index.html +++ b/wiki/mymc-java/index.html @@ -111,7 +111,7 @@
JavaScript Library for My-MC.Link API
+Java Library for My-MC.Link API
- To use the MyMCLib
library in your project, install it via npm:
+ To use the MyMCLib
library in your project, install it via Maven:
npm install mymc-lib
+ <dependency>
+ <groupId>io.github.mrmasrozytlive</groupId>
+ <artifactId>mymc-java-lib</artifactId>
+ <version>1.2.0</version>
+</dependency>
- Proper Importing: To make use of this module, you'll need to either utilize the .mjs
extension or incorporate "type": "module"
in your package.json
file. This requirement exists because modern JavaScript (ES6 and later) introduced the concept of modules, which allows for more organized and scalable code by encapsulating functionality within separate files.
+ 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.
import MyMCLib from "mymc-lib";
+ import net.mitask.MyMCLib;
Then, create an instance of MyMCLib
by providing your API token:
const MyMC = new MyMCLib("your-api-token");
+ MyMCLib myMcLink = new MyMCLib("API_KEY_HERE");
import MyMCLib from "mymc-lib";
+ import net.mitask.MyMCLib;
-// Instantiate MyMCLib with your API token
-const MyMC = new MyMCLib("your-api-token");
-
-// Will print information about API key expiration date
-let keyData = await MyMC.getTime();
-
-console.log(keyData);
+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:
root@test:/home# node test
-{
+ {
success: true,
keyexpireString: 'Tue Apr 15 2025 06:14:59 GMT-0400 (Eastern Daylight Time)',
expireDate: '2025-04-15T10:14:59.000Z',
@@ -229,8 +240,8 @@ console.log(keyData);
Getting Server Time
- const timeData = await MyMC.getTime();
-console.log(timeData);
+ JSONObject timeData = myMcLink.getTime();
+System.out.println(timeData.toString());
@@ -239,8 +250,8 @@ console.log(timeData);
const statsData = await MyMC.getStats();
-console.log(statsData);
+ JSONObject statsData = myMcLink.getStats();
+System.out.println(statsData.toString());
const logData = await MyMC.getLog();
-console.log(logData);
+ JSONObject logData = myMcLink.getLog();
+System.out.println(logData.toString());
const startResult = await MyMC.startServer();
-console.log(startResult);
+ JSONObject startResult = myMcLink.startServer();
+System.out.println(startResult.toString());
const stopResult = await MyMC.stopServer();
-console.log(stopResult);
+ JSONObject stopResult = myMcLink.stopServer();
+System.out.println(stopResult.toString());
const restartResult = await MyMC.restartServer();
-console.log(restartResult);
+ JSONObject restartResult = myMcLink.restartServer();
+System.out.println(restartResult.toString());
const customLinkResult = await MyMC.createMyLink();
-console.log(customLinkResult);
+ JSONObject customLinkResult = myMcLink.createMyLink();
+System.out.println(customLinkResult.toString());
const deleteLinkResult = await MyMC.deleteMyLink();
-console.log(deleteLinkResult);
+ JSONObject deleteLinkResult = myMcLink.deleteMyLink();
+System.out.println(deleteLinkResult.toString());
const sftpLinkResult = await MyMC.createLinkSFTP();
-console.log(sftpLinkResult);
+ JSONObject sftpLinkResult = myMcLink.createLinkSFTP();
+System.out.println(sftpLinkResult.toString());
const deleteSftpLinkResult = await MyMC.deleteLinkSFTP();
-console.log(deleteSftpLinkResult);
+ JSONObject deleteSftpLinkResult = myMcLink.deleteLinkSFTP();
+System.out.println(deleteSftpLinkResult.toString());
const hashData = await MyMC.getConnectionHash();
-console.log(hashData);
+ JSONObject hashData = myMcLink.getConnectionHash();
+System.out.println(hashData.toString());
const sftpHashData = await MyMC.getConnectionHashSFTP();
-console.log(sftpHashData);
+ JSONObject sftpHashData = myMcLink.getConnectionHashSFTP();
+System.out.println(sftpHashData.toString());
const playersData = await MyMC.getOnlinePlayers();
-console.log(playersData);
+ JSONObject playersData = myMcLink.getOnlinePlayers();
+System.out.println(playersData.toString());
const websiteURL = await MyMC.getWebsiteURL();
-console.log(websiteURL);
+ JSONObject websiteURL = myMcLink.getWebsiteURL();
+System.out.println(websiteURL.toString());
const mapURL = await MyMC.getMapURL();
-console.log(mapURL);
+ JSONObject mapURL = myMcLink.getMapURL();
+System.out.println(mapURL.toString());
const banResult = await MyMC.postBan("username");
-console.log(banResult);
+ JSONObject banResult = myMcLink.postBan("username");
+System.out.println(banResult.toString());
const unbanResult = await MyMC.postUnban("username");
-console.log(unbanResult);
+ JSONObject unbanResult = myMcLink.postUnban("username");
+System.out.println(unbanResult.toString());
const sayResult = await MyMC.postSay("Hello, everyone!");
-console.log(sayResult);
+ JSONObject sayResult = myMcLink.postSay("Hello, everyone!");
+System.out.println(sayResult.toString());
const tellResult = await MyMC.postTell("username", "Hey, how are you?");
-console.log(tellResult);
+ JSONObject tellResult = myMcLink.postTell("username", "Hey, how are you?");
+System.out.println(tellResult.toString());
const consoleResult = await MyMC.postConsole("say Hello, world!");
-console.log(consoleResult);
+ JSONObject consoleResult = myMcLink.postConsole("say Hello, world!");
+System.out.println(consoleResult.toString());
const giveResult = await MyMC.postGive("username", "item", 1);
-console.log(giveResult);
+ JSONObject giveResult = myMcLink.postGive("username", "item", 1);
+System.out.println(giveResult.toString());
const modID = "exampleMod123";
-const installResult = await MyMC.installMod(modID);
-console.log(installResult);
+ String modID = "exampleMod123";
+JSONObject installResult = myMcLink.installMod(modID);
+System.out.println(installResult.toString());
const modID = "exampleMod123";
-const uninstallResult = await MyMC.uninstallMod(modID);
-console.log(uninstallResult);
+ String modID = "exampleMod123";
+JSONObject uninstallResult = myMcLink.uninstallMod(modID);
+System.out.println(uninstallResult.toString());
const installedMods = await MyMC.getInstalledMods();
-console.log(installedMods);
+ JSONObject installedMods = myMcLink.getInstalledMods();
+System.out.println(installedMods.toString());
constructor(token: string)
+ public MyMCLib(String token)
Creates an instance of the MyMCLib
class with the provided API token.
getTime(): Promise
- Retrieves the current server time.getStats(): Promise
- Retrieves server statistics.getLog(): Promise
- Retrieves server logs.startServer(): Promise
- Starts the Minecraft server.stopServer(): Promise
- Stops the Minecraft server.restartServer(): Promise
- Restarts the Minecraft server.createMyLink(): Promise
- Creates a custom link.deleteMyLink(): Promise
- Deletes a custom link.createLinkSFTP(): Promise
- Creates an SFTP link.deleteLinkSFTP(): Promise
- Deletes an SFTP link.getConnectionHash(): Promise
- Retrieves a connection hash.getConnectionHashSFTP(): Promise
- Retrieves an SFTP connection hash.getOnlinePlayers(): Promise
- Retrieves a list of online players.getWebsiteURL(): Promise
- Retrieves the server's website URL.getMapURL(): Promise
- Retrieves the server's map URL.postBan(username: string): Promise
- Bans a player by username.postUnban(username: string): Promise
- Unbans a player by username.postSay(message: string): Promise
- Sends a message to all players.postTell(username: string, message: string): Promise
- Sends a private message to a player.postConsole(command: string): Promise
- Executes a command in the server console.postGive(username: string, item: string, amount: number): Promise
- Gives an item to a player.installMod(modID: string): Promise
- Installs a mod by ID.uninstallMod(modID: string): Promise
- Uninstalls a mod by ID.getInstalledMods(): Promise
- Retrieves a list of installed mods.JSONObject getTime()
- Retrieves the current server time.JSONObject getStats()
- Retrieves server statistics.JSONObject getLog()
- Retrieves server logs.JSONObject startServer()
- Starts the Minecraft server.JSONObject stopServer()
- Stops the Minecraft server.JSONObject restartServer()
- Restarts the Minecraft server.JSONObject createMyLink()
- Creates a custom link.JSONObject deleteMyLink()
- Deletes a custom link.JSONObject createLinkSFTP()
- Creates an SFTP link.JSONObject deleteLinkSFTP()
- Deletes an SFTP link.JSONObject getConnectionHash()
- Retrieves a connection hash.JSONObject getConnectionHashSFTP()
- Retrieves an SFTP connection hash.JSONObject getOnlinePlayers()
- Retrieves a list of online players.JSONObject getWebsiteURL()
- Retrieves the server's website URL.JSONObject getMapURL()
- Retrieves the server's map URL.JSONObject postBan(String username)
- Bans a player by username.JSONObject postUnban(String username)
- Unbans a player by username.JSONObject postSay(String message)
- Sends a message to all players.JSONObject postTell(String username, String message)
- Sends a private message to a player.JSONObject postConsole(String command)
- Executes a command in the server console.JSONObject postGive(String username, String item, int amount)
- Gives an item to a player.JSONObject installMod(String modID)
- Installs a mod by ID.JSONObject uninstallMod(String modID)
- Uninstalls a mod by ID.JSONObject getInstalledMods()
- Retrieves a list of installed mods.getRequest(endpoint: ApiEndpoint, token: string): Promise
- Makes a GET request to the specified API endpoint.deleteRequest(endpoint: ApiEndpoint, token: string): Promise
- Makes a DELETE request to the specified API endpoint.postRequest(endpoint: ApiEndpoint, token: string, data: {}): Promise
- Makes a POST request to the specified API endpoint with the provided data.JSONObject getRequest(ApiEndpoint endpoint, String token)
- Makes a GET request to the specified API endpoint.JSONObject deleteRequest(ApiEndpoint endpoint, String token)
- Makes a DELETE request to the specified API endpoint.JSONObject postRequest(ApiEndpoint endpoint, String token, JSONObject data)
- Makes a POST request to the specified API endpoint with the provided data.