2.1.7 • Published 2 years ago

@amoraschi/earthmc v2.1.7

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Node.js wrapper for the EarthMC API, to retrieve information from the EarthMC server

Inspired from earthmc

The changelog is available here

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getNation('Madagascar')
  .then(nation => console.log(nation))
import { EarthAPI } from '@amoraschi/earthmc'

@returns A Promise with an Information instance

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.info()
  .then(info => console.log(info))

@returns A Promise with an Array of Town instances

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getTowns()
  .then(towns => console.log(towns))

@param name - Name of the town

@returns A Promise with a Town instance, or undefined if the town wasn't found

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getTown('London')
  .then(town => console.log(town))

@returns A Promise with an Array of Player instances

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getTownless()
  .then(townless => console.log(townless))

@param name - Name of the town

@returns A Promise with an Array of Nation instances

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getJoinableNations('London')
  .then(nations => console.log(naitons))

@param x - Number on the X axis of the coordinates

@param z - Number on the Z axis of the coordinates

@param radius - Size of the radius in blocks

@returns A Promise with an Array of Town instances

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getNearbyTowns(0, 0, 1000)
  .then(towns => console.log(towns))

@returns A Promise with an Array of Resident instances

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getResidents()
  .then(residents => console.log(residents))

@param username The username of the resident

@returns A Promise with a Resident instance, or undefined if the resident wasn't found

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getResident('Notch')
  .then(resident => console.log(resident))

@returns A Promise with an Array of Player instances

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getPlayers()
  .then(players => console.log(players))

@param username The username of the player

@returns A Promise with a Player instance, or undefined if the player wasn't found

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getPlayer('Notch')
  .then(player => console.log(player))

@param x - Number on the X axis of the coordinates

@param z - Number on the Z axis of the coordinates

@param radius - Size of the radius in blocks

@returns A Promise with an Array of Player instances

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getNearbyPlayers(0, 0, 1000)
  .then(players => console.log(players))

@returns A Promise with an Array of string

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getAllPlayers()
  .then(players => console.log(players))

@returns A Promise with an Array of Nation instances

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getNations()
  .then(nations => console.log(nations))

@param name - Name of the nation

@returns A Promise with a Nation instance, or undefined if the town wasn't found

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getNation('Madagascar')
  .then(nation => console.log(nation))

@param x - Number on the X axis of the coordinates

@param z - Number on the Z axis of the coordinates

@param radius - Size of the radius in blocks

@returns A Promise with an Array of Nation instances

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getNearbyNations(0, 0, 1000)
  .then(nations => console.log(nations))

@param name - Name of the nation

@param includeTaken - Default is false, if the function should include the towns that are already in a nation

@returns A Promise with an Array of Town instances

import { EarthAPI } from '@amoraschi/earthmc'

const earthmc = new EarthAPI()

earthmc.getInvitableTowns('Madagascar')
  .then(towns => console.log(towns))
{
  result: Ping
  info: {
    online: boolean
    queue: number
    towny: number
    stormy: boolean
    thundering: boolean
  }
}
{
  version: {
    protocol: number
    name: string
  }
  players: {
    online: number
    max: number
    sample: any[]
  }
  description: {
    extra: [
      {
        bold: true
        extra: Array<{
          color: string
          text: string
        }>
        text: string
      },
      {
        text: string
      },
      {
        color: string
        text: string
      }
    ]
    text: string
  }
  favicon: string
  latency: number
}
{
  chunks: number
  position: Vec3
  name: string
  nation?: string
  mayor: string
  residents: string[]
  onlineResidents: Player[]
  pvp: boolean
  mobs: boolean
  public: boolean
  explosion: boolean
  fire: boolean
  capital: boolean
}
{
  name: string
  town: string
  nation?: string
  rank: 'Nation Leader' | 'Mayor' | 'Resident'
}
{
  world: 'underground' | 'earth'
  username: string
  nickname: string
  position: Vec3
}
{
  name: string
  residents: string[]
  towns: Town[]
  king?: string
  capital?: string
  position: Vec3
  chunks: number
}
2.1.6

2 years ago

2.1.5

2 years ago

2.1.7

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago