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

earthmc

v9.9.1

Published

An unofficial EarthMC library providing handy methods and extensive info.

Downloads

192

Readme

EarthMC-NPM

An unofficial wrapper library for interacting with the EarthMC map APIs. This package is part of the EarthMC Toolkit and provides extensive info on people, places and more.

Install

bun add earthmc

While I recommend Bun for its speed, you can also install the package with any other package manager.

PNPM ➜ pnpm add earthmc
Yarn ➜ yarn add earthmc
NPM (ew) ➜ npm i earthmc

Import

By default, the available maps are exported and can be used like so:

import { Aurora } from 'earthmc' // ESM
const { Aurora } = require('earthmc') // CJS

However, you may want to create your own map instance to customize the expiry time of the cache.

import { Squaremap } from 'earthmc'

const Aurora = new Squaremap('aurora') // Defaults to `5000` (or 5s).
const Aurora = new Squaremap('aurora', 30 * 1000) // Keep cached for half a minute.

Basic Usage

Visit the documentation to use this library to its full potential.

const towns = await Aurora.Towns.all().catch(console.error)
console.log(towns.length)

// These calls are instant since the previous call to `all()` populated the cache.
const single = await Aurora.Towns.get('exampleName')
const many = await Aurora.Towns.get('town1', 'town2', 'town3', ...)

GPS

In addition to the four main classes (Towns, Nations, Residents, Players), both maps also provide a GPS. Here is an example of how you could use it.

// To avoid PVP, call `safestRoute` instead.
const route = await Aurora.GPS.fastestRoute({ x: town.x, z: town.z })
const desc = `Type **/n spawn ${route.nation.name}** and head **${route.direction}** for **${route.distance}** blocks.`

To continously track a player, you can use the track method.

  • First parameter (player name) is required, but case insensitive.
  • Second parameter (interval) is optional. Defaults to 3000 milliseconds.
  • Third parameter (route) is optional. Defaults to FASTEST.
// Start tracking a player, with 5s delay, outputting the safest route.
const tracker = await Aurora.GPS.track("PlayerName", 5000, Routes.SAFEST).catch(e => {
    console.error("Error fetching player: " + e)
})

// Listen for any errors that may occur.
tracker.on('error', e => {
    console.error("An error occurred: " + e)
})

tracker.on('underground', (playerInfo) => {
    console.log("Player went underground - " + playerInfo)
})

tracker.on('locationUpdate', (routeInfo) => {
    console.log("Player's location updated - " + routeInfo)
})