npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mc-server-events

v1.0.1

Published

Minecraft server events API

Downloads

8

Readme

Minecraft Server Events

A simple Node event emitter I made because one didn't exist yet.

Emission Types

  • all
  • connected
  • disconnected
  • time (time set changes)
  • died
  • mode (game mode changes)
  • chat

How it works

  1. Uses Chokidar to listen for change events on the server log file.
  2. When a change is detected, it finds out how many new lines have been added and processes each line individually using tail to get only the relevant lines.
  3. Parses the message and emits a Node event if a relevant message is found.

Example Usage

const McServerEvents = require('mc-server-events');
const events = new McServerEvents('../minecraft-server/logs/latest.log');

events.on('all', data  => {
	console.log(data.status, data);
});

Example Output

connected {
  user: 'kyjus25',
  id: 248,
  coordinates: { x: 224.5, y: 66, z: 110.5 },
  status: 'connected',
  context: 'kyjus25[/127.0.0.1:61599] logged in with entity id 248 at (224.5, 66.0, 110.5)',
  timestamp: '11:53:50'
}
disconnected {
  user: 'kyjus25',
  status: 'disconnected',
  context: 'kyjus25 left the game',
  timestamp: '11:54:07'
}
time {
  time: 13000,
  status: 'time',
  context: 'Set the time to 13000',
  timestamp: '11:54:17'
}
died {
  user: 'kyjus25',
  reason: 'drowned',
  status: 'died',
  context: 'kyjus25 drowned',
  timestamp: '11:54:57'
}
mode {
  user: 'kyjus25',
  mode: 'Creative',
  status: 'mode',
  context: "Set kyjus25's game mode to Creative Mode",
  timestamp: '12:16:22'
}
chat {
  user: 'kyjus25',
  message: 'Hello world!',
  status: 'chat',
  context: '<kyjus25> Hello world!',
  timestamp: '12:16:44'
}

Requirements

  • Created using the latest Minecraft (1.16.3), no support prior to this release.
  • Needs the tail command, so you probably need Linux or OSX
  • Needs access to the Minecraft server log file, so it needs to be running on the same machine as the one running the Minecraft server.

Need an event added?

Create an issue ticket on this repo, or feel free to add it yourself and send me a PR