eldboi
πŸ“Ž 1 file 6,173 chars
πŸ“„
pasted-code-1776787749057.txt
txt 141 lines
β–Ά
You are an expert Minecraft plugin developer. Create a production-ready Paper plugin called EliteAIBuilder for Minecraft 1.21.x using Java 21.

GOAL:
Build a stable, optimized, and error-free plugin that lets players define a protected build region with a wand, then use Google Gemini API to generate and physically construct structures inside that region using a real-looking NPC builder that places blocks one by one.

IMPORTANT REQUIREMENTS:
- Server platform: Paper
- Minecraft version: 1.21.x
- Java version: 21
- Plugin name: EliteAIBuilder
- Must be clean, optimized, and free of major bugs
- Must work with a configurable Gemini API key from config.yml
- Must handle errors safely and never crash the server
- Must be compatible with modern Paper API
- Use asynchronous API requests where possible, but all world/block changes must happen on the main thread
- Add clear logging and user-friendly messages

COMMANDS:
1) /EliteAIBuilder wand
   - Gives the player a GOLDEN SWORD
   - This is the region selection wand

2) Left-click with the wand
   - Sets pos1 of the selection

3) Right-click with the wand
   - Sets pos2 of the selection

4) /eliteaibuilder build 
   - Starts an AI building process inside the selected region
   - The plugin must first validate that pos1 and pos2 are set
   - The plugin must draw a square/outline particle border around the selected region
   - The border must visually show the build area
   - Players must not be able to enter or cross into the protected build area while construction is active
   - The region should be protected from player entry during the build using events/region checks
   - Start a builder NPC that looks like a real player and places blocks step by step inside the region
   - The NPC should move naturally as it builds
   - The builder should place blocks in a realistic order, not instantly
   - The build process should be based on the user's prompt and the Gemini API response

GEMINI API INTEGRATION:
- Use Google Gemini API
- Read the API key from config.yml
- Make the API key configurable:
  gemini-api-key: "YOUR_KEY_HERE"
- Also include model name in config:
  gemini-model: "gemini-1.5-flash"
- Send the player's prompt to Gemini and ask it to return a structured build plan
- The response must be parsed safely
- Do not depend on fragile free-form text only; require a structured JSON response from Gemini if possible
- If the Gemini response is invalid, show a helpful error message and stop safely

BUILD LOGIC:
- The plugin should translate the AI response into block placements
- Only build within the selected region
- The build should respect region limits and never place blocks outside the selection
- The builder should be able to place common Minecraft blocks in a safe and controlled way
- If the requested build is too large for the selected region, warn the player
- If the region is too small, reject the build with a clear message
- Keep performance optimized by batching block placements where appropriate
- Do not lag the server

NPC BUILDER:
- The builder must look like a real player
- It should simulate hand block placement
- The NPC should walk around the region naturally while building
- It should not appear like a simple instant fill command
- If full NPC libraries are needed, choose a stable and common solution for Paper 1.21.x
- If a library is required, use a well-known placeholder architecture so it can be swapped easily
- If a true NPC system is too complex, implement a lightweight fake-player builder with visible movement and placement animations, but keep the design extensible

REGION PROTECTION:
- While building, the selected area must be protected
- Players must not enter the region
- Cancel movement or block interactions that cross into the region during the build
- Show particle borders around the region during active building
- Optionally send action bar messages like β€œBuilding in progress...”
- When the build finishes, remove the protection and border

PARTICLE VISUALS:
- Show a square/outline particle frame around the selected region
- Use clear particles that are visible but not annoying
- Update particles when pos1/pos2 changes
- Show a stronger border while build is active

CONFIGURATION:
Create a config.yml with:
- gemini-api-key
- gemini-model
- build-particle
- build-speed
- protect-region-during-build
- max-build-size
- message prefixes
- language/messages

PERMISSIONS:
- eliteaibuilder.wand
- eliteaibuilder.build
- eliteaibuilder.admin

