We spend a lot of time playing Minecraft and the old bot that we used just wasn't cutting it. When players got off the server, the EC2 instance shut down. This was fine, but players weren't held accountable for the time they spent on the server, and we wanted this to change.
What it does
When a player joins the server, they have their own personal collection of tokens (currency) that is deducted from as the user is on the server. It is deducted at a rate of 1 credit per minute. If the user runs out of tokens, they are bombarded with TNT in order to keep them from playing until they pay to be on the server. They can use the discord bot in order to check how many credits they have. If the bot joins another discord server, they credits are persisted between servers because of our usage of Cloud SQL.
How I built it
The server is built upon the Google Kubernetes Engine in order to make deploying as simple as possible. Things like our discord bot and our API server are running on Kubernetes. But, our minecraft servers themselves are also running up in the cluster! In order to persist data, we use Google Cloud Sql to persist data about our users and credits. We also wanted to play around with big data, so we implemented Google's BigQuery to store every time a block is broken.
Challenges I ran into
We did not know how to create a Bukkit plugin, and we did not know much about google cloud. One of the team members was familiar with AWS, so we had that as a starting point. We had to work with load balancers, kubernetes, Google's hosted nodes and BigQuery. We had a lot of issues in the beginning in getting our applications posted and deployed on the servers. After a while, we got some scripts running to get our application hosted. Creating an HTTP POST request in Java was an enormous hurdle as well. None of us knew Java so we had to do a lot of research in order to figure out what to do. We all learned a ton in the process.
Accomplishments that I'm proud of
The moment that we got our Java plugin to communicate with our NodeJS backend, we were extremely proud. We had issues getting the proper information to POST to the server because of the way Java handles the input. The issue was that we had to include the "Content-Type": "application/json" header.
What I learned
We learned how to make a plugin for Minecraft servers. None of us knew how to code in Java, let alone work on a plugin for a pre-existing server. We have learned so much and are extremely excited to use this knowledge to create plugins in the future.
What's next for Minecraft Discord Bot
We are extremely excited to actually implement this bot, so we want to continue working on it to make it fully polished and able to be used. We all enjoy playing with each other, and removing the need to manage server payments will be a huge help!