Coder Social home page Coder Social logo

prismarine-realms's Introduction

prismarine-realms

NPM version Build Status Discord Try it on gitpod

Minecraft Realm interface for Minecraft Java and Bedrock editions, providing a stable API to start/stop Realms, and obtain Realm information such as connection addresses.

Minecraft Realms is a subscription based service provided by Mojang where users can host, create and manage their own private Minecraft servers.

Installation

npm install prismarine-realms

Usage

RealmAPI

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

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

Example

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

const authflow = new Authflow()

const api = RealmAPI.from(authflow, 'bedrock') // or 'java'

// Returns a list of Realms the authenticating account has joined or owns.
await api.getRealms().then(console.log)

Documentation

See API Documentation

prismarine-realms's People

Contributors

dependabot[bot] avatar extremeheat avatar iantapply22 avatar jojomatik avatar lucienhh avatar mrdiamond64 avatar rom1504 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

prismarine-realms's Issues

Preview Realms don't work with prismarine-realms

Is your feature request related to a problem? Please describe.

It is related to a problem, the new preview realms feature in Minecraft does not work with prismarine-realms

Describe the solution you'd like

Make a way to get and edit the preview realms

Describe alternatives you've considered

I have not considered anything else

Full coverage of Bedrock/Java Realm API

This issue is to track the current endpoints covered in prismarine-realms, most endpoints are documented here

