DonutBot/README.md

85 lines
2.1 KiB
Markdown

# mcbot
Mineflayer bot for handling a spawner workflow, placing bone orders, and protecting the area with automatic emergency shutdown logic.
## Features
- Repeating spawner cycle (`/api/spawner`) with a 60-second delay between cycles.
- GUI automation for:
- opening spawner GUI
- moving bones to inventory
- running `/order ZareMate`
- delivering and confirming order
- Security monitor:
- detects unauthorized nearby players (from `allowed_players.txt`)
- detects nearby block breaks
- triggers emergency routine
- Emergency routine:
- attempts to break/remove the spawner
- attempts to stash spawner drops into a nearby ender chest
- sends Discord webhook alert
- quits bot
- Simple web UI + API on `http://localhost:3008`.
## Requirements
- Node.js 18+
- A valid Microsoft-authenticated Minecraft account for the configured bot username
- Access to target server (`java.donutsmp.net` by default in code)
## Install
```bash
npm install
```
## Configure
Create `.env` in project root.
```env
DISCORD_WEBHOOK_URL=
ALLOWED_PLAYERS_FILE=allowed_players.txt
DEBUG_LOGS=0
```
Notes:
- `ALLOWED_PLAYERS_FILE` can be relative to project root or absolute path.
- `DEBUG_LOGS=1` enables extra slot/window debug logging.
## Run
```bash
node index.js
```
## Web Endpoints
- `GET /` : basic web UI
- `GET /api/logs` : bot logs as JSON
- `POST /api/spawner` : start spawner loop
- `POST /api/stop` : stop spawner loop
## Allow List
Edit `allowed_players.txt`:
- one player name per line
- case-insensitive matching
- lines starting with `#` are ignored
## Important Runtime Behavior
- On first spawn, bot stores join position and auto-arms security after 5 seconds.
- Movement guard pauses loop if bot is moved too far from loop start.
- If security is triggered, bot now tries to stash spawner items in ender chest before quitting.
## Files
- `index.js` : all bot logic and HTTP server
- `web/index.html` : web UI
- `allowed_players.txt` : allow-list for security monitor
- `AGENTS.md` : guidance for future automation agents
- `docs/BOT_OPERATIONS.md` : deeper operational notes