Socket
Book a DemoInstallSign in
Socket

earthmc

Package Overview
Dependencies
Maintainers
1
Versions
221
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

earthmc

An unofficial EarthMC library providing handy methods and extensive info.

latest
Source
npmnpm
Version
10.4.0
Version published
Maintainers
1
Created
Source

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 continuously 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)
})

Keywords

earth

FAQs

Package last updated on 19 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts