@hyprtrail/minecraftserver-addons
v1.0.6
Published
minecraftserver-addons ============ (https://github.com/hyprtrail/minecraftServer-addons)
Downloads
3
Readme
minecraftserver-addons
(https://github.com/hyprtrail/minecraftServer-addons)
What's minecraftserver-addons?
Addons for @hyprtrail/minecraftServer
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-addons
.
import(require) the addons you want
const minecraftServer = require('@hyprtrail/minecraftserver')
const path = require("path")
const mcserver = new minecraftServer({ jar: path.resolve(__dirname,'../Minecraft/server.jar') })
// add addons chat and joinleave
const {chat, joinleave} = require("@hyprtrail/minecraftserver-addons")
mcserver.addAddon(chat)
mcserver.addAddon(joinleave)
mcserver.start()
Getting the data
chat addon
Listeners: chat
/**
* @typedef {object} ChatData
* @property {string} player
* @property {string} message
* @property {string} time
* @property {string} thread
* @property {string} level
*/
mcserver.on('chat', (data)=>{
/** @type {import('@hyprtrail/minecraftserver-addons').ChatData} */
console.log(`Chat-data:`)
console.log(data)
})
advance_achieve addon
Listeners: advancement
, achievement
and goal
/**
*
* @typedef {Object} AdvancementData
* @property {string} player
* @property {string} advancement
* @property {string} time
* @property {string} thread
* @property {string} level
*/
/**
*
* @typedef {Object} AchievementData
* @property {string} player
* @property {string} achievement
* @property {string} time
* @property {string} thread
* @property {string} level
*/
/**
*
* @typedef {Object} GoalData
* @property {string} player
* @property {string} goal
* @property {string} time
* @property {string} thread
* @property {string} level
*/
mcserver.on('advancement', (data)=>{
/** @type {import('@hyprtrail/minecraftserver-addons').AdvancementData} */
console.log(`Advancement-data:`)
console.log(data)
})
mcserver.on('achievement', (data)=>{
/** @type {import('@hyprtrail/minecraftserver-addons').AchievementData} */
console.log(`Achievement-data:`)
console.log(data)
})
mcserver.on('goal', (data)=>{
/** @type {import('@hyprtrail/minecraftserver-addons').GoalData} */
console.log(`Goal-data:`)
console.log(data)
})
joinleave addon
Listeners: join
and leave
/**
*
* @typedef {Object} JoinData
* @property {string} player
* @property {string} ip
* @property {number} x
* @property {number} y
* @property {number} z
* @property {string} time
* @property {string} thread
* @property {string} level
*/
/**
*
* @typedef {Object} LeaveData
* @property {string} player
* @property {string} message
* @property {string} time
* @property {string} thread
* @property {string} level
*/
mcserver.on('join', (data)=>{
/** @type {import('@hyprtrail/minecraftserver-addons').JoinData} */
console.log(`Join-data:`)
console.log(data)
})
mcserver.on('leave', (data)=>{
/** @type {import('@hyprtrail/minecraftserver-addons').LeaveData} */
console.log(`Leave-data:`)
console.log(data)
})
serverInfo addon
Listeners: started
and starting
/**
*
* @typedef {Object} StartingData
* @property {string} time
* @property {string} thread
* @property {string} level
*/
/**
*
* @typedef {Object} StartedData
* @property {string} time
* @property {string} thread
* @property {string} level
*/
mcserver.on('started', (data)=>{
/** @type {import('@hyprtrail/minecraftserver-addons').StartedData} */
console.log(`Started-data:`)
console.log(data)
})
mcserver.on('starting', (data)=>{
/** @type {import('@hyprtrail/minecraftserver-addons').StartingData} */
console.log(`Starting-data:`)
console.log(data)
})
death addon
Listeners: death
mcserver.on('death', (data)=>{
console.log(`Started-data:`)
console.log(data)
})