76 lines
2.3 KiB
Markdown
76 lines
2.3 KiB
Markdown
# MC god
|
|
|
|
Minecraft (MC) god is a tool that connects to a Minecraft server's RCON port, listens for messages from users by tailing the log, and interacts with players. It has the ability to call some functions to control things like weather, day/night cycle, and difficulty.
|
|
|
|
## Layout
|
|
|
|
This repository uses the Go standard layout described at https://github.com/golang-standards/project-layout.
|
|
|
|
- internal/pkg
|
|
- rcon -- contains utilities for interacting with the RCON service
|
|
- cmd/mcgod -- contains the main function
|
|
|
|
### RCON
|
|
|
|
https://github.com/gorcon/rcon is used to connect to the RCON. The system expects the user provide a RCON_ADDRESS, and RCON_PASSWORD environment flag.
|
|
|
|
## Usage
|
|
|
|
### Environment Variables
|
|
|
|
The mcgod application requires the following environment variables to be set:
|
|
|
|
- `RCON_ADDRESS` - The address of the Minecraft server's RCON (e.g., "localhost:25575")
|
|
- `RCON_PASSWORD` - The password for RCON access
|
|
- `RCON_DEPLOYMENT` - Kubernetes deployment name for log monitoring (optional)
|
|
- `RCON_NAMESPACE` - Kubernetes namespace for log monitoring (optional)
|
|
- `RCON_POD` - Kubernetes pod name for log monitoring (optional)
|
|
- `RCON_CONTAINER` - Kubernetes container name for log monitoring (optional)
|
|
|
|
### Running Locally
|
|
|
|
To build and run locally:
|
|
```bash
|
|
make build
|
|
RCON_ADDRESS="localhost:25575" RCON_PASSWORD="your_rcon_password" ./mcgod
|
|
```
|
|
|
|
### Running with Docker
|
|
|
|
To build and run with Docker:
|
|
```bash
|
|
make build-docker-local
|
|
docker run --rm -it \
|
|
-e RCON_ADDRESS="localhost:25575" \
|
|
-e RCON_PASSWORD="your_rcon_password" \
|
|
docker.tipsy.codes/mcgod:latest
|
|
```
|
|
|
|
## Building
|
|
|
|
### Local Build
|
|
```bash
|
|
make build
|
|
```
|
|
|
|
### Cross-platform Build
|
|
```bash
|
|
make build-amd64 # Build for AMD64
|
|
make build-arm64 # Build for ARM64
|
|
```
|
|
|
|
### Docker Build
|
|
```bash
|
|
make build-docker # Build multi-architecture Docker image
|
|
make build-docker-local # Build Docker image for current architecture
|
|
```
|
|
|
|
# Handling updates
|
|
|
|
Use `go mod tidy` to update go.mod; do not directly modify it.
|
|
|
|
# Best practices
|
|
|
|
## Only capture environment/flags in main
|
|
|
|
To make testing easier, all utility packages should accept arguments that they need. These arguments sometimes get provided by the user, via flags or environment variables. Such variables should generally only be captured in the top-level package (i.e., main), and not helpers. |