How-This-Works

Minecraft Website/Database

The Minecraft website is connected to a Firebase Realtime Database. This is a cloud-hosted database where the data is stored as a JSON object and synchronized in real time with every connected client. The purpose of this database is to store the Minecraft build commands for the Discord bot and Minecraft server to read. This database has two sections. One section is a list of users, each containing a unique key. Under this unique key, each Minecraft build is stored. Under the build name, the Minecraft commands necessary to create the build are listed. The second section is a username section. Each username has a unique key attached to it. This key and associated username can be mapped to the user section to find the Minecraft builds for any user.

Image goes here

Once you navigate to the website, you will notice an authentication page. This authentication page is run using Firebase authentication. There are a few ways that Firebase authentication can be implemented, one of which is FirebaseUI Auth. FirebaseUI Auth handles the login page and allows users to login with an email and a password. FirebaseUI also provides additional services with authentication, such as account recovery.

Once authentication has been established, you will notice a home page that includes a create username section. This allows a user to change their username at any point, as long as the new username is unique and contains no special characters. To check whether the new username is unique, a database reference is created. Each username in the database will be read and compared to the new username. If a match has been found, then that username has already been taken and will be denied. If the username is unique, then two new database references are created. One reference finds the user’s unique ID in the username section of the database and removes the old username. The second database reference adds the new username and sets the value to the user’s unique ID.

Under the create username section, you will see a “Choose File” button and a terminal screen. On activation, this button opens a file reader to read each NBT file that is uploaded. Once you select the Choose File button and pick your Minecraft NBT file, a Python script will run your NBT file to create the Minecraft build commands. This process is run using Pyodide. Pyodide makes it possible to run Python through a web browser. Once this has completed, the output is a list of JSON Minecraft commands. These commands are then uploaded to the database using a database reference.

Under the terminal screen, you will see a list of Minecraft build paths. This list is read directly from the database and updated whenever a new build is uploaded. The Minecraft build list function creates a database reference to access each username stored in the username section of the database and grabs each unique ID. This ID is then used to find the associated build names under the user section of the database. If a build name is found, the username of the unique ID is concatenated with the build name found under that unique ID to create the build path. This process repeats for each unique ID, and each path found is placed into an array. Once this has been completed, the array will consist of all possible build paths and be displayed on the website.