Socket
Socket
Sign inDemoInstall

prismarine-realms

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prismarine-realms

Node.JS Wrapper around both the Java & Bedrock Realms API


Version published
Maintainers
1
Created
Source

prismarine-realms

NPM version Build Status Discord Try it on gitpod

Node.JS Wrapper around both the Java & Bedrock Realms API. Minecraft Realms is a subscription based service provided by Mojang where users can create/manage their own private server. The intention of this package is to provide easy access to the internal API used to manage Realms such as opening/closing a Realm, managing players, getting host information and much more.

Installation

npm install prismarine-realms

Usage

RealmAPI

.from(authflow: Authflow, platform: 'bedrock' | 'java')

Takes an Authflow instance from prismarine-auth, you can see the documentation for this here.

API

Definitions

ParamTypeDescription
realmIdstringThe ID of the Realm
realmInviteCodestringThe invite code for the Realm (Only on Bedrock)
usernamestringThe username of player
uuidstringThe unique ID of the player, w/o hyphens
xuidstringThe Xbox User ID of the targeted player

const { Authflow } = require('prismarine-auth') 
const { RealmAPI } = require('prismarine-realms')

const authflow = new Authflow()

const api = RealmAPI.from(authflow, 'bedrock')
getRealms()

Gets a list of Realms the authenticating account has joined or owns

await api.getRealms()
getRealm(realmId: string)

Gets detailed information about a Realm if owned

await api.getRealm('1234567')
getAddress()

Gets the address for the Realm

const realm = await api.getRealm('1234567')

await realm.getAddress()
invitePlayer(uuid: string, name: string)

Invites a player to the Realm

const realm = await api.getRealm('1234567')

await realm.invitePlayer('a8005260a332457097a50bdbe48a9a21', 'Steve')
open()

Opens a Realm. Allows players to join

const realm = await api.getRealm('1234567')

await realm.open()
close()

Closes a Realm. Removes all current players and restricts joining

const realm = await api.getRealm('1234567')

await realm.close()

Using prismarine-realms with Mineflayer, Node Minecraft Protocol and Bedrock Protocol

Prismarine-auth is used in Mineflayer to allow quick connection to owned/joined Realms by providing a pickRealm function which should return a single Realm instance. It will then handle getting the host information and connect your bot to that Realm. The process of getting the Realms connection is handled in the protocol libraries meaning the same options can be passed there as well.

Mineflayer
const mineflayer = require('mineflayer')

const bot = mineflayer.createBot({
  username: 'example',
  auth: 'microsoft',
  realms: {
    pickRealm: (realms) => realms.find(realm => realm.name === 'My Realm')
  }
})
Node Minecraft Protocol
const protocol = require('minecraft-protocol');

const client = protocol.createClient({
  username: 'example',
  auth: 'microsoft',
  realms: {
    pickRealm: (realms) => realms.find(realm => realm.name === 'My Realm')
  }
});
Bedrock Protocol
const protocol = require('bedrock-protocol');

const client = protocol.createClient({
  username: 'example',
  realms: {
    pickRealm: (realms) => realms.find(realm => realm.name === 'My Realm')
  }
});

Keywords

FAQs

Package last updated on 02 Apr 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc