mc-minder 0.1.0

A smart management suite for Minecraft Fabric servers on Termux/Android
Documentation

MC-Minder ๐ŸŽฎ

Crates.io License: MIT Rust

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

cargo install mc-minder

From Source

git clone https://github.com/SharkMI-0x7E/mc-minder.git
cd mc-minder
cargo build --release

For Termux/Android (aarch64)

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:

cp mc-minder/config.example.toml ./config.toml

Edit config.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 ๅฏๅŠจๆœๅŠกๅ™จ

# 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

Endpoint Method Description
/status GET Get server status and uptime
/history GET Get conversation history
/command POST Execute RCON command

Example:

# 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 ๅค‡ไปฝ

# 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 file for details.

Acknowledgments ่‡ด่ฐข

  • This project was written with AI assistance
  • Inspired by the need for lightweight Minecraft server management on mobile devices

Author ไฝœ่€