Code Monkey home page Code Monkey logo

minecraft-tools's Introduction

Simple and scriptable tools for Minecraft server admins. Read my blog post for the full story.

Download your world from Realms

$ source login.sh EMAIL PASSWORD
$ realms-download.sh

This downloads the latest backup of your currently active world to world.tar.gz. No local install of Minecraft is needed. You're now free to run Overviewer or whatever you want.

You'll need

You need httpie and jq, so sudo apt-get install httpie jq if needed.

Validate your current access token

When you login, your access token is displayed and stored in the environment variable access_token. The token means you don't have to keep logging in (and risk rate-limiting), but eventually it expires. You can validate your access token at any time with

$ validate.sh $access_token

Understanding logins

We run the login script with source to set three environment variables for the other tools to pick up:

  • access_token, e.g. 14fc1a392727462fa35e0d82e138aef1
  • name, e.g. notch
  • id, e.g. 069a79f444e94726a5befca90e38aaf5

If you're interested in player UUIDs check out https://mcuuid.net.

Rate limiting

If you made too many authentication requests recently, a valid login will be rejected as invalid - the error looks like an incorrect password. If in doubt, wait 15 minutes.

Notice, as long as validate.sh $access_token shows your token is valid, you don't need to authenticate again.

Download an older backup

Pass the backup number 1-4, e.g. realms-download.sh 2 downloads the second backup in the list. Default is 1.

Limitations

  • Only the currently active world is available.
  • Only the four most recent backups are available for download.

Why did I make this?

As an admin I want small, simple tools that are easy to understand and adapt for my purposes.

There are amazing tools out there like yggdrasil, but they carry a ton of baggage (i.e. 67 npm packages).

The point of REST APIs is to be simple and accessible without advanced tools. For these scripts you just need httpie and jq, which deserve a place in your toolbox.

Understanding Realms

The backups listed in the game client are the only backups that exist. The 'download latest' button just selects the one at the top - #1, as indexed by the API - downloads it and extracts into your $HOME/.minecraft/saves with the correct world name.

You can see the same backup list in raw JSON with GET ${realms_server}/worlds/${world_id}/backups.

Service availability

I've seen the Realms API throw 503s - with the response Retry again later - on retrieving the download link for a world. Keep retrying until it works.

Timestamps

Each backup has a timestamp. When you download a world, check the timestamp on level.dat - this should match what's shown in the game client.

If you 'download latest' from the game,, what ends up in your saves directory is not identical to what you get direct from the API. I believe the game client processes the world files somehow, since many of their timestamps are set to now.

minecraft-tools's People

Contributors

air avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

minecraft-tools's Issues

Realm download fails with server

On the first response command (line 19) we get the following response:

http: error: SSLError: hostname 'mcoapi.minecraft.net' doesn't match '*.realms.minecraft.net'

Currently the block of variables is set to:

backup_number="${1:-1}"
output_file=world.tar.gz
realms_server=https://mcoapi.minecraft.net
version=1.11.2

I've tried changing the version line to version=1.12 but the error continues.

I've also tried changing the realms_server definition to realms_server=https://realms.minecraft.net but the error continues.

Just now I've tried changing both the version to 1.12 and the realm to mcoapi.realms.minecraft.net and I get:
http: error: ConnectionError: HTTPSConnectionPool(host='mcoapi.realms.minecraft.net', port=443): Max retries exceeded with url: /worlds (Caused by <class 'socket.gaierror'>: [Errno -2] Name or service not known)

I'm pretty sure the above is simply related to the lockouts from multiple attempts to run the command, but I've not confirmed that. I have confirmed that I've run the "source login" command successfully.

Status code 503

You should make an automated retry with 503. The time to wait is defined in Retry-After header.

HTTP 404 - Not Found from realms-download.sh

Hello,

Thanks for the tools, trying to get them to pull a realm backup down for use with overviewer - however the script for realms-download is pulling a 404 when being executed:

swwils@PC21:~/minecraft-tools$ ./realms-download.sh
/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py:794: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
  InsecureRequestWarning)
/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py:794: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
  InsecureRequestWarning)

http: warning: HTTP 404 Not Found
Error getting download link, response:

login.sh working fine and gets token, name and id

Is it possible that the endpoint has changed location?

get-minecraft-jar is broke and doesn't check what's downloaded

File content is

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>987FFE0301ABCF82</RequestId><HostId>r0GZtrKQydrUA+7Dr7+Xv1XIo7Myjy9NzQwkziIenfQrMGjmK6lLoOvakQ9za5Z+sbfYWudRybc=</HostId></Error>

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.