Monicraft
- 9 Devlogs
- 48 Total hours
A python TUI app for monitoring a minecraft server running on a pterodactyl panel trough the pterodactyl client API and the Textual python library.
A python TUI app for monitoring a minecraft server running on a pterodactyl panel trough the pterodactyl client API and the Textual python library.
The final devlog for Monicraft is finally here. It has been a long, but really educational, journey. I’ve locked in for a last time and rewritten the whole player manager logic
. It is now way more optimized and only updates the data for online players. I’ve switched from keeping everything apart to making a class for each player and storing all the data in it, and then keeping those objects in a dictionary with the player’s uuid as the key.
Admin Camilio13 > {message}.
Monicraft’s second-to-last devlog has arrived
. I’ve now added the last feature I wanted to add, the “include offline player list” button. It works by simply getting the whole usercache.json file and getting all the names and UUID’s in it. After that it’s just using my old function to retrieve the saved data and stats on the server. I still wanna optimize it and take some time to fix and improve the application overall.
) the visibility of offline players in the Player List. Also added a extra column to the table to see who’s online and who’s not. Online players will allways show up at the top. You’re also able to use some of the Player Manager’s features on offline players.{UUID}.dat) now operates in parralel, so bigger servers don’t have to wait for seconds every time the table is built. This brings up the problem that the default rate limit for the client API is 240 requests/min, so really big servers with more than 40 recent (offline) players or even online players will exceed this limit. This is why I wanted to implement offline player caching, more on that in future plans.
. I didn’t discover this until I ran it in my native terminal, I’ve done all the testing in my built-in terminal in my IDE.I think I will be doing one more devlog where I will add these features and polish it for the first SHIP.
I’ve been working hard on some big changes to make the project, faster, more reliable and visually attractive. I’ve gone ahead and implemented one of the two final changes, the statistics screen for players. It was alot of repetitive work, but I managed to make it look good. At first I wanted to parse some of the saved stats (such as play time, deaths, etc.) manually, but I came to the conclusion that formatting the tag (minecraft:damage_dealt –> Damage Dealt) and showing them was a better idea. I found some naming logic in the tags so I could filter out time, distances and damage to format them into a readable format. All distance stats end with one_cm and are stored in centimeters (1/100 of a block). All time stats contain the substring "time" and are stored in ticks (1/20 of a second). And finally all the damage stats contain the substring "damage" and are stored as 10 times the damage for more precision (or 20 times the hearts damage).
requests library to the httpx library to make it so queries, server statuses and normal requests all operate separately.usercache.json on the server, right into RAM for faster acces and less requests.API class which was trying to show notifications, without being part of the actual GUI. It is now fixed by passing the app class onto the API class and giving it acces to the GUI.
I’m getting close to finishing this project (fr this time
). I think it will be one more devlog, it’s been a long ride.
I randomly realised that not everyone has a minecraft server laying around, so I decided to make a dummy mode, so everyone can test out the Monicraft dashboard. I’ve now polished all the player manager buttons (except for Include offline players and Statistics, more on that in future plans). You’re now able to message, kick, ban and change gamemode with the player manager. I made this more user-friendly by using pop-ups.
--dummy argument when running the program. This makes it so every command that is sent to the “server” is just displayed in the terminal, making you able to see what’s going on. I’ve added a stream_dummy_data() function that updates the stats every 2 seconds with random values. The mod list will be empty. The player list will display a random new player every 10 seconds (those are the default minecraft skins’ names + some random number). You’re able to use every feature from the player manager in dummy mode, everything being sent will be displayed in the console.Include Offline Players button: This makes it so offline players (cached in usercache.json in the server’s root) will be displayed in the player list. Maby I’ll also add the ability to manage offline players, but I’m not sure.Statistics button: This button will show a pop-up that shows all the player’s stats (such as blocks broken, mobs killed, etc.)
It’s been a few long session with alot of thinking and implementing
. I never thought that getting the online players would be so hard. At first, I wanted to use minecraft’s list command and then parse the output from the terminal, but that was way too hard and would not work on big servers with terminals full of commands. So I decided to use the mcstatus library to get a list of all online players. This is done by:
I then use the name to get the UUID of a player stored in the usercache.json file in the root directory of every minecraft server. That UUID is then used to get the saved {UUID}.dat file in the worlds folder. All the player’s data (e.g. health, hunger, position, gamemode, etc.) is stored in there. This brings the restriction of the server’s autosave time (which is 5 minutes by default). So I’ve also added a refresh button which saves the game and updates the player list. The player list is automatically updated every ten seconds and based off the lastest safe file.
New Features:
Future Plans:
This project is close to being finished, but I want to add two last features.
.env file. You can also reset these value’s.Future Plans:
settings command).
say in front of every command you send, which makes it easier to chat with the people that are online on your server.Bugs and Future Plans:
How I came up with the idea:
I was just thinking about what I could possibly make, I felt like coding, but I just didn’t know what I should make. So I just started playing minecraft as always, on the server with my friends. When I was changing something on the server panel, I was wondering how the panel really works. It turns out almost every hosting provider uses the Pterodactyl dashboard. It relies on a REST API, which is publicly available to anyone. I decided to try and recreate such a panel, but in Python.
The foundation:
The connection with the Pterodactyl API is established trough websockets. I decided to start with a screen which is an overview of the main server resources (such as CPU usage, RAM usage and Storage usage) and the console. The GUI is build with Textual and customized by the built-in TCSS.
What I have done so far:
I initially started this project to learn more about API’s and specifically websockets. I also wanted to see how it would be to build a GUI app in python and if it’s really as hard/bad-looking as everyone says.