Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@scriptserver/json

garrettjoecox16GPL-3.02.0.4TypeScript support: included

Simple module for storing and reading data in JSON files

minecraft, server, scriptserver

readme

@scriptserver/json

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

useJson(server: ScriptServer | JavaServer | RconConnection)

import { ScriptServer, RconConnection, JavaServer } from '@scriptserver/core';
import { useJson } from '@scriptserver/json';

const scriptServer = new ScriptServer();
useJson(scriptServer.rconConnection);
// Or
const rconConnection = new RconConnection({
  json: {
    path: __dirname + '/json',
  },
});
useJson(rconConnection);

// Or

const javaServer = new JavaServer({
  json: {
    path: __dirname + '/json',
  },
});
useJson(javaServer);

Class: ScriptServer | JavaServer | RconConnection

This module adds the json methods to all of the three servers, depending on what is passed in to the useJson() method

server.json.get: (path: string, key?: string) => Promise<T>

server.json.set: (path: string, key: string, value: T) => Promise<T>

Interface: Config

These configuration options are here to override as needed for flavors, if you are having trouble getting the utils to work in your given flavor of server, try overriding these.

  • config: Config
    • json
      • path: string