ifung-0
📎 1 file 3,077 chars
📄
pasted-code-1770199095386.txt
txt 56 lines
▶
Here is a refined, optimized prompt designed for AI coding assistants (like ChatGPT-4, Claude 3.5 Sonnet, or Cursor). I have structured it to ensure the AI understands the logic, the configuration requirements, and the specific INVENTORY GUI mechanics.

***

**Copy and Paste this into your AI:**

```markdown
**Role:** Act as a Senior Minecraft Java Plugin Developer specializing in Spigot/Paper API (Version 1.20+).

**Project Name:** ChaosVote

**Objective:** Create a plugin that automatically triggers a "Chaos Vote" every 30 minutes, allowing players to vote on random server-wide events via a INVENTORY GUI.

**Key Specifications:**

1.  **Automatic Cycle:**
    -   Run a repeating task that triggers a vote every X minutes (default 30).
    -   When triggered, pause any active event from the previous round.

2.  **Voting INVENTORY GUI:**
    -   Open a custom Inventory (e.g., size 27 or 54) for every online player.
    -   **Title:** Must include a countdown timer (e.g., "Vote: 29s remaining").
    -   **Layout:** Display 4 randomized event options as items in the center slots. Fill empty slots with gray stained glass pane.
    -   **Interaction:** When a player clicks an event item:
        -   Register their vote for that specific event.
        -   Play a click sound.
        -   Update the item Lore to show current vote counts (real-time updates).
    -   Allow players to change their vote by clicking a different option.

3.  **Event Execution:**
    -   After the timer (default 30s) ends, calculate the winner.
    -   Announce the winner in the chat with a bold, formatted message (e.g., `&c&lCHAOS! &fThe event TNT Rain has begun!`).
    -   Apply the event effects for a set duration (e.g., 5 minutes), then clean up/revert changes.

4.  **Event List (Implement at least 5):**
    -   `TNT_STORM`: Spawn primed TNT above random players every 5 seconds.
    -   `LOW_GRAVITY`: Apply Jump Boost X to all players.
    -   `SPEED_DEMON`: Apply Speed V and Haste III to all players.
    -   `SPOILED_LOOT`: Shuffle the hotbar inventory of all players randomly.
    -   `DIAMOND_RAIN`: Drop diamond items at random coordinates around the world.
    -   `HALF_HEALTH`: Set max health of all players to 4 hearts.

5.  **Configuration (`config.yml`):**
    -   `vote_interval`: Time between votes (in minutes).
    -   `voting_duration`: Time players have to vote (in seconds).
    -   `event_duration`: How long the event lasts (in minutes).
    -   `events_enabled`: A list to toggle specific events on/off.

6.  **Code Structure Requirements:**
    -   Use an `Enum` or a Manager class to handle different events easily so I can add more later.
    -   Include a `plugin.yml` with the command `/chaosvote` (alias: `/cv`) which allows admins to force-start a vote.
    -   Use `HashMap` to track who voted for what.
    -   Ensure thread safety (run tasks on the main scheduler).

**Output:** Please provide the full Java source code, the `plugin.yml`, and a sample `config.yml`.
```
Kodari AI
KodariFeb 4 at 10:00 am 13,021 (v2)

I’ll create a comprehensive chaos voting plugin with an interactive inventory GUI system and real-time vote tracking.

ChaosVote
An automated chaos voting system that periodically presents players with random server-wide events through an interactive GUI. Players vote for their preferred chaos event, and the winning event is executed with configurable durations and effects. Features real-time vote tracking, countdown timers, and customizable event pools with six unique chaos events including TNT storms, gravity modifications, and inventory manipulation.

Created complete ChaosVote plugin with:

  • Automatic voting system - Triggers every 30 minutes (configurable)

  • Interactive GUI - Real-time countdown timer in inventory title, 4 random event options, vote counts update live in item lore

  • 6 Chaos Events - TNT Storm, Low Gravity, Speed Demon, Spoiled Loot, Diamond Rain, Half Health

  • Thread-safe tracking - HashMap<UUID, ChaosEvent> for vote storage

  • Smart GUI updates - Title refreshes every second, vote counts update across all viewers instantly

  • Event cleanup - Proper restoration (e.g., Half Health restores original max health)

  • Admin command - /chaosvote or /cv to force-start votes

  • Full configuration - All intervals, durations, and event toggles in config.yml

All cross-version compatibility handled through XSeries (XMaterial, XSound, XPotion).

ifung-0

add some commends for admins to edit the duration, skip vote and start vote instantly and add perrmission for luckperms

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
15 933
src/main/java/com/chaosvote/ChaosVote.java
package com.chaosvote;

import com.chaosvote.command.ChaosVoteCommand;
import com.chaosvote.config.ConfigManager;
import com.chaosvote.event.EventManager;
import com.chaosvote.inventory.gui.GUIListener;
import com.chaosvote.inventory.gui.GUIManager;
import com.chaosvote.vote.VoteManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

@Getter
public class ChaosVote extends JavaPlugin {
    private ConfigManager configManager;
    private GUIManager guiManager;
    private VoteManager voteManager;
    private EventManager eventManager;
    private BukkitTask autoVoteTask;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        this.guiManager = new GUIManager();
        this.eventManager = new EventManager(this);
        this.voteManager = new VoteManager(this);
        
        Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
        
        getCommand("chaosvote").setExecutor(new ChaosVoteCommand(this));
        
        startAutoVoting();
        
        getLogger().info("ChaosVote enabled successfully!");
    }

    @Override
    public void onDisable() {
        if (autoVoteTask != null) {
            autoVoteTask.cancel();
        }
        eventManager.stopCurrentEvent();
        getLogger().info("ChaosVote disabled!");
    }

    public void startAutoVoting() {
        if (autoVoteTask != null) {
            autoVoteTask.cancel();
        }
        
        long intervalTicks = configManager.getVoteInterval() * 60 * 20L;
        
        autoVoteTask = Bukkit.getScheduler().runTaskTimer(this, () -> {
            voteManager.startVote();
        }, intervalTicks, intervalTicks);
    }

    public void forceVote() {
        voteManager.startVote();
    }
}