Node.js

Servercraft can also be used programmatically through Node.js. To get started, install the package.

npm i servercraft

Initialize

const servercraft = require('servercraft')
const server = new servercraft()

Setup

server.setup(startAfter, args, config, version)

If startAfter is false, you can omit or pass null for the args and config parameters. If startAfter is true, you can omit the config parameter.

Start

server.start(args, config)

Stop

server.stop()

Get IP

server.ip

Args are command-line arguments, and config is a JSON object. You can find a list of all the arguments here. You can find a list of all the config options below.

Download

Servercraft also allows you to only download a JAR file to a directory.

require('servercraft').download('version', 'target dir')

Config

Start

config is optional

servercraft.start('args', { maxMemoryAllocation:"1024M", minMemoryAllocation:"1024M" )

Setup

servercraft.setup(startAfter,'args',config)

Delete your server

servercraft.delete()

Get path to the directory

servercraft.dirpath

Last updated