SUGGESTED FEATURES:
- /eliteaibuilder cancel to stop the current build
- /eliteaibuilder reload to reload config
- /eliteaibuilder pos1 and pos2 feedback messages
- /eliteaibuilder status to show current selection and build progress
- Optional progress bar or action bar

CODE QUALITY REQUIREMENTS:
- Use a clean package structure
- Separate command handling, region selection, Gemini service, build planner, NPC builder, particle renderer, and protection manager
- Use defensive programming and null checks
- Handle invalid selections, offline players, missing API keys, and API failures gracefully
- Use asynchronous HTTP for Gemini requests
- Use Bukkit scheduler properly for world changes
- Make the plugin easy to maintain and extend
- Add comments only where useful
- Provide all necessary files:
  - plugin.yml
  - config.yml
  - main plugin class
  - command classes
  - listener classes
  - service classes
  - utility classes

EXPECTED BEHAVIOR:
- /EliteAIBuilder wand gives a gold sword
- Left click with wand sets pos1
- Right click with wand sets pos2
- /eliteaibuilder build  starts AI-based construction inside the selected region
- The region is protected and outlined with particles during the build
- A real-player-like NPC builder constructs the design block by block
- The plugin uses Gemini API reliably
- The plugin must not be buggy, incomplete, or placeholder-only
- The plugin should feel like a polished premium quality build assistant

OUTPUT:
Generate the complete source code for the plugin, ready to compile with Java 21 for Paper 1.21.x.
Include all necessary classes and files.
Make sure the code is organized, efficient, and safe.
Kodari AI
KodariApr 21 at 4:16 pm 34,036 (v2)
EliteAIBuilder
A premium AI-powered building assistant plugin for Paper 1.21.x. Players select a build region using a golden sword wand, then issue natural language prompts to generate structures via the Google Gemini API. The AI response is translated into a sequential block-by-block build plan executed by a visible ArmorStand NPC builder. The active region is particle-outlined and fully protected during construction, with action bar progress updates and clean async/sync threading.

Here’s my build plan before writing any code:

  • ConfigManager exposes getApiKey(), getModel(), getBuildParticle(), getBuildSpeed(), isProtectRegion(), getMaxBuildSize(), getPrefix(), getMessage()

  • RegionManager holds player selections; BuildManager holds active BuildSession objects and exposes isBuildActive(), getActiveBuildRegion(), getActiveSessionOwners(), startBuild(), cancelBuild(), cancelAllBuilds()

  • GeminiService returns CompletableFuture<BuildPlan>; result is consumed back on the main thread via Bukkit.runTask

  • ParticleRenderer returns a BukkitTask for the edge-outline particle loop

  • BuildSession holds region, plan, NPC entity, tasks, and current index β€” no cross-dependency

  • WandListener + RegionProtectionListener use plugin.getBuildManager() which is always initialized before listeners register

The plugin is complete. Here’s a summary of what was built:

  • 16 files across a clean package structure: config, region, gemini, builder, particles, listeners, commands

  • Wand system β€” golden sword with custom name; left-click sets Pos1, right-click sets Pos2 via PlayerInteractEvent

  • Gemini API β€” fully async HttpClient call with structured JSON prompt requesting response_mime_type: application/json; response is defensive-parsed (strips markdown fences, validates bounds, filters air/invalid materials)

  • BuildManager β€” runs a BukkitRunnable on the main thread placing one block per configured tick via XMaterial, moving an invulnerable ArmorStand NPC with a pickaxe to each position as it builds, with live action bar progress

  • ParticleRenderer β€” draws all 12 edges of the cuboid every 10 ticks using XParticle with a configurable particle type

  • RegionProtectionListener β€” cancels PlayerMoveEvent, BlockBreakEvent, and BlockPlaceEvent for any non-owner inside an active build region

  • All block changes happen on the main thread; all Gemini HTTP calls are async with safe main-thread callbacks via Bukkit.runTask

