BuildContest

BuildContest plugin automatically creates Minecraft sub-servers using Docker and transfers players to their respective contest servers.

63

BuildContest

BuildContest Plugin

BuildContest is a Velocity plugin that simplifies the setup of dedicated servers for each team in a building contest. The plugin uses Docker Compose to start sub-servers and automatically transfers players to their respective sub-servers for the contest. Team configurations and server information are persistently stored.

Features

- Prevent Duplicate Participation: Create team servers using HTTP API calls with Docker Compose, and register them with Velocity. - Prevent Duplicate Participation: Players are automatically transferred to their corresponding sub-servers when joining the main server. - Prevent Duplicate Participation: Authenticate HTTP requests using Bearer Token. - Prevent Duplicate Participation: When adding a team, if a player already exists in another team, they cannot join other teams.

Installation Steps

1. Prepare the Environment - Install Prepare the Environment proxy server. - Ensure Docker and Docker Compose are installed and properly configured.

2. Create a Minecraft Contest Server Image (Sub-Server) - It's recommended to use Create a Minecraft Contest Server Image (Sub-Server) as the server base. - Set the port to `25565` and ensure it can be accessed correctly via the proxy, including proper `forwarding-mode` settings. - Create a Dockerfile for building the server image. - Build the image, e.g., `docker build -t minecraft-contest:latest .` - Create a `docker-compose.yml` file for starting the sub-server.

3. Download the Plugin - Jump to Download the Plugin

4. Configure the Plugin - Place the plugin jar file in the `plugins/` directory of Velocity. - Start the Velocity server once to generate the configuration files, then stop the server to adjust settings.

5. Configure Files - Modify `config.yml` in the `plugins/BuilderContest/` directory to set up ports and other settings. - Place `docker-compose-default.yml` in the plugin directory as the template for starting sub-servers.

6. Start the Server - Start the server and retrieve the `bearer-token` from the generated `config.yml`.

Configuration File Description

config.yml ```yaml ktor: http-port: 8080 # HTTP service port. port-start: 30000 # Starting port for sub-servers. bearer-token: # Bearer Token; leave this empty on first use. allow-host: "*" # Allowed host addresses. ```

docker-compose-default.yml Example - Use `#SERVER_NAME_PLACEHOLDER` as the placeholder for the Docker container name. - Use `#SERVER_PORT_PLACEHOLDER` as the placeholder for the port. ```yaml version: '3.8' services: minecraft_server: image: minecraft-contest:latest container_name: "#SERVER_NAME_PLACEHOLDER" ports: - #SERVER_PORT_PLACEHOLDER:25565 volumes:

Mount the local world directory to the specified path in the container

- ./worlds/#SERVER_NAME_PLACEHOLDER/world:/app/world environment: EULA: "TRUE" restart: unless-stopped ```

Usage Instructions

HTTP API

- After the plugin starts, an HTTP service will be launched on port `8080` by default. - Key API endpoint: - Add Team: `POST /team/add`, requires Bearer Token authentication, with `teamId`, `teamName`, and `members` as payload fields.

Example Request

```bash curl --location --request POST 'http://localhost:8080/team/add' --header 'Content-Type: application/json' --header 'Authorization: Bearer sSCj4piDoEfV2zIo_C8lD7S4ul0YlVOyBr2BkKpdsTI (Retrieve this from config.yml)' --data-raw '{ "teamId": "team_1", "teamName": "Team 1", "members": ["Hanamizu_", "user1"] }' ```

ADS