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

@scriptserver/core

v2.0.4

Published

A minecraft server wrapper built in Node

Downloads

57

Readme

@scriptserver/core

FYI: This package is an addon for ScriptServer and requires ScriptServer to be set up, please see here for more information.

Class: ScriptServer

ScriptServer is simply a combination of JavaServer and RconConnection, entirely for convenience.

import { ScriptServer } from '@scriptserver/core';

new ScriptServer(config: Config)

scriptserver.start()

Starts the javaServer and attempts to connect with the rconConnection

scriptserver.stop()

Disconnects the rconConnection and stops the javaServer

Class: JavaServer

JavaServer is a class that manages the java process itself, and captures the java process STDOUT.

import { JavaServer } from '@scriptserver/core';

new JavaServer(config: Config)

  • config: Config
    • javaServer
      • jar: string
      • args: string[]
      • path: string
      • pipeStdout: boolean
      • pipeStdin: boolean
      • flavorSpecific
        • [flavor name]
          • startedRegExp: RegExp
          • stoppedRegExp: RegExp
const javaServer = new JavaServer({
  flavor: 'spigot',
  javaServer: {
    jar: 'spigot.jar',
    flavorSpecific: {
      spigot: {
        startedRegExp: /.../i,
        stoppedRegExp: /.../i,
      },
    },
  },
});

javaServer.start(): void

javaServer.stop(): void

javaServer.send(message: string): void

Sends an input to the java process STDIN

Note - Usually you should prefer RconConnection.send instead of using this, as you cannot reliably determine what the result of a sent message here is. Only use this if you are not using an RconConnection.

javaServer.on('start', () => void)

javaServer.on('stop', () => void)

javaServer.on('console', (message: string) => void)

Class: RconConnection

RconConnection is a class that manages the rcon connection to the java server. This requires that the RCON connection is enabled in the server's server.properties

import { RconConnection } from '@scriptserver/core';

new RconConnection(config: Config)

  • config: Config
    • rconConnection
      • host: string
      • port: number
      • password: string
      • buffer: number
const rconConnection = new RconConnection({
  rconConnection: {
    password: 'password',
  },
});

rconConnection.connect(): void

rconConnection.disconnect(): void

rconConnection.send(message: string): Promise<string>

rconConnection.on('connected', () => void)

rconConnection.on('disconnected', () => void)

Interface: Config

The config object is shared across all modules in ScriptServer, specific keys at the root level determine what module the config is for. The shape of the Config is the same regardless of which class you are using.


const config = {
  myPluginConfig: {...},
  rconConnection: {...},
  javaServer: {...},
}

new ScriptServer(config);
new JavaServer(config);
new RconConnection(config);

Extending config for plugins

If you are creating a plugin you might want to add type-safety to your config object, you can do that by adding the following to your module:

import { Config } from '@scriptserver/core';

interface CustomPluginConfig {
  etc: string;
}

declare module '@scriptserver/core/dist/Config' {
  interface Config {
    customPlugin: CustomPluginConfig;
  }
}

If all else fails, just refer to the official plugins and how they are extending the configuration.

Note - this is purely for typescript and type-safety, this is not required for making a plugin.