You are browsing as a guest. Sign up (or log in) to start making projects!

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.

Ship #1

Monicraft is a TUI based app that runs right in your terminal. It contains features like Real-Time Console Monitoring, Command Execution, Power Actions, Resource Monitoring, A Chat Mode, A Settings Page, A Mod Page and A Player Manager. It relies on the Pterodactyl Panel’s client API, which most rented servers run on, so it’s pretty useful if you prefer an alternate way of monitoring your server or want easier acces to things like player data and stats.

I think it turned out to be a really great and pretty useful project. I run a minecraft server myself, and I think I could actually use this to monitor my minecraft server. The UI looks not that bad for a TUI tool and the features allow you to do almost anything you can do on the web Pterodactyl Panel.

I learned alot of new things while making this project. I learned how to use an API and websockets. I also learned how to optimize networking and apps in general to make them run smoother. I think that my python skills also improved overall, together with the way of computational thinking. It was a really long project and I put alot of time in it, but I think it was worth it and look out to making more projects like this.

  • 9 devlogs
  • 48h
  • 17.55x multiplier
  • 846 Stardust
Try project → See source code →
Open comments for this post

7h 29m 11s logged

Monicraft - Offline Player Caching, More statistics, Better Exception Handling & More :python:


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 :aaaaa-disintegrates: . 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.


New Features:

  • Offline Player Caching: The data for all players is now cached at all times, right into memory. It then checks the online player list and updates it every 30 seconds (by default).
  • More configuration: You can now change the interval for the player data fetching and the online player list fetching. You can also set a prefix for the chat mode, like Admin Camilio13 > {message}.
  • More Resource Management: You can now also see the disk usage (total size of the server) and network inbound and outbound on the main screen.
  • UI improvement: I gave the main screen a little overhaul to make it look a bit better. And I tried to make the buttons and everything else as stable as possible, but they’re still sometimes shifting or not perfectly centered depending on your screen size and terminal zoom. This is a problem I can’t fix and will always be there when using Textual.
  • Fixed bugs:
    • Several bugs with dummy mode, the app relied on non-existing API functions.
    • Cursor kept shifting when player list refreshed.
    • Pterodactyl client API rate limit was exceeded on big servers.
0
1
53
Open comments for this post

4h 46m 46s logged

Monicraft - Offline Player List, Async Player Data Fetching & More :python:


Monicraft’s second-to-last devlog has arrived :hack: . 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.


