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
maxMemoryAllocation
maxMemoryAllocation is the maximum amount of memory that the server can use. This is in MB.
Number
minMemoryAllocation
minMemoryAllocation is the minimum amount of memory that the server can use. This is in MB.
Number
Start
servercraft.start('args', { maxMemoryAllocation:"1024M", minMemoryAllocation:"1024M" )
Setup
servercraft.setup(startAfter,'args',config)
startAfter
Start server after setup
bool
args
If startAfter is true, pass these command-line arguments to start()
string
config
If startAfter is true, pass this to start()
object
Delete your server
servercraft.delete()
Get path to the directory
servercraft.dirpath
Last updated
Was this helpful?