eldboi

recreate super version 1.1.0

πŸ“Ž 1 file 7,012 chars
πŸ“„
pasted-code-1776789732401.txt
txt 176 lines
β–Ά
You are an expert Minecraft plugin developer. Create a production-ready Paper plugin called EliteAIBuilder for Minecraft 1.21.x using Java 21.

GOAL:
Build a stable, optimized, and error-free plugin that lets players define a protected build region with a wand, then use the OpenRouter API to generate and physically construct structures inside that region using a real-looking NPC builder that places blocks step by step.

IMPORTANT REQUIREMENTS:
- Server platform: Paper
- Minecraft version: 1.21.x
- Java version: 21
- Plugin name: EliteAIBuilder
- Must be clean, optimized, and free of major bugs
- Must work with a configurable OpenRouter API key from config.yml
- Must handle errors safely and never crash the server
- Must be compatible with modern Paper API
- Use asynchronous API requests where possible, but all world/block changes must happen on the main thread
- Add clear logging and user-friendly messages

OPENROUTER INTEGRATION:
- Use OpenRouter API instead of Gemini
- Read the API key from config.yml
- Config must include:
  openrouter-api-key: "YOUR_KEY_HERE"
  openrouter-model: "liquid/lfm-2.5-1.2b-thinking:free"
- Send the player's prompt to OpenRouter and ask it to return a structured build plan
- Support streaming responses
- Parse the streamed output safely
- Do not rely only on free-form text; require structured JSON output if possible
- If the response is invalid, show a helpful error message and stop safely

USE THIS OPENROUTER STREAMING ALGORITHM:
Implement the OpenRouter request logic based on this flow:

1) Send a POST request to the OpenRouter chat endpoint.
2) Include headers:
   - Authorization: Bearer 
   - Content-Type: application/json
   - HTTP-Referer: 
   - X-Title: EliteAIBuilder
3) Use model:
   - liquid/lfm-2.5-1.2b-thinking:free
4) Request body should include:
   - model
   - messages
   - stream: true
5) Stream the response chunk by chunk.
6) For each chunk:
   - read chunk.choices[0].delta.content
   - append content to the full response buffer
7) After stream ends:
   - validate the final content
   - parse JSON if JSON was requested
   - if parsing fails, stop with a safe error
8) If streaming fails:
   - automatically retry once or fall back to non-streaming mode
9) All network calls must be async
10) Never block the main server thread

REFERENCE STREAMING LOGIC TO IMPLEMENT IN JAVA:
The plugin should behave like this logic, translated into Java:
- open a streaming HTTP connection to OpenRouter
- continuously read incoming response chunks
- extract delta content from each streamed message
- write the content into a buffer
- when the stream ends, combine all content into one complete response
- convert that response into a build plan object
- continue only if the build plan is valid

COMMANDS:
1) /EliteAIBuilder wand
   - Gives the player a GOLDEN SWORD
   - This is the region selection wand

2) Left-click with the wand
   - Sets pos1 of the selection

3) Right-click with the wand
   - Sets pos2 of the selection

4) /eliteaibuilder build 
   - Starts an AI building process inside the selected region
   - Validate that pos1 and pos2 are set
   - Draw a square/outline particle border around the selected region
   - Show the build area clearly
   - Prevent players from entering or crossing into the protected area while construction is active
   - Use region checks and movement cancellation
   - Start a builder NPC that looks like a real player and places blocks step by step inside the region
   - The NPC should move naturally as it builds
   - The build should be based on the user’s prompt and the OpenRouter response

BUILD LOGIC:
- Convert the AI response into block placements
- Only build within the selected region
- Never place blocks outside the selection
- Respect region limits
- Reject builds that are too large for the region
- Keep performance optimized by batching block placements
- Do not lag the server