New Features:

  • Include Offline Players: A toggle which toggles (yeah, the toggle toggles something :yayayayayay: ) 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.
  • Async Player Data Fetching: The fetching of playerdata (stored in {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.
  • Improved Stats UI: The statistics pop-up was a bit too small and not all the data could fit in. So I made it a bit cooler by making it bigger :sunglas:
  • Small Fixes
    • Only ping the server when it’s running to prevent errors.
    • Fixed a problem where my Unicode characters got turned into ugly emoji’s :angry-fart: . 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.

Future Plans:

I think I will be doing one more devlog where I will add these features and polish it for the first SHIP.

  • Fix a bug where you suddenly select the first row of the table after rebuilding it
  • Create a cache for offline players
  • Add disk usage resource data
  • Settings: Changing the loop delay
  • Settings: Chat mode and message prefixes
  • Make the GitHub workflow files
  • Make an installation guide in the README
0
0
22
Open comments for this post

7h 17m 32s logged

Monicraft - Player Statistics, Asynchronous Networking & More :python:


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).


New Features:

  • Statistics screen: This screen is accessed trough the “Stats” button in the player manager and contains 3 tabs: General, Entities and Items. General contains stats like amount of jumps, distance walked and interactions with special blocks, entities shows the kill count for every entity you’ve killed and the Items tab shows how many of each item you’ve crafted, mined, used, broken, picked up and dropped.
  • Async Networking: I’ve switched from the requests library to the httpx library to make it so queries, server statuses and normal requests all operate separately.
  • UUID caching: Monicraft will now no longer have to send a request to the API to figure out someones UUID. On the first request it caches every user and their names, which are stored in usercache.json on the server, right into RAM for faster acces and less requests.
  • Small fixes and optimizations: When starting up without any credentials, it will now scan for credentials until inputted in the settings instead of crashing. The request headers are also updated when new credentials saved. I’ve fixed a logging issue with the 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.

Future Plans:

  • Include offline players in player manager: Last real feature I want to add.
  • Finalizing and polishing: I wanna make sure everything runs bug-free, the program doesn’t crash and also make it look good on most (I can’t make it look good on all screen sizes) screen sizes. I need to build the executables and make sure they’re working.
0
0
5
Open comments for this post

5h 34m 24s logged

Monicraft - Player Manager, Dummy Mode & More! :python:


I’m getting close to finishing this project (fr this time :blob_hype: ). 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.


New Features:

  • Pop-ups in Player Manager: You’re now able to give the reason for a kick or ban with the use of an interactive pop-up. The message feature also uses a pop-up to send a message directly to the selected player. Changing the gamemode is done trough a pop-up with a selection menu, which excludes the gamemode the player is currently in and let’s you choose between the other 3.
  • Dummy Mode: This mode is accessed by adding the --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.
  • Fixed Reconnect Logic: When the server disconnects for whatever reason, the dasboard will now try to reconnect every 5 seconds.
  • Queries with statusses as fallback: The recent implementation used both queries and statusses if queries were enabled. It now only uses statusses if queries are not enabled. This makes it alot more optimized, using only one of two all the time.

Future Plans:

  • Implement the 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.
  • Implement the Statistics button: This button will show a pop-up that shows all the player’s stats (such as blocks broken, mobs killed, etc.)
0
0
61
Open comments for this post

5h 44m 52s logged

Monicraft - Player Manager, NBT Parsing & More :python:


It’s been a few long session with alot of thinking and implementing:nvs: . 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:

  1. Sending a query to the server.
  2. If queries are disabled on the server or the query simply fails, it sends a normal status request (server list ping) to the server.

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:

  • Player Manager: A way to see all online players and their statistics. You can also kick and ban people by just selecting them and clicking a button.

Future Plans:

  • Adding the functionality to toggle the visibility of offline players in the player list.
  • Adding functionality to the following buttons: Stats, Message, Gamemode
  • Adding a player stats screen (viewed by clicking the stats button) which shows all the statistics of a single player (e.g. mobs killed, blocks broken, distance ran, etc.)
0
0
35
Open comments for this post

3h 37m 30s logged

Monicraft - Mods list, Server kill, Navigation buttons & UI/UX improvements :python:


  • I’ve added buttons to navigate between screens. I forgot to add this last time, so travelling between screens was a bit tricky. :dumb:
  • You’re now able to kill the server for when the server get’s stuck in a shutdown or crashes. It will sent a confirmation pop-up message upon the first click, telling you to click another time to confirm. This lasts for 10 seconds and then it will reset.
  • I’ve also added a new screen with a list of all the mods you’ve installed on the server, including name, file size and last changed date.
  • The UI/UX is now alot more stable. I had orginally designed everything on my monitor. But when I would use it on my laptop screen, the whole UI collapsed. So I made everything a bit smaller.

Future plans:

This project is close to being finished, but I want to add two last features.

  • Player management: Quickly see who’s online on the server and manage them (kick, ban, whitelist, unwhitelist)
  • Version manager: See what versions of Minecraft, Java and mod loader you’re using and modify them.
1
1
32
Open comments for this post

5h 10m 23s logged

Monicraft - Settings, Power action buttons, Visual Improvements


  • I’ve added a settings page where you can configure your API key, Panel endpoint and Server ID. It has a save button and automatically saves when leaving the screen, which writes the inputs to an .env file. You can also reset these value’s.
  • I’ve added power action buttons, which can be used to start, restart or stop your minecraft server.
  • I’ve added pop-up toasts for errors and informative messages.
  • I’ve improved the connection funtions to retry every 5 seconds when the connection is lost.

Future Plans:

  • Adding a button to navigate to the settings menu (it is now accessed by sending the settings command).
  • Version manager for Java, Minecraft and Mods.
0
1
19
Open comments for this post

3h 42m 18s logged

Monicraft - Server resources viewer, Sending commands, Chat mode & Styling :python:


  • The console now works properly. It now streams the console directly from your Minecraft server to your terminal trough websockets.
  • The server resources (RAM usage, CPU usage and server state) are now visible in a sidebar and are constantly being updated.
  • It’s now possible to send commands to the server using the input bar at the bottom. I also added a extra “Chat Mode”, it basically puts say in front of every command you send, which makes it easier to chat with the people that are online on your server.
  • The style has been upgraded. I went for a green/nature looking style, because I like the color palette.

Bugs and Future Plans:

  • The Chat Mode button doesn’t change color until you move your cursor after you clicked it, not a big problem, but it is kinda confusing.
  • I wanna add the option to view/update/remove your installed mods on the server and give more insight into the installed version of modloader.
0
1
22
Open comments for this post

4h 48m 42s logged

First devlog for Monicraft!


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:

  • Setup the main code space
  • Do some research about the API and learn how Textual works
  • Design the UI shape
  • Connection with the API trough websockets (WIP)

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.

0
2
16

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…