1.0.5 • Published 2 years ago

@hyprtrail/minecraftserver v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

minecraftServer

What's minecraftServer?

Its a Wrapper for Minecraft server written in node.js. Using child_process to open the server in another thread and read the console.

What version of Minecraft does it work with?

It relies format of the output log, it should work with pretty much any version of Java Minecraft dating back to 2012.

Prerequisites

  • NodeJS (^16.0.0 recommended)
  • NodeJS knowledge.

Setup

Run npm install @hyprtrail/minecraftServer. Download the minecraft server.jar. instance the server and supply the path to the minecraft server server.jar . Remember to accept the eula.

const minecraftServer = require('@hyprtrail/minecraftserver')
const path = require("path")

// {jar:'pathToJar', minmem: 8G, maxmem: 8G, javapath:'', javaoptions:''}
const mcserver = new minecraftServer({ jar: path.resolve(__dirname,'../Minecraft/server.jar') })

mcserver.start()

You start your server with start() method

Getting the data

/**
 * @typedef {Object} StdoutData
 * @property {string} fullmsg
 * @property {string} time
 * @property {string} thread
 * @property {string} level
 * @property {string} message
 */

mcserver.on('data', (data)=>{
  /** @type {import('./mcserver').StdoutData} */
  console.log(`Data:`)
  console.log(data)
})

Addons (https://github.com/hyprtrail/minecraftServer-addons)

To import an addon just require the addon-js file and add it to the server.

  const chat = require("/minecraftServer-addons/src/chat")
  mcserver.addAddon(chat)
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago