RA-AIChat

Chat with a Gemini AI from inside Minecraft using /ai, with a topic-limiting system prompt, per-player conversation memory in SQLite, async requests, and cooldowns.

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 &#RRGGBB colors

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-pairs controls 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

  1. Place RA-AIChat.jar into your plugins/ folder
  2. Start the server once to generate plugins/RA-AIChat/config.yml
  3. Put your Gemini key into gemini.api-key
  4. Optionally change gemini.model and edit system-prompt.txt
  5. Run /ai admin reload or restart the server
  6. Give the raaichat.use permission 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

CommandDescriptionAccess
/ai <question>Ask the AI a questionraaichat.use
/ai admin reloadReload the config and system promptraaichat.admin

Permissions

PermissionDefaultDescription
raaichat.usefalseUse /ai
raaichat.adminopUse /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