/ssn

🍉 Minecraft anarchy server (configs, plugins and more)

Primary LanguageSvelteGNU General Public License v3.0GPL-3.0

Over-engineered open-source Minecraft anarchy server — made in Brasil 🇧🇷✨

🗂 What's inside?

This monorepo uses npm as a package manager. It includes the following applications:

  • apps: web applications related to the server
  • packages: libraries shared between apps
  • plugins: first-party Minecraft plugins source code
  • servers: the Minecraft servers configuration files and plugin binaries

📦 Dependencies

Make sure you have Node.js v20 installed with npm v8 or up. You can easily change your Node version using nvm:

$ nvm install 20
$ nvm use 20

For plugin development, you will need JDK 17 and Maven. To install them on macOS using Homebrew, run:

$ brew install openjdk@17 maven

Finally, you will also need to have Docker and Docker Compose installed. You can easily get both by installing the much recommended Docker Desktop.

⚡️ Get started

First off, install the dependencies by running the following command:

$ npm install

Then, you will need to setup your environment variables. You can do this by copying the example file:

$ cp .env.example .env

Now, open your /etc/hosts file and add these lines to the end:

127.0.0.1 ssn.local id.ssn.local gk.ssn.local rcon.ssn.local cmd.ssn.local
::1       ssn.local id.ssn.local gk.ssn.local rcon.ssn.local cmd.ssn.local

You can now start all the containers by running this command:

$ npm run start

🎉 You should now be able to join the Minecraft server using the IP ssn.local and open http://ssn.local in your browser.

🧰 Build

To build a plugin and copy the artifact to the server, you can run this command:

# npm run build:plugin-name
$ npm run build:catraca

All services are rebuilt on start by default.

🚀 Deploy

For deploying in production you can generally follow the development environment steps and:

  • Only expose the 25565 and 80 ports from your server
  • Setup the environment variables inside ".env" properly
    • Generate random and strong passwords for the keys
    • Configure the memory allocation according to your server
    • Fill in external sevice keys (like Discord, Turnstile and SendGrid)
    • Update the volume mount points to local paths

For now™, you'll need to build the containers and run them on your server like so:

$ chmod +x ./scripts/deploy.sh
$ ./scripts/deploy.sh

🔄 Auto restart

To enable automatic restarts, you'll need to setup a cron job to run the scripts/restart.sh script. Begin by making all scripts in the scripts directory executable:

$ find scripts -type f -iname "*.sh" -exec chmod +x {} \;

Then, get the full path to the restart script:

$ realpath ./scripts/restart.sh
# /path/to/restart.sh

Finally, you can use crontab to add your cron job as you wish. I like to run it every day, a minute before 6am (to account for the restart warning) — remember to check your system time beforehand!

$ crontab -e
# if vim opens by default you can also use:
# EDITOR="nano" crontab -e
59 5 * * * /path/to/restart.sh

If you need help with cron, you can refer to crontab.guru.

🤒 Known issues

These are known issues with the current setup of this project:

  • As you restart your instance multiple times, a gigantic build cache will form until your containers are out of space. When that happens, run docker system prune -af --volumes to delete all your docker containers and volumes.
  • Docker image building and publishing are not currently configured. Therefore, deployment requires manual steps and can take up to 10 minutes to complete.

🤝 Contributing

First of all, thank you for your interest in making SSN better! Contributions are always welcomed. Feel free to open an issue with your suggestion or bug report, preferably in Brazilian Portuguese. Please, read our contribution guidelines before working on an issue.

📝 License

The SSN project is licensed under the GPLv3 License.