NPC BUILDER:
- The builder must look like a real player
- It should simulate hand block placement
- The NPC should walk around naturally while building
- It should not look like a simple instant-fill command
- If a full NPC library is needed, use a stable solution for Paper 1.21.x
- If a true NPC system is too complex, implement a lightweight fake-player builder with visible movement and placement animation, but keep the design extensible

REGION PROTECTION:
- While building, the selected area must be protected
- Players must not enter the region
- Cancel movement or block interactions that cross into the region during the build
- Show particle borders around the region during active building
- Optionally send action bar messages like β€œBuilding in progress...”
- When the build finishes, remove the protection and border

PARTICLE VISUALS:
- Show a square/outline particle frame around the selected region
- Use visible but not annoying particles
- Update particles when pos1/pos2 changes
- Show a stronger border while build is active

CONFIGURATION:
Create a config.yml with:
- openrouter-api-key
- openrouter-model
- build-particle
- build-speed
- protect-region-during-build
- max-build-size
- message prefixes
- language/messages

PERMISSIONS:
- eliteaibuilder.wand
- eliteaibuilder.build
- eliteaibuilder.admin

SUGGESTED FEATURES:
- /eliteaibuilder cancel to stop the current build
- /eliteaibuilder reload to reload config
- /eliteaibuilder pos1 and pos2 feedback messages
- /eliteaibuilder status to show current selection and build progress
- Optional progress bar or action bar

CODE QUALITY REQUIREMENTS:
- Use a clean package structure
- Separate command handling, region selection, OpenRouter service, stream parser, build planner, NPC builder, particle renderer, and protection manager
- Use defensive programming and null checks
- Handle invalid selections, offline players, missing API keys, API failures, and streaming errors gracefully
- Use asynchronous HTTP for OpenRouter requests
- Use Bukkit scheduler properly for world changes
- Make the plugin easy to maintain and extend
- Add comments only where useful
- Provide all necessary files:
  - plugin.yml
  - config.yml
  - main plugin class
  - command classes
  - listener classes
  - service classes
  - utility classes

EXPECTED BEHAVIOR:
- /EliteAIBuilder wand gives a gold sword
- Left click with wand sets pos1
- Right click with wand sets pos2
- /eliteaibuilder build  starts AI-based construction inside the selected region
- The region is protected and outlined with particles during the build
- A real-player-like NPC builder constructs the design block by block
- The plugin uses OpenRouter reliably
- The plugin must not be buggy, incomplete, or placeholder-only
- The plugin should feel like a polished premium quality build assistant

OUTPUT:
Generate the complete source code for the plugin, ready to compile with Java 21 for Paper 1.21.x.
Include all necessary classes and files.
Make sure the code is organized, efficient, and safe.
Kodari AI
KodariApr 21 at 4:44 pm 16,488 (v2)

Let me read all existing files first.

Here’s my plan:

  • Move the gemini package β†’ openrouter, rename GeminiService β†’ OpenRouterService with full streaming support

  • Update ConfigManager and config.yml to use OpenRouter keys/model

  • Update EliteAIBuilder main class field, EliteAIBuilderCommand messages, plugin.yml version to 1.1.0

  • Implement proper OpenRouter streaming (SSE) with retry/non-streaming fallback

Now rewrite OpenRouterService with streaming SSE logic, update all other files:

Here’s a summary of all changes in v1.1.0:

  • gemini β†’ openrouter package: GeminiService renamed to OpenRouterService, BlockPlacement and BuildPlan moved accordingly β€” all references auto-updated

  • OpenRouterService: Full rewrite β€” sends POST to https://openrouter.ai/api/v1/chat/completions with proper headers (Authorization, HTTP-Referer, X-Title), streams SSE chunks line-by-line extracting choices[0].delta.content, falls back to non-streaming on any stream failure, includes JSON fence stripping and bracket-extraction fallback for malformed responses

  • ConfigManager: gemini-api-key / gemini-model keys replaced with openrouter-api-key / openrouter-model

  • config.yml: New keys with default model liquid/lfm-2.5-1.2b-thinking:free

  • plugin.yml: Version bumped to 1.1.0, description updated

  • build.gradle: Added gson:2.10.1 as implementation (Paper bundles it but declaring it ensures compile-time availability)

