Giter Site home page Giter Site logo

minehut-file-watcher's Introduction

minehut-file-watcher

GitHub

minehut-file-watcher is a helpful command line tool that will watch your files and automatically push them to your Minehut server when they are changed. This is great for people writing config files or scripts, as they don't have to type in their editor, copy-and-paste the content from their editor to Minehut's editor, then click Save, wait for it to upload, then reload in-game. Instead, they can just type in their editor and reload in-game. Nothing more.

Like this project? Star the repo
Found a bug, have a suggestion? Make an issue

This is a fixed version of Jellz minehut file watcher (https://github.com/jellz/minehut-file-watcher) I am not the original creator, just maintaining it with new breaking API changes.

Getting Started

Currently the only way to install it is download the code, and install it globally, locally. E.g npm install -g ./directory/here/minehut-file-watcher

$ mh-watch

minehut-file-watcher

--setserver=<server name>
Set the server to push files to (persistent)

--setsession=<session id>
Set the session id to use to authenticate with Minehut (not persistent, you may need to update this)

--setauth=<token>
Set the password to use to authenticate with Minehut (not persistent, you may need to update this)

--setprofiletoken=<id>
Set the SLG profile token to authenticate with Minehut

--dump=<auth>
If you use the code in the read me, you can just dump the result here and everything will be set for you.

--getconfig
Get your current config. Useful for debugging.

--minehutpath=<remote path>
Set the path of the file you want to update remotely

--download=<remote path>
Download a file from the minehut server

After setting the above persistent config values, use mh-watch <file> (--minehutpath=<remote path>).

To clarify the --minehutpath option: you must provide it when you run mh-watch <file>, not before as a standalone option. For example, mh-watch --minehutpath=/plugins/Skript/scripts/myscript.sk and then mh-watch script.sk will not work.

You need to do mh-watch script.sk --minehutpath=/plugins/Skript/scripts/myscript.sk.

Setup

So in the initial versions of this tool, it was much easier to setup. However with API changes it has become very hard. You can use the MH+ google chrome extension to make the following process easier, as it will automatically fetch the keys needed when you open the minehut.com website.

At the moment, you can use the following code to get the auth keys: (You need to inspect element the minehut website, and go to console. Paste this all in there)

console.save = function (data, filename) {
    if (!data) {
        console.error('Console.save: No data')
        return;
    }

    if (!filename) filename = 'data.json'

    if (typeof data === "object") {
        data = JSON.stringify(data, undefined, 4)
    }

    var blob = new Blob([data], {
            type: 'text/json'
        }),
        e = document.createEvent('MouseEvents'),
        a = document.createElement('a')

    a.download = filename
    a.href = window.URL.createObjectURL(blob)
    a.dataset.downloadurl = ['text/json', a.download, a.href].join(':')
    e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
    a.dispatchEvent(e)
}

const getCookie = (name) => decodeURIComponent(document.cookie).split("; ").find(
  cookie => cookie.startsWith(name)
).slice(name.length + 1);

console.save(({
    minehutToken: getCookie("access_token_prd"),
    minehutSession: localStorage.minehut_session_id,
    slgUserToken: localStorage.slg_user_token,
}));

Take the values and input them into the seperate inputs for each value. (Or, you can instead use the --dump=(auth-file) method to just dump the full file result of the code above and have it sorted automatically by the code.)

  • Set your Minehut session-id with mh-watch --setsession=1234abcd
  • Set your Minehut auth token with mh-watch --setauth=minehutisfree78
  • Set your Minehut SLG profile token with mh-watch --setprofiletoken=omgthisismyprofile!!
  • Choose your server with mh-watch --setserver=MyServer (the command should output the server ID if it was successful)

After setting the three config values, run the following command in a terminal: mh-watch path/to/my/file.yml --minehutpath=path/to/file/on/minehut.yml. If I was editing a script, I would use the command mh-watch shop.sk --minehutpath=plugins/Skript/scripts/shop.sk. You need to pass the --minehutpath option every time you watch a file, while the other three config options are persistent.

Note: If the value of minehutpath is a path to a nonexistent file, the file will automatically be created on the server.

minehut-file-watcher's People

Contributors

raybytes avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

crewly

minehut-file-watcher's Issues

Needs a easter egg

It's a cultural religion to add secret easter eggs in code, do it or else we'll process.exit(1) you!

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.