I own a Survival Minecraft server. It’s free to play and you can check it out at amongdemons.com
Below I’ll give you more details on the custom Java plugin I built. This is what makes the server unique.
What is a Custom Minecraft Plugin for Spigot?
For those of you that don’t know, Minecraft is the best selling game of all time. At least that’s what wiki says at the time I’m writing this.
Simply put, it’s online Lego with blocks. You take them from one place and put them in another. The types of blocks are so diverse that players created computer logic inside it. Yes, you read that right, your imagination is the limit.
Anyway, back to my project. Spigot is an interface over the default Minecraft server that allows coders to build custom features in game.
There is an entire database with free and premium plugins. I use some of them, but I needed more. Let’s go through the most impactful features I created.
Whitelist System
The server accepts everyone, including non-premium players. These are people that didn’t buy the game and want to play with us. Imagine there’s a terminology for them, so yes, they are many.
They can change the in-game username every time they start Minecraft. Practically a person can grief and ruin other players’ experience on the server with no consequences. In this case I don’t know who to ban. They can always return with a different alias.
That’s why I needed a whitelist. Here’s how it works:
- Every player must register on the website using the in game username, an email and a custom password.
- When entering the game, your character can’t move or do anything important until you login. This was all coded by me in the custom plugin.
- To start playing you need to enter the custom command /login [password]
- This command remotely connects to the website database and checks if you are eligible to play or not.
- If someone gets banned they lose all the currency and the protected areas that are connected to that email.
Anti-flood Check
I coded a part where if 2 or more players connect from the same IP and they didn’t login, one of them gets kicked.
This helps when malicious people flood your server with random usernames. They will have to register and login with all. Most people don’t know how to modify the random scripts they find on the internet.
If they somehow find a solution, I still have the option to make the accounts inactive at register. This gives the server enough protection against this type of attacks.
MySQL Economy Connected to Vault
The main currency on the server is called Souls. These are stored in the database along side with the player’s other information.
Everyone will get some when they register, vote the server, refer a friend or donate. But these features are part of the website. I talk more about that in this article.
Most Spigot plugins agreed upon using an intermediate plugin called Vault. So I coded mine to be a provider for all their functions. Every transaction will now connect to the website database and use each player’s balance as the in game currency. In coding terms, my plugin implements the Vault’s Economy class.
This allowed me to:
- configure GriefPrevention to consume souls when players want to claim land
- create a custom command /addmarker which costs souls. This adds a sign to the Dynmap live map. You can check that out on here
- convert player’s souls into levels. Everyone can check their balance in game using /souls and they can consume souls for levels using /souls convert [number]
- transfer currency from one player to another using /souls give [player] [amount]
Passive Rewards for Online Players
I didn’t want to rely 100% on the website for souls generation. Players should have an option to get rewarded while playing the game.
After a I tested a few options, I finally decided it’s best to gift active players. Everyone who is online will get souls every 10 minutes.
The amount of souls is set as a variable in the config.yml file. This way I can change it without recompiling the plugin. Then I run a BukkitScheduler which creates a multi-line insert in the MySQL database.
Receive Pending Items from MySQL Database
Players can trade their souls (server currency) for in game items. I created a small shop on the website. You can check it out here.
The problem is that I don’t have direct access to everyone’s inventory. I can’t put items whenever I want. The user must trigger this event.
To solve this issue, I save all the purchased items in a database. These rows are temporary. When the player connects to the game or uses the custom command /claimkits, the items are transferred and the database is cleared.
This last part is controlled by the plugin.
Source Code and Final Thoughts
I wrote this article to summarize the things I programmed for my Spigot plugin. You can find all the java code on GitHub. Use it freely. With a few minor changes, you can apply it to your Minecraft server.
github.com/alurosu/alurosu.minecraft.survival
As always, if you have any questions, suggestions or feedback, please comment down below.
Thanks for checking out my project.
Leave a Reply
You must be logged in to post a comment.