eldboi
πŸ“Ž 1 file 8,297 chars
πŸ“„
pasted-code-1776790601789.txt
txt 245 lines
β–Ά
You are an expert Minecraft Paper plugin developer. Create a complete, production-ready, error-free plugin called EliteAIBuilder for Minecraft 1.21.1 using Java 21.

GOAL:
Build a stable AI-assisted construction plugin that lets players select a region with a wand, clears that region first, then uses an AI model through OpenRouter to generate a complete block-by-block build plan with coordinates. The plugin must then construct the build step by step in a realistic way using a visible builder NPC or fake-player style builder that places blocks one by one. The build must be smooth, correct, and fully within the selected region.

CORE REQUIREMENTS:
- Server platform: Paper
- Minecraft version: 1.21.1
- Java version: 21
- Plugin name: EliteAIBuilder
- Must be optimized, clean, and stable
- Must not crash the server
- Must use OpenRouter API, not Gemini
- Must support configurable API key and model from config.yml
- Must save build logs into a logs folder automatically
- Must record total build time, total placed blocks, and build status
- Must provide clear error messages for invalid selections, API failures, or build failures
- Must be fully compatible with modern Paper API

WAND AND SELECTION:
- Command: /EliteAIBuilder wand
- Gives the player a GOLDEN_SWORD
- Left click with the wand = set pos1
- Right click with the wand = set pos2
- Show clear feedback messages for pos1 and pos2
- Store selection per player safely
- Support world checks so both points must be in the same world
- Show particles around the selected region

BUILD FLOW:
1) Player selects a region using the wand.
2) Player uses /eliteaibuilder build .
3) Plugin calculates the selected region size and sends region information to the AI automatically.
4) Plugin first clears the selected region completely.
5) Then the AI returns a detailed build plan.
6) The build plan must contain:
   - region coordinates
   - total dimensions
   - total volume
   - list of blocks to place
   - exact x, y, z coordinates for every block
   - block type for every placement
   - build order
7) The plugin must place blocks one by one in a realistic way.
8) After the build finishes, save a log file with:
   - player name
   - prompt
   - region size
   - total blocks placed
   - elapsed time in minutes and seconds
   - success or failure state
   - any errors encountered

AI OUTPUT FORMAT:
The OpenRouter response must be structured JSON. The plugin must validate the response before building.

The AI must return something like this:

{
  "success": true,
  "region": {
    "world": "world",
    "pos1": {"x": 100, "y": 64, "z": 100},
    "pos2": {"x": 120, "y": 74, "z": 120},
    "width": 21,
    "height": 11,
    "length": 21,
    "volume": 4851
  },
  "clear_before_build": true,
  "build_steps": [
    {
      "index": 1,
      "x": 101,
      "y": 64,
      "z": 101,
      "block": "stone_bricks"
    },
    {
      "index": 2,
      "x": 102,
      "y": 64,
      "z": 101,
      "block": "stone_bricks"
    }
  ]
}

AI INSTRUCTIONS:
- The AI must think in build steps, not in paragraphs
- The AI must return every block placement one by one
- Every placement must include exact coordinates and block type
- The AI must never place blocks outside the selected region
- The AI must respect the region size
- The AI must produce a build plan that is valid for Minecraft blocks
- The AI must optimize placement order to look natural and smooth
- The AI should build from ground to top or layer by layer
- The AI should avoid impossible coordinates
- The AI must not use unsupported blocks
- The AI must return valid JSON only, without markdown or explanation

