RA-AIChat
Author: RajaAditya Website: rajaaditya.my.id Version: 1.0.0 API: Paper 1.21.x
Features
Ask the AI In Game
/ai <question>sends the question to the Google Gemini API and prints the answer in chat- Replies use a configurable prefix and support both legacy
&and hex&#RRGGBBcolors
Rules Without Rebuilding
- What the AI is allowed to talk about, its tone, format, and server info live in
system-prompt.txt, not in code - The default prompt keeps the AI on Minecraft gameplay questions and politely declines anything else
- Change the file and run
/ai admin reload, no rebuild needed
Conversation Memory
- Each player's chat history is stored in SQLite (
history.db), by UUID, so the AI remembers earlier questions even after a restart or a name change history.max-pairscontrols how many recent question and answer pairs are sent as context
Safe for the Server
- Requests to Gemini and database access run asynchronously, so they never lag the main thread
- A per-player cooldown prevents spam (default 10 seconds)
- If the API key is empty, a warning is printed and players get an error message
Dependencies
None. You need a Gemini API key, which is free from Google AI Studio.
Installation
- Place
RA-AIChat.jarinto yourplugins/folder - Start the server once to generate
plugins/RA-AIChat/config.yml - Put your Gemini key into
gemini.api-key - Optionally change
gemini.modeland editsystem-prompt.txt - Run
/ai admin reloador restart the server - Give the
raaichat.usepermission to the players who may use it
Keep your API key private. Do not commit config.yml to a public repository.
File Structure
text
1
plugins/RA-AIChat/
├── config.yml # API key, model, history, cooldown, messages
├── system-prompt.txt # The AI's rules and topic limits
└── history.db # SQLite conversation history
Configuration
config.yml
yaml
1
gemini:
api-key: "YOUR_GEMINI_API_KEY"
model: "gemini-3.5-flash-lite"
history:
enabled: true
max-pairs: 10 # recent question/answer pairs sent as context
cooldown-seconds: 10
messages:
prefix: "&b[AI] &f"
thinking: "&7Thinking..."
cooldown: "&cWait {time} more seconds before asking again."
error: "&cSomething went wrong contacting the AI. Try again later."
no-args: "&cUse: /ai <question>"
reload-success: "&aRA-AIChat config reloaded."
no-permission: "&cYou do not have permission for this command."
Commands
| Command | Description | Access |
|---|---|---|
/ai <question> | Ask the AI a question | raaichat.use |
/ai admin reload | Reload the config and system prompt | raaichat.admin |
Permissions
| Permission | Default | Description |
|---|---|---|
raaichat.use | false | Use /ai |
raaichat.admin | op | Use /ai admin reload |
raaichat.use pairs well with RA-JoinBenefits, which can hand out a temporary trial of this permission to new players.
License
Developed by RajaAditya — rajaaditya.my.id