This small package will let you start
, stop
and send
messages to a minecraft server.
// require our package
var mc_srv = require('mc_srv');
// some configuration
mc_srv.Configuration.basePath = '~/minecraft';
// defining server
var definition = { name: "Test Server", jarfile: "minecraft_server.jar" };
var server = new mc_srv.Server(definition);
// start server
server.start();
There are a couple of global values that can be set.
Key | Default | Description |
---|---|---|
basePath |
The root folder where your mindcraft servers exists | |
standardArguments |
-Xms1024m -Xmx2G | Arguments appended to the command line |
A server definition consist of a name
and a jarfile
. When launching a server, mc_srv will look for the jarfile
inside of the name
folder.
The Server
class provides the following methods
Launces the server. If the server already runs, it will do nothing.
Stops a running server.
Returns true if the server i stopped.
Sends message to the server. This is the same as writing in the server console on a manually launched server.
A server will emit the following events.
Event | Arguments | Description |
---|---|---|
status | status | Will signal changes in server status. Possible values are starting, ready, stopping and stopped |
player joined | player | A new player has joined the server |
player left | player | A player left the server |
chat | player message | Player sent a message in the chat |
data | data | Minecraft sent data to the console |
Tests can be run using [Mocha][http://mochajs.org/].