CLEAR REGION FIRST:
Before building, the plugin must:
- remove all blocks inside the selected region
- clear the full build area completely
- keep bedrock or protected world blocks safe if needed
- log the clear action
- only after clearing, start the build plan execution

NPC / BUILDER BEHAVIOR:
- The build should look like a real builder NPC or fake-player builder
- It must not instantly set the whole structure
- It must move naturally and place blocks one by one
- The builder must visually follow the build order
- Use hand-placement style animations if possible
- If a full NPC library is difficult, implement a lightweight fake-player style builder with visible movement and placement animation
- The building must feel like a real construction process
- The NPC should not be idle; it should actively place every block in order
- The NPC should stay inside or near the selected region while building

REGION PROTECTION:
- While building, the selected region must be protected
- Players must not enter or break blocks inside the region while construction is active
- Cancel movement or interactions that attempt to enter the protected area
- Show particle borders around the region during build
- Remove protection after build ends
- Send progress messages to the player

OPENROUTER INTEGRATION:
- Use OpenRouter API instead of Gemini
- Read the API key from config.yml
- Read the model from config.yml
- Use streaming if possible
- If streaming fails, fall back to normal request mode
- Validate all responses safely
- Never freeze the main thread
- Make all HTTP requests asynchronously
- Parse response carefully
- Retry once or twice if the model is temporarily overloaded

CONFIG.YML MUST INCLUDE:
- openrouter-api-key
- openrouter-model
- openrouter-base-url
- build-particle
- build-delay-ticks
- clear-region-before-build
- protect-region-during-build
- max-build-size
- log-folder
- messages

COMMANDS:
1) /EliteAIBuilder wand
   - Gives a golden sword wand

2) /eliteaibuilder build 
   - Starts AI build generation and construction

3) /eliteaibuilder cancel
   - Cancels the current build

4) /eliteaibuilder status
   - Shows current build progress

5) /eliteaibuilder reload
   - Reloads config and messages

PERMISSIONS:
- eliteaibuilder.wand
- eliteaibuilder.build
- eliteaibuilder.cancel
- eliteaibuilder.reload
- eliteaibuilder.admin

BUILD EXECUTION:
- The plugin must convert the AI JSON into an internal build queue
- Blocks must be placed one at a time or in small safe batches
- Each placed block must use the exact coordinates from the AI plan
- The plugin must count how many blocks were placed
- The plugin must measure the elapsed build time
- The plugin must write an automatic log file after each build
- Log files must be saved in a logs folder with a timestamp filename
- Example log file names:
  build-2026-04-21_18-30-00.txt

LOG CONTENT MUST INCLUDE:
- player name
- prompt
- world name
- region coordinates
- size of the region
- total blocks cleared
- total blocks placed
- start time
- end time
- elapsed duration
- success or failure
- error messages if any

CODE QUALITY REQUIREMENTS:
- Use a clean package structure
- Separate command handling, wand selection, AI service, JSON parsing, build planner, build executor, region protection, particle effects, and log writer
- Use defensive programming
- Validate nulls and invalid selections
- Handle missing API key gracefully
- Handle invalid JSON safely
- Handle region too large gracefully
- Handle unsupported blocks gracefully
- Use Bukkit scheduler properly
- Never perform world edits asynchronously
- Use async only for HTTP and parsing preparation
- Keep the code readable and extensible
- Provide complete source code, not partial snippets

EXPECTED RESULT:
- /EliteAIBuilder wand gives a gold sword
- Left click sets pos1
- Right click sets pos2
- /eliteaibuilder build  clears the region first
- Then AI returns a full block-by-block build plan with coordinates
- The builder places blocks one by one in the correct order
- The region is protected during building
- Logs are saved automatically
- Time taken and total blocks placed are recorded
- The plugin works smoothly and professionally

