Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

minecraft-wrap

PrismarineJS4.7kMIT1.6.0

Download and wrap the vanilla minecraft server in node.js

minecraft, download, wrap, node

readme

minecraft wrap

NPM version Build Status

Download and wrap the vanilla minecraft server and client in node.js.

Install

To install a downloadMinecraft and a runMinecraft command line programs, run:

npm install -g minecraft-wrap

Usage

downloadMinecraft 1.8.8 1.8.8.jar server
runMinecraft [<minecraft dir>] [<version>] [<username>] [<password>] [<stop>]

See examples

API

download(minecraftVersion,filename,done)

download the vanilla server of version minecraftVersion jar file at filename.

It checks with a md5 hash that the file downloaded is correct and it doesn't download it if the destination file is already the correct file.

downloadClient(minecraftVersion,filename,done)

download the vanilla client of version minecraftVersion jar file at filename.

downloadBedrockServer(os, version, outputPath, suffixVersion)

os: 'win' | 'linux' version: valid bedrock version (ie: '1.16.220') outputPath: name of folder to extract server to suffixVersion: the name of the outputFolder will be suffixed to the end of the folder name, ie: output to output1.16.220

download + unzip the bedrock server

new WrapServer(MC_SERVER_JAR,MC_SERVER_PATH[,OPTIONS])

initialize a wrapper with jar MC_SERVER_JAR, store mc server file at MC_SERVER_PATH

OPTIONS is an object containing the following optional properties:

  • minMem : the minimum memory allocated to the minecraft server, default to 512
  • maxMem : the maximum memory allocated to the minecraft server, default to 512
  • doneRegex : the regex to check for the server message announcing the server has started, default to new RegExp(/\[Server thread\/INFO\]: Done/)
  • noOverride : don't override config files
  • javaPath : specify path to a java executable to use, by default it's just java

WrapServer.startServer(propOverrides, done)

start the minecraft server with properties overrides propOverrides. Calls done when the server is started.

WrapServer.stopServer(done)

stop the minecraft server, calls done when the server is stopped.

WrapServer.deleteServerData(done)

delete the minecraft server data.

WrapServer.writeServer(line)

write line to the server.

"line" (line)

the Wrap instance emit that event when the server write a line

new WrapClient(clientPath,version)

create a client wrapper instance

  • using clientPath as minecraft directory (or the default os specific path if undefined)
  • with minecraft version version (or the version of the selected profile if undefined)

WrapClient.prepare()

prepare all the files requires for the minecraft client in the minecraft directory.

return a promise

WrapClient.auth(username,password)

authenticate the user using username and password. If these parameters are undefined, the selected user in the profile is used

return a promise

WrapClient.setAuthInfo(playerName,uuid,accessToken,userProperties)

set the authentication information directly without contacting the mojang servers. playerName, uuid, accessToken and userProperties need to be provided.

WrapClient.start()

start the client

return a promise that is resolved when the client is properly started

WrapClient.stop()

stop the client

return a promise that is resolved when the client is stopped

new LauncherDownload(mcPath,os="linux")

create a launcher downloader with mcPath as minecraft directory path

LauncherDownload.getWholeClient(version)

get the client jar, the assets, the libraries and extract the native libraries for the version version. return an object of arrays of the paths of the downloaded files

LauncherDownload.getVersionsList()

get and return a promise of the version list

LauncherDownload.getVersionInfos(version)

get and save the version infos and return a promise of it

LauncherDownload.getAssetIndex(version)

get and save the asset index and return a promise of it

LauncherDownload.getAllAssets(version)

get all the assets, save them and return a promise of an array of the paths

LauncherDownload.getAsset(assetFile,version)

get the asset assetFile, save it and return a promise of its path

LauncherDownload.getClient(version, [path])

get the client jar, save it and return return a promise of its path

LauncherDownload.getServer(version, [path])

get the server jar, save it and return return a promise of its path

LauncherDownload.extractNatives(version)

extract the natives files and return a promise to the path of the dir

LauncherDownload.getLibraries(version)

get all the libraries, save them and return a promise of an array of the paths

Testing

The MC_SERVER_JAR environment variable must be defined and point the .jar location before calling npm test.

changelog

History

1.6.0

1.5.1

  • Fix publish.yml

1.5.0

  • Fix etag not md5 on all downloads (@u9g)
  • Kill process when shutdown takes too long (@IceTank)

1.4.0

  • Throw on too old java version
  • Don't use broken native transport (Thanks @nickelpro)
  • Allow explicitly picking a java executable
  • Use node-fetch instead of request

1.3.0

  • update dependencies
  • make the server depend on its parent process (thanks @imharvol)

1.2.3

  • run the server in detached mode to avoid closing it by accident when doing ctrl+c on the main script

1.2.2

  • stop printing . to the console for wrap server

1.2.1

  • increase ram default in wrap server

1.2.0

  • standardjs
  • use new non-aws client and server download urls (thanks @lluiscab) : required >= mc 1.13

1.1.8

  • fix yggdrasil dependency

1.1.7

  • bump dependencies

1.1.6

  • add params for mc <=1.6

1.1.5

  • handle userProperties (necessary for 1.8) in wrap client

1.1.4

  • implement path based promise queue for downloading to avoid downloading 2 times the same path

1.1.3

  • remove duplicate libs

1.1.2

  • fix some bugs for initial download of the client

1.1.1

  • fix wrap client arg processing

1.1.0

  • add launcher_download class that act like the launcher downloader
  • implement client wrap
  • add runMinecraft bin
  • add option to not override config files in wrap server

1.0.2

  • write empty arrays in json list files instead of nothing, needed since 17w18b

1.0.1

  • use 'close' instead of 'exit' event for quitServer : might cause less problems

1.0.0

  • improve the cli interface
  • can now download the client

0.7.1

  • improve default done regex to support both spigot and vanilla

0.7.0

  • add OPTIONS parameter to specify the ram usage and the done string to check for spigot support

0.6.5

  • go back to using mkdirp, which doesn't have any problem after all

0.6.4

  • batch.concurrency(1) fixes the bug

0.6.3

  • use fs.mkdir instead of mkdirp, should fix the bug

0.6.2

  • fix the dir existence checking

0.6.1

  • check the created path is actually created in wrap_server.js

0.6.0

  • check with a md5 hash that the file downloaded is correct, doesn't download it if the destination file is already the correct file

0.5.4

  • create empty banned-players.json, banned-ips.json, ops.json, whitelist.json to avoid errors

0.5.3

  • fix writeServer

0.5.2

  • don't stop the server if there's nothing to stop

0.5.1

  • some cleanup of wrap

0.5.0

  • change default properties to something more default

0.4.0

  • add wrap.writeServer(line)

0.3.0

  • separate stopping the server and deleting its files

0.2.0

  • add downloadMinecraft to bin

0.1.0

  • download and wrap functionality (mostly imported from mineflayer and node-minecraft-protocol)