# MC-Minder ๐ฎ
[](https://crates.io/crates/mc-minder)
[](https://opensource.org/licenses/MIT)
[](https://www.rust-lang.org/)
A smart management suite for Minecraft Fabric servers on Termux/Android. ไธไธชไธบ Termux/Android ไธ็ Minecraft Fabric ๆๅกๅจ่ฎพ่ฎก็ๆบ่ฝ็ฎก็ๅฅไปถใ
> **Note**: This project was written with AI assistance. ๆฌ้กน็ฎ็ฑ AI ่พ
ๅฉ็ผๅใ
## Features ๅ่ฝ็นๆง
- **Log Monitoring ๆฅๅฟ็ๆง**: Real-time monitoring of server logs, parsing chat/join/leave/death events
- **AI Chatbot AI ่ๅคฉๆบๅจไบบ**: Support for OpenAI API and Ollama, triggered by `!` prefix
- **RCON Communication RCON ้ไฟก**: Native RCON protocol implementation for sending commands and messages
- **Context Memory ไธไธๆ่ฎฐๅฟ**: Per-player conversation history with automatic expiration
- **HTTP API**: RESTful API for status queries, history, and command execution
- **Shell Scripts Shell ่ๆฌ**: Integrated start/stop/monitor/backup management
## Installation ๅฎ่ฃ
### From crates.io
```bash
cargo install mc-minder
```
### From Source
```bash
git clone https://github.com/SharkMI-0x7E/mc-minder.git
cd mc-minder
cargo build --release
```
### For Termux/Android (aarch64)
```bash
cargo build --target aarch64-linux-android --release
```
## Usage ไฝฟ็จๆนๆณ
### 1. Directory Structure ็ฎๅฝ็ปๆ
```
MC_server/ # Server root directory
โโโ fabric-server.jar # Server core
โโโ start.sh # Startup script (copy from scripts/)
โโโ config.toml # Configuration file
โโโ logs/
โ โโโ latest.log
โโโ world/
โโโ mc-minder/ # This project
โโโ Cargo.toml
โโโ src/
โโโ target/release/mc-minder
```
### 2. Configuration ้
็ฝฎ
Copy `config.example.toml` to your server root directory and rename to `config.toml`:
```bash
cp mc-minder/config.example.toml ./config.toml
```
Edit `config.toml`:
```toml
[server]
jar = "fabric-server.jar"
min_mem = "512M"
max_mem = "1G"
session_name = "mc_server"
log_file = "logs/latest.log"
[rcon]
host = "127.0.0.1"
port = 25575
password = "your_rcon_password"
[ai]
api_url = "https://api.openai.com/v1/chat/completions"
api_key = "sk-xxx"
model = "gpt-3.5-turbo"
trigger = "!"
max_tokens = 150
temperature = 0.7
[ollama]
enabled = false
url = "http://localhost:11434/api/generate"
model = "qwen:0.5b"
[backup]
world_dir = "world"
backup_dest = "../backups"
retain_days = 7
[notification]
telegram_bot_token = ""
telegram_chat_id = ""
termux_notify = true
```
### 3. Start the Server ๅฏๅจๆๅกๅจ
```bash
# Copy scripts to server root
cp mc-minder/scripts/start.sh ./
cp mc-minder/scripts/backup.sh ./
# Start
./start.sh start
# Stop
./start.sh stop
# Status
./start.sh status
# Attach to console
./start.sh attach
```
### 4. AI Chat Usage AI ่ๅคฉไฝฟ็จ
Players can trigger AI responses by prefixing their message with `!`:
```
!hello
!help
!how to make a diamond sword?
```
## HTTP API
| `/status` | GET | Get server status and uptime |
| `/history` | GET | Get conversation history |
| `/command` | POST | Execute RCON command |
Example:
```bash
# Get status
curl http://localhost:8080/status
# Execute command
curl -X POST http://localhost:8080/command \
-H "Content-Type: application/json" \
-d '{"command": "list"}'
```
## Project Structure ้กน็ฎ็ปๆ
```
mc-minder/
โโโ Cargo.toml # Rust project configuration
โโโ config.example.toml # Configuration example
โโโ README.md # This file
โโโ LICENSE # MIT License
โโโ .gitignore
โโโ scripts/
โ โโโ start.sh # Server startup script
โ โโโ backup.sh # Backup utility
โโโ src/
โโโ main.rs # Main entry point
โโโ lib.rs # Library exports
โโโ config.rs # Configuration parsing
โโโ log_monitor.rs # Log file monitoring
โโโ ai_client.rs # AI API client
โโโ rcon_client.rs # RCON protocol client
โโโ context.rs # Conversation context manager
โโโ http_api.rs # HTTP API server
```
## Command Line Options ๅฝไปค่ก้้กน
```
mc-minder [OPTIONS]
Options:
-c, --config <PATH> Configuration file path [default: ../config.toml]
-v, --verbose Enable verbose logging
--http-port HTTP API port [default: 8080]
-h, --help Show help
-V, --version Show version
```
## Backup ๅคไปฝ
```bash
# Create backup
./backup.sh create
# List backups
./backup.sh list
# Restore from backup
./backup.sh restore ../backups/mc-backup-20240101-120000.tar.gz
# Clean old backups
./backup.sh clean
```
## Requirements ็ณป็ป่ฆๆฑ
- Rust 1.70+
- Java (for Minecraft server)
- tmux (for session management)
- Optional: Ollama (for local AI)
## Contributing ่ดก็ฎ
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## License ่ฎธๅฏ่ฏ
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Acknowledgments ่ด่ฐข
- This project was written with AI assistance
- Inspired by the need for lightweight Minecraft server management on mobile devices
## Author ไฝ่
- GitHub: [@SharkMI-0x7E](https://github.com/SharkMI-0x7E)