OUTPUT:
Generate the full plugin source code for Paper 1.21.1 with Java 21.
Include all necessary files:
- plugin.yml
- config.yml
- main plugin class
- command classes
- listeners
- AI service class
- JSON parser or mapper
- build executor
- region manager
- protection manager
- particle renderer
- log writer
- utilities

Make sure the final code is complete, compile-ready, and does not contain placeholder-only logic.
Kodari AI
KodariApr 21 at 4:59 pm 21,895 (v2)

Let me read all existing files first.

Now I have a full picture. Here’s what needs to be added/fixed:

  • Missing: Region clear phase before building, log writer, build timing/logging, prompt passed to startBuild

  • Missing: LogWriter class, clearTask in session, clear-region-before-build/log-folder in config

  • Missing: eliteaibuilder.cancel and eliteaibuilder.status permissions in plugin.yml

Here’s a summary of every change made:

  • LogWriter (new) β€” writes timestamped .txt log files to the configured log-folder with player name, prompt, world, region coords/size, blocks cleared, blocks placed, start/end time, duration, and success/failure status

  • BuildSession β€” added prompt, startTime, blocksCleared, and clearTask fields with Lombok getters/setters

  • BuildManager β€” added startClearPhase() that batch-clears 500 blocks/tick with action bar progress before handing off to startBuildPhase(); both phases now call LogWriter on completion/cancellation; startBuild accepts prompt as a 4th argument

  • EliteAIBuilder β€” registered LogWriter as a plugin field with @Getter

  • ConfigManager β€” added getBaseUrl(), isClearRegion(), getLogFolder(), and renamed getBuildSpeed() to read build-delay-ticks

  • EliteAIBuilderCommand β€” passes prompt to startBuild

  • config.yml β€” added openrouter-base-url, clear-region-before-build, log-folder; renamed build-speed β†’ build-delay-ticks

  • plugin.yml β€” added eliteaibuilder.cancel and eliteaibuilder.status permissions

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
17 1,499
src/main/java/com/eliteaibuilder/EliteAIBuilder.java
package com.eliteaibuilder;

import com.eliteaibuilder.builder.BuildManager;
import com.eliteaibuilder.commands.EliteAIBuilderCommand;
import com.eliteaibuilder.config.ConfigManager;
import com.eliteaibuilder.logging.LogWriter;
import com.eliteaibuilder.openrouter.OpenRouterService;
import com.eliteaibuilder.listeners.RegionProtectionListener;
import com.eliteaibuilder.listeners.WandListener;
import com.eliteaibuilder.particles.ParticleRenderer;
import com.eliteaibuilder.region.RegionManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

public class EliteAIBuilder extends JavaPlugin {

    @Getter private static EliteAIBuilder instance;

    @Getter private ConfigManager configManager;
    @Getter private RegionManager regionManager;
    @Getter private OpenRouterService openRouterService;
    @Getter private ParticleRenderer particleRenderer;
    @Getter private BuildManager buildManager;
    @Getter private LogWriter logWriter;

    @Override
    public void onEnable() {
        instance = this;
        saveDefaultConfig();

        this.configManager = new ConfigManager(this);
        this.regionManager = new RegionManager();
        this.openRouterService = new OpenRouterService(this);
        this.particleRenderer = new ParticleRenderer(this);
        this.logWriter = new LogWriter(this);
        this.buildManager = new BuildManager(this);

        EliteAIBuilderCommand commandHandler = new EliteAIBuilderCommand(this);
        getCommand("eliteaibuilder").setExecutor(commandHandler);
        getCommand("eliteaibuilder").setTabCompleter(commandHandler);

        getServer().getPluginManager().registerEvents(new WandListener(this), this);
        getServer().getPluginManager().registerEvents(new RegionProtectionListener(this), this);

        getLogger().info("EliteAIBuilder enabled successfully.");
    }

    @Override
    public void onDisable() {
        if (buildManager != null) {
            buildManager.cancelAllBuilds();
        }
        getLogger().info("EliteAIBuilder disabled.");
    }
}