GeminiMC - 用于 Minecraft 服务器管理的 Gemini AI
一款强大的 Minecraft 插件,集成了 Google 的 Gemini AI,帮助服务器管理员通过自然语言命令管理他们的服务器。
功能特性
- 自然语言界面:用普通英语向 Gemini 提问
- 命令执行:AI 可以建议并执行服务器命令
- 确认系统:在命令执行前进行审查(或启用自动接受)
- 对话记忆:保持聊天历史记录以提供上下文感知的响应
- 服务器上下文:AI 可访问服务器信息、玩家数据和最近的聊天记录
- 仅限 OP 访问:安全——只有服务器操作员才能使用此插件
- 双模型支持:同时使用 Gemini 2.0 Flash 进行规划和执行
要求
- Minecraft 1.21+(Spigot/Paper 服务器)
- Java 21 或更高版本
- Google Gemini API 密钥
安装
- 下载插件 JAR 文件
- 将其放入服务器的
plugins 文件夹中
- 重启服务器
- 配置你的 API 密钥(参见设置部分)
设置
获取 Gemini API 密钥
- 前往 Google AI Studio
- 点击“创建 API 密钥”
- 复制你的 API 密钥
配置插件
- 在游戏中运行:
/g setapikey YOUR_API_KEY_HERE
- 或者编辑
plugins/GeminiMC/config.yml 并在其中添加你的密钥
用法
基本命令
/g <问题> - 向 Gemini AI 提问
/g setapikey <密钥> - 设置你的 Gemini API 密钥
/g autoaccept <true|false> - 切换自动接受命令
/g clearhistory - 清除对话历史
/g context view - 查看当前服务器上下文
/g context clear - 清除最近的聊天上下文
/g confirm - 确认待处理的命令
/g cancel - 取消待执行的命令
/g help - 显示帮助信息
示例用法
基础问题
/g 当前在线玩家有多少?
/g 主世界现在几点?
/g 服务器使用了多少内存?
服务器管理
/g give all online players a diamond
/g teleport everyone to spawn
/g change the weather to clear
/g set the time to day in all worlds
复杂任务
/g create a new world called "mining" with seed 12345
/g ban player xyz for griefing
/g give op to player abc
命令确认
当 Gemini 建议执行命令时,你会看到:
⚠ AI 想要执行以下命令:
• /give @a diamond 1
• /say Diamonds for everyone!
[确认] [取消]
点击按钮或输入 /g confirm 或 /g cancel。
自动接受模式
对于可信的操作,启用自动接受:
/g autoaccept true
命令将立即执行,无需确认。请谨慎使用此模式!
要禁用:
/g autoaccept false
工作原理
-
上下文收集:当你提出问题时,插件会收集当前服务器信息:
- 在线玩家
- 世界数据
- 服务器性能(TPS、内存)
- 最近的聊天消息
-
AI 处理:你的问题和上下文将被发送至 Gemini AI
-
响应解析:分析 AI 的回复以提取命令建议
-
命令执行:如果存在命令建议:
- 在普通模式下:你需要进行确认
- 在自动接受模式下:命令将自动执行
-
历史记录追踪:对话会被保存以便后续使用
配置
编辑 plugins/GeminiMC/config.yml:
# 你的 Gemini API 密钥
api-key: ""
# 自动接受命令执行
auto-accept: false
# 保留的最大聊天记录数量
max-history: 50
# 包含在上下文中的最近聊天消息最大数量
max-chat-context: 10
# Gemini API 设置
gemini:
planning-model: "gemini-2.0-flash-exp"
execution-model: "gemini-2.0-flash-exp"
api-url: "https://generativelanguage.googleapis.com/v1beta/models/"
安全
- 仅限 OP:只有服务器操作员才能使用
/g 命令
- 命令审查:所有命令在执行前均可审查(除非启用了自动接受)
- 控制台执行:命令以控制台身份运行,拥有完整权限
- 无外部访问:AI 无法访问除 Gemini API 之外的任何外部服务
从源码构建
- 克隆仓库
- 安装 Maven
- 运行:
mvn clean package
- 在
target/GeminiMC-1.0.0.jar 中找到 JAR 文件
构建要求
构建命令
mvn clean package
故障排除
“API key not set” 错误
- 在游戏中运行
/g setapikey YOUR_KEY
- 或者将密钥添加到
config.yml 中
命令未执行
- 确保你是 OP:
/op yourname
- 检查服务器日志是否有错误
- 验证你的 API 密钥是否有效
AI 无响应
- 检查网络连接
- 验证是否可以访问 Gemini API
- 检查服务器控制台的错误消息
“You must be an operator” 提示
- 只有 OP 可以使用此插件
- 请服务器管理员将你设为 OP:
/op yourname
隐私与数据
- 对话历史存储在本地
plugins/GeminiMC/histories/ 目录中
- 问题和上下文会被发送至 Google 的 Gemini API
- 不会向任何其他外部服务发送数据
- 请查阅 Google 的 Gemini API 服务条款
支持
如有问题、疑问或建议:
- 查看上面的故障排除部分
- 查看服务器控制台日志
- 确认你使用的是兼容的 Minecraft 版本(1.21+)
许可证
本插件按“原样”提供,用于服务器管理目的。
致谢
注意:此插件赋予 AI 执行服务器命令的能力。除非你完全信任 AI 的建议,否则在确认前务必仔细审查所有命令。请谨慎使用自动接受模式。
GeminiMC - Gemini AI for Minecraft Server Management
A powerful Minecraft plugin that integrates Google's Gemini AI to help server administrators manage their servers through natural language commands.
Features
- Natural Language Interface: Ask Gemini questions in plain English
- Command Execution: AI can suggest and execute server commands
- Confirmation System: Review commands before execution (or enable auto-accept)
- Conversation Memory: Maintains chat history for context-aware responses
- Server Context: AI has access to server info, player data, and recent chat
- OP-Only Access: Secure - only server operators can use the plugin
- Dual Model Support: Uses Gemini 2.0 Flash for both planning and execution
Requirements
- Minecraft 1.21+ (Spigot/Paper server)
- Java 21 or higher
- Google Gemini API key
Installation
- Download the plugin JAR file
- Place it in your server's
plugins folder
- Restart your server
- Configure your API key (see Setup section)
Setup
Getting a Gemini API Key
- Go to Google AI Studio
- Click "Create API Key"
- Copy your API key
Configuring the Plugin
- In-game, run:
/g setapikey YOUR_API_KEY_HERE
- Or edit
plugins/GeminiMC/config.yml and add your key there
Usage
Basic Commands
/g <question> - Ask Gemini AI a question
/g setapikey <key> - Set your Gemini API key
/g autoaccept <true|false> - Toggle auto-accepting commands
/g clearhistory - Clear conversation history
/g context view - View current server context
/g context clear - Clear recent chat context
/g confirm - Confirm pending commands
/g cancel - Cancel pending commands
/g help - Show help message
Example Usage
Basic Questions
/g how many players are online?
/g what time is it in the overworld?
/g how much memory is the server using?
Server Management
/g give all online players a diamond
/g teleport everyone to spawn
/g change the weather to clear
/g set the time to day in all worlds
Complex Tasks
/g create a new world called "mining" with seed 12345
/g ban player xyz for griefing
/g give op to player abc
Command Confirmation
When Gemini suggests commands, you'll see:
⚠ The AI wants to execute the following commands:
• /give @a diamond 1
• /say Diamonds for everyone!
[CONFIRM] [CANCEL]
Click the buttons or type /g confirm or /g cancel.
Auto-Accept Mode
For trusted operations, enable auto-accept:
/g autoaccept true
Commands will execute immediately without confirmation. Be careful with this mode!
To disable:
/g autoaccept false
How It Works
-
Context Gathering: When you ask a question, the plugin gathers current server information:
- Players online
- World data
- Server performance (TPS, memory)
- Recent chat messages
-
AI Processing: Your question and context are sent to Gemini AI
-
Response Parsing: The AI's response is analyzed for command suggestions
-
Command Execution: If commands are suggested:
- In normal mode: You're asked to confirm
- In auto-accept mode: Commands execute automatically
-
History Tracking: The conversation is saved for future context
Configuration
Edit plugins/GeminiMC/config.yml:
# Your Gemini API key
api-key: ""
# Auto-accept command execution
auto-accept: false
# Maximum chat history to keep
max-history: 50
# Maximum recent chat messages to include in context
max-chat-context: 10
# Gemini API settings
gemini:
planning-model: "gemini-2.0-flash-exp"
execution-model: "gemini-2.0-flash-exp"
api-url: "https://generativelanguage.googleapis.com/v1beta/models/"
Security
- OP-Only: Only server operators can use
/g commands
- Command Review: All commands can be reviewed before execution (unless auto-accept is enabled)
- Console Execution: Commands run as console with full permissions
- No External Access: The AI cannot access external services beyond the Gemini API
Building from Source
- Clone the repository
- Install Maven
- Run:
mvn clean package
- Find the JAR in
target/GeminiMC-1.0.0.jar
Build Requirements
Build Command
mvn clean package
Troubleshooting
"API key not set" error
- Run
/g setapikey YOUR_KEY in-game
- Or add the key to
config.yml
Commands not executing
- Make sure you're an OP:
/op yourname
- Check server logs for errors
- Verify your API key is valid
AI not responding
- Check your internet connection
- Verify the Gemini API is accessible
- Check server console for error messages
"You must be an operator" message
- Only OPs can use this plugin
- Ask a server admin to OP you:
/op yourname
Privacy & Data
- Conversation history is stored locally in
plugins/GeminiMC/histories/
- Questions and context are sent to Google's Gemini API
- No data is sent to any other external service
- Review Google's Gemini API Terms of Service
Support
For issues, questions, or suggestions:
- Check the troubleshooting section above
- Review server console logs
- Check that you're using a compatible Minecraft version (1.21+)
License
This plugin is provided as-is for server management purposes.
Credits
Version
Current version: 1.0.0
Note: This plugin gives AI the ability to execute server commands. Always review commands before confirming unless you fully trust the AI's suggestions. Use auto-accept mode with caution.
评论 0
登录后参与评分
还没有评论,来抢沙发吧