azuolasbur

Develop an AI Agent plugin that allows players to generate complex structures with a single command, such as /aigenerate x1 y1 z1 x2 y2 z2 make a medieval house. Integrate the Gemini 2.5 Flash API to handle the building requests, allowing customization of structure types, dimensions, and styles. Include permissions for different player ranks and a cooldown system to prevent spam.

Kodari AI
KodariApr 18 at 8:37 pm 11,906 (v2)

I’ll create an AI-powered structure generation plugin that integrates with the Gemini 2.5 Flash API.

AIAgentBuilder
An AI-powered structure generation plugin that uses Gemini 2.5 Flash API to create complex buildings from natural language prompts. Players use /aigenerate with coordinates and descriptions to generate medieval houses, castles, modern buildings, and more. Features permission-based access tiers, cooldown management, rate limiting, and asynchronous building to prevent server lag. Supports cross-version compatibility through XSeries.

Perfect! I’ve created a complete AI-powered structure generation plugin with the following features:

Core Features:

  • /aigenerate x1 y1 z1 x2 y2 z2 <prompt> command to generate structures

  • Gemini 2.5 Flash API integration for natural language processing

  • Three permission tiers (basic/premium/unlimited) with different size limits

  • Cooldown system with bypass permissions

  • Asynchronous building to prevent server lag

  • Cross-version compatibility through XSeries

Key Components:

  1. GeminiAPIClient - Handles API calls with proper JSON formatting and response parsing

  2. StructureBuilder - Places blocks gradually (50/tick default) to avoid lag

  3. CooldownManager - Permission-based cooldown times (120s/60s/0s)

  4. PermissionManager - Validates structure dimensions against player tier limits

  5. ConfigManager - Centralized configuration management

Permission Tiers:

  • Basic (default): 10x10x10, 120s cooldown

  • Premium: 30x30x30, 60s cooldown

  • Unlimited: 100x100x100, no cooldown

Setup Instructions:

  1. Get a Gemini API key from Google AI Studio

  2. Add it to config.yml under gemini.api-key

  3. Adjust limits and cooldowns as needed

Example Usage:

Plain Text
/aigenerate 100 64 200 120 80 220 make a medieval stone house with a wooden roof
/aigen 0 70 0 15 85 15 create a modern glass tower

The plugin handles API errors gracefully, validates all inputs, and provides clear feedback to players throughout the generation process.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
12 800
src/main/java/com/aiagent/AIAgentPlugin.java
package com.aiagent;

import com.aiagent.api.GeminiAPIClient;
import com.aiagent.builder.StructureBuilder;
import com.aiagent.command.GenerateCommand;
import com.aiagent.config.ConfigManager;
import com.aiagent.manager.CooldownManager;
import com.aiagent.manager.PermissionManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class AIAgentPlugin extends JavaPlugin {
    private ConfigManager configManager;
    private GeminiAPIClient geminiAPIClient;
    private CooldownManager cooldownManager;
    private PermissionManager permissionManager;
    private StructureBuilder structureBuilder;

    @Override
    public void onEnable() {
        this.configManager = new ConfigManager(this);
        this.geminiAPIClient = new GeminiAPIClient(this);
        this.cooldownManager = new CooldownManager(this);
        this.permissionManager = new PermissionManager(this);
        this.structureBuilder = new StructureBuilder(this);

        getCommand("aigenerate").setExecutor(new GenerateCommand(this));

        getLogger().info("AIAgentBuilder has been enabled!");
        
        if (configManager.getApiKey().equals("YOUR_GEMINI_API_KEY_HERE")) {
            getLogger().warning("Please set your Gemini API key in config.yml!");
        }
    }

    @Override
    public void onDisable() {
        if (structureBuilder != null) {
            structureBuilder.cancelAllBuilds();
        }
        getLogger().info("AIAgentBuilder has been disabled!");
    }
}