mjsrv
v1.0.1
Published
JavaScript library to initalize Minecraft Java servers
Readme
mjsrv
Minecraft JS server
A JavaScript library for creating and managing Minecraft Java servers.
Installation
npm install mjsrvQuick Start
import { MinecraftServer } from "mjsrv";
MinecraftServer.create({
version: "1.21.6",
motd: "Welcome to my server!",
id: "my-server",
});
setTimeout(() => {
MinecraftServer.serve("my-server");
}, 5000);Documentation
MinecraftServer
The MinecraftServer class provides methods for creating and managing Minecraft servers.
MinecraftServer.create(options)
Creates a new Minecraft server.
Options:
version(string): The version of the Minecraft server to create. Defaults to the latest version.motd(string): The message of the day for the server. Required.id(string): The ID of the server. Defaults tominecraft-server-<random_6_figure_uuid>.maxPlayers(number): The maximum number of players that can join the server. Defaults to20.hardcore(boolean): Whether to enable hardcore mode. Defaults tofalse.
Example:
import { MinecraftServer } from "mjsrv";
MinecraftServer.create({
version: "1.21.6",
motd: "Welcome to my hardcore server!",
id: "my-hardcore-server",
hardcore: true,
});MinecraftServer.serve(id, port, gui)
Starts a Minecraft server.
id(string): The ID of the server to start.port(number): The port to start the server on. Defaults to25565.gui(boolean): Whether to enable the MinecraftServer GUI. Defaults tofalse. To specify, first specifyport.
MinecraftServer.start(id, port, gui)
Starts a Minecraft server.
id(string): The ID of the server to start.port(number): The port to start the server on. Defaults to25565.gui(boolean): Whether to enable the MinecraftServer GUI. Defaults tofalse. To specify, first specifyport.
MinecraftServer.stop(id)
Stops a Minecraft server.
id(string): The ID of the server to stop.
MinecraftServer.restart(id)
Restarts a Minecraft server.
id(string): The ID of the server to restart.
MinecraftServer.delete(id)
Deletes a Minecraft server.
id(string): The ID of the server to delete.
MinecraftServer.toContainer(id, options)
Converts a Minecraft server to a Docker container.
id(string): The ID of the server to convert.options(object):image(string): The name of the Docker image to create. Defaults to the server ID.
Example:
import { MinecraftServer } from "mjsrv";
MinecraftServer.toContainer("my-server", { image: "my-minecraft-image" });Containers
The Containers class provides methods for managing Docker containers for Minecraft servers.
Containers.start(id, image, port)
Starts a Docker container for a Minecraft server.
id(string): The ID of the server.image(string): The name of the Docker image to use.port(number): The port to start the server on. Defaults to25565.
Containers.stop(id)
Stops a Docker container for a Minecraft server.
id(string): The ID of the server.
Containers.restart(id)
Restarts a Docker container for a Minecraft server.
id(string): The ID of the server.
Containers.delete(id)
Deletes a Docker container for a Minecraft server.
id(string): The ID of the server.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