Bedrock & Java

  • Realm Information

    • Get Realm by ID - GET /world/:realmId
    • Get all Realms - GET /worlds
    • Get subscription info - GET /subscriptions/:realmId
    • Get subscription info (detailed) - GET /subscriptions/:realmId/details
    • Get Realm connection info
      • Java - GET /worlds/v1/:realmId/join/pc
      • Bedrock - GET /worlds/:realmId/join
    • Get joinable Realms info
      • Java - GET /activities/liveplayerlist
      • Bedrock - GET /activities/live/players
  • Realm Management

    • Open Realm - PUT /worlds/:realmId/open
    • Close Realm - PUT /worlds/:realmId/close
    • Change active slot (1-3) - PUT /worlds/:realmId/slot/:slot
    • Edit name/description - POST /worlds/:realmId { "name": "", "description": "" }
    • Delete Realm - DELETE /worlds/:realmId
    • Reset Realm
      • Java - POST /worlds/{realmId}/reset { "seed": "", "worldTemplateId": -1, "levelType": 0, "generateStructures": true }
      • Bedrock - PUT /worlds/{realmId}/reset
    • Update Realm configuration
      • Java - POST /worlds/:realmId/slot/:slot
      { "pvp": true, "spawnAnimals": true, "spawnMonsters": true, "spawnNPCs": true, "spawnProtection": 0, "commandBlocks": false, "difficulty": 2, "gameMode": 0, "forceGameMode": false, "slotName": "", "worldTemplateId": -1, "worldTemplateImage": null }
      
      • Bedrock - POST /worlds/:realmId/configuration
      { "description":{"description": "","name": ""options":{"slotName":"Test","pvp":true,"spawnAnimals":true,"spawnMonsters":true,"spawnNPCs":true,"spawnProtection":0,"commandBlocks":false,"forceGameMode":false,"gameMode":0,"difficulty":2,"worldTemplateId":-1,"worldTemplateImage":"","adventureMap":false,"resourcePackHash":null,"incompatibilities":[],"versionRef":"","versionLock":false,"cheatsAllowed":true,"texturePacksRequired":true,"timeRequest":null,"enabledPacks":{"resourcePacks":[""],"behaviorPacks":[""]},"customGameServerGlobalProperties":null,"worldSettings":{"sendcommandfeedback":{"type":0,"value":true},"commandblocksenabled":{"type":0,"value":true},"dodaylightcycle":{"type":0,"value":true},"randomtickspeed":{"type":1,"value":3},"naturalregeneration":{"type":0,"value":true},"showtags":{"type":0,"value":true},"commandblockoutput":{"type":0,"value":true},"dofiretick":{"type":0,"value":false},"maxcommandchainlength":{"type":1,"value":65535},"falldamage":{"type":0,"value":true},"tntexplodes":{"type":0,"value":true},"drowningdamage":{"type":0,"value":true},"domobloot":{"type":0,"value":true},"domobspawning":{"type":0,"value":true},"showbordereffect":{"type":0,"value":true},"showdeathmessages":{"type":0,"value":true},"respawnblocksexplode":{"type":0,"value":true},"doweathercycle":{"type":0,"value":true},"doentitydrops":{"type":0,"value":true},"doimmediaterespawn":{"type":0,"value":true},"freezedamage":{"type":0,"value":true},"pvp":{"type":0,"value":true},"keepinventory":{"type":0,"value":false},"doinsomnia":{"type":0,"value":true},"mobgriefing":{"type":0,"value":true},"dotiledrops":{"type":0,"value":true},"firedamage":{"type":0,"value":true},"functioncommandlimit":{"type":1,"value":10000},"spawnradius":{"type":1,"value":25},"showcoordinates":{"type":0,"value":true}}}}
      
  • Backups

    • Restore to backup - PUT /worlds/:realmId/backups?backupId=xxx&clientSupportsRetries
    • Get backups - GET /worlds/:realmId/backups
    • Get backup download Java can only download world as is, Bedrock can download world from any backup or get latest
      • Java - GET /worlds/:realmId/slot/:slot/download
      • Bedrock - GET /archive/download/world/:realmId/:slot/:backupId
      • Bedrock (latest) - GET /archive/download/world/:realmId/:slot/latest
  • Invites

    • Get pending invites - GET /invites/pending
    • Get pending invites count -GET /invites/count/pending
    • Accept invite - PUT /invites/accept/:inviteId
    • Reject invite - PUT /invites/reject/:inviteId
    • Manage players
      • Java (invite) - POST /invites/:realmId { "uuid": "", "name": "", "operator": false }
      • Java (remove) - DELETE /worlds/:realmId/invite/:playerUUID
      • Java (op) - POST /ops/:realmId/:playerUUID
      • Java (deop) - DELETE /ops/:realmId/:playerUUID
      • Bedrock (invite) - PUT /invites/:realmId/invite/update { "invites": { [playerXUID]: "ADD" } }
      • Bedrock (remove) - PUT /invites/:realmId/invite/update { "invites": { [playerXUID]: "REMOVE" } }
      • Bedrock (op) - PUT /invites/:realmId/invite/update { "invites": { [playerXUID]: "OP" } }
      • Bedrock (deop) - PUT /invites/:realmId/invite/update { "invites": { [playerXUID]: "DEOP" } }
      • Bedrock (remove all) - PUT /invites/:realmId/invite/update { "invites": null }
  • Misc

    • Get recent news - GET /mco/v1/news
    • Check stage compatibility - GET /mco/stageAvailable
    • Check version compatibility - GET /mco/client/compatible
    • Get trial eligibility
      • Java - GET /trial
      • Bedrock - GET /trial/new

Bedrock Only

  • Realm Information

    • Get Realm info from invite - GET /worlds/v1/link/:realmInviteCode (realms.gg/AB1CD2EFA3B)
    • Get banned players - GET /worlds/:realmId/blocklist
  • Realm Managment

    • Ban player from Realm - POST /worlds/:realmId/blocklist/:xuid
    • Unban player from Realm - DELETE /worlds/:realmId/blocklist/:xuid
    • Remove Realm from joined list - DELETE /invites/:realmId
    • Realm enable forced texture pack - PUT /world/:realmId/content/texturePacksRequired
    • Realm disable forced texture pack - DELETE /world/:realmId/content/texturePacksRequired
    • Realm change default permission - PUT /worlds/:realmId/defaultPermission { "permission": "VISITOR" /* VISITOR, MEMBER, OPERATOR */ }
    • Realm change a user's permission - PUT /worlds/:realmId/userPermission { "permission": "VISITOR", /* VISITOR, MEMBER, OPERATOR */ "xuid": "" }
  • Invites

    • Get Realm invite info - GET /links/v1?worldId=xxx
    • Refresh Realm invite code - POST /links/v1
    • Add Realm from invite code - POST /invites/v1/link/accept/:realmInviteCode

Java Only

  • Realm Managment

    • Set Realm to minigame - PUT /worlds/minigames/:minigameId/:realmId
    • Get Realm activity - GET /activities/:realmId
  • Misc

    • Get Realm status - GET /mco/available

TypeError: api.getRealmInvite is not a function

This is my code:
const authflow = new Authflow()
const api = RealmAPI.from(authflow, 'bedrock')
const realm = await api.getRealm('6435795')
const code = await api.getRealmInvite('6435795')

Move API docs out of readme

With more endpoints being added it's a good time to move the API documentation out of the readme and into a docs directory where we can also handle platform-specific endpoints more clearly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.