_fizz4r
📎 1 file 5,062 chars
📄
pasted-code-1791709069035.txt
txt 74 lines
▶
Create a complete Minecraft Paper plugin called DragonAnnounce for Minecraft 26.3 (Java).

Use the latest Paper API that matches 26.3 and the Java version Paper requires for it. Set api-version in plugin.yml to match 26.3. Do not use deprecated or removed methods. If an API method has changed, use the current one and add a short comment.

The plugin has ONLY two features: automatically announcing who killed the Ender Dragon, and automatically announcing who picked up the Dragon Egg. Do NOT add a timed/repeating announcer, an /announce command, or any other announcement feature.

=== 1. ENDER DRAGON KILL ANNOUNCEMENT ===
- Listen for EntityDeathEvent where the entity is an EnderDragon.
- Find the killer with getKiller(). If there is no direct killer (bed explosion, end crystal, dispenser, etc.), fall back to the player who dealt the most damage to the dragon, tracked with EntityDamageByEntityEvent (include projectiles).
- Broadcast to the whole server automatically. Default message:
  "&5&l[DRAGON SLAIN] &d{player} &7has defeated the Ender Dragon in &e{world}&7!"
- Also: show a title/subtitle to all players, play a configurable sound to everyone, and spawn fireworks at the killer's location.
- Placeholders: {player}, {world}, {kill_count}, {time_taken}.
- Save each player's dragon kill count in data.yml.
- Reset damage tracking when the dragon dies.
- If this feature is turned off, still keep tracking kill counts, but send no announcement.

=== 2. DRAGON EGG PICKUP ANNOUNCEMENT ===
- Automatically detect a player getting the Dragon Egg from:
  - the ground (EntityPickupItemEvent)
  - a chest or other container (InventoryClickEvent, including shift-click and hotbar swaps)
  - hoppers and other inventory moves where relevant
- Broadcast to the whole server. Default message:
  "&6&l[DRAGON EGG] &e{player} &7now holds the Dragon Egg!"
- Per-player cooldown (configurable, in seconds) so dropping and re-picking it up doesn't spam chat.
- Optional announcements (each with its own toggle, off by default): egg dropped, egg placed as a block, egg lost, holder died.
- Optional glowing effect on the current holder (toggle in config).
- Save the current holder and last known location in data.yml.
- Do not announce on player join unless the holder actually changed.
- If this feature is turned off, still track the holder silently so /dragonegg stays accurate.

=== 3. TURN ON/OFF CONTROLS ===
- /dragonannounce toggle: turn the WHOLE plugin's announcements on or off.
- /dragonannounce toggle dragon: turn only the dragon kill announcement on or off.
- /dragonannounce toggle egg: turn only the egg announcements on or off.
- /dragonannounce status: show whether the plugin, dragon announcement, and egg announcement are currently ON or OFF.
- /dragonannounce mute: lets any player hide the announcements for themselves only (toggle). Save each player's choice in data.yml.
- Toggle states are saved to data.yml (or written back to config.yml) so they persist after restart.
- Every toggle sends a clear confirmation message, e.g. "&aDragon announcements are now &lON".
- The same on/off switches must also exist in config.yml (master enabled, dragon-kill enabled, egg-pickup enabled) so it can be disabled without commands.

=== 4. COMMANDS AND PERMISSIONS ===
- /dragonegg: show who currently holds the Dragon Egg (or the last known location)
- /dragonannounce reload: reload config.yml
- /dragonannounce toggle [dragon|egg], /dragonannounce status, /dragonannounce mute (as above)
- Permissions:
  - dragonannounce.admin (reload, toggle, status)
  - dragonannounce.mute (/dragonannounce mute, default true)
  - dragonannounce.dragonegg (/dragonegg, default true)
- Add tab completion for all commands and subcommands.

=== 5. CONFIG (config.yml) ===
- Every message, sound, title, and cooldown must be editable.
- Separate on/off toggles for: master plugin switch, dragon kill announcement, egg pickup announcement, egg drop/lost announcements, glowing effect, fireworks.
- Support color codes (&a, &l, etc.) and hex colors (&#RRGGBB) in all messages.
- Configurable prefix.
- Add clear comments above every option.
- Put all messages in a messages section so they are easy to translate.

=== 6. CODE REQUIREMENTS ===
- Clean package structure: main, listeners, commands, managers, utils.
- Use a message utility class for colors, hex colors, and placeholders.
- Use a ToggleManager class to hold and save all on/off states.
- Save persistent data in data.yml (kill counts, egg holder, egg location, toggle states, muted players).
- Handle errors safely (null checks, invalid config values fall back to defaults).
- Comment every class and the main methods.

=== 7. OUTPUT ===
Provide every file in full, with the path of each file shown above its code:
- pom.xml (or build.gradle)
- src/main/resources/plugin.yml
- src/main/resources/config.yml
- All Java classes
Then give short build instructions (how to compile the .jar and where to put it on the server).
Kodari AI
KodariOct 11 at 9:06 am 3
DragonAnnounce
Automatically announces Ender Dragon kills and Dragon Egg pickups on Paper servers. Tracks killer via damage attribution, broadcasts configurable messages with titles, sounds, and fireworks, saves kill counts and egg holder data, supports per-player muting, toggleable features, and full config customization with hex colors and placeholders.
  1. Create the Paper 26.3/Java 25 Gradle project and plugin configuration.

  2. Implement dragon kill tracking/announcements, egg holder tracking, persistence, toggles, commands, and colorized messages.

Created DragonAnnounce for Paper 26.3 / Java 25, with dragon kill tracking and announcements, Dragon Egg holder tracking, persisted toggles and player mutes, and both commands.

To get the jar: click Compile in the desktop top bar (or ⋮ → Compile Project on mobile), then click Compile and Download. Put the downloaded jar in your server’s plugins folder and restart the server.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
12 1,188
src/main/java/com/kodari/dragonannounce/DragonAnnouncePlugin.java
package com.kodari.dragonannounce;

import com.kodari.dragonannounce.commands.DragonAnnounceCommand;
import com.kodari.dragonannounce.commands.DragonEggCommand;
import com.kodari.dragonannounce.listeners.DragonListener;
import com.kodari.dragonannounce.listeners.EggListener;
import com.kodari.dragonannounce.managers.DragonManager;
import com.kodari.dragonannounce.managers.EggManager;
import com.kodari.dragonannounce.managers.ToggleManager;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;

/** Main plugin entry point; creates managers, loads persistence, and registers commands and listeners. */
public final class DragonAnnouncePlugin extends JavaPlugin {
    private File dataFile;
    private FileConfiguration data;
    private ToggleManager toggleManager;
    private DragonManager dragonManager;
    private EggManager eggManager;

    /** Loads configuration and persistent state, then enables listeners and commands. */
    @Override
    public void onEnable() {
        saveDefaultConfig();
        dataFile = new File(getDataFolder(), "data.yml");
        data = YamlConfiguration.loadConfiguration(dataFile);

        toggleManager = new ToggleManager(this);
        toggleManager.load();
        dragonManager = new DragonManager(this);
        eggManager = new EggManager(this);

        Bukkit.getPluginManager().registerEvents(new DragonListener(dragonManager), this);
        Bukkit.getPluginManager().registerEvents(new EggListener(eggManager), this);

        DragonAnnounceCommand announceCommand = new DragonAnnounceCommand(this);
        if (getCommand("dragonannounce") != null) {
            getCommand("dragonannounce").setExecutor(announceCommand);
            getCommand("dragonannounce").setTabCompleter(announceCommand);
        }
        DragonEggCommand eggCommand = new DragonEggCommand(this);
        if (getCommand("dragonegg") != null) {
            getCommand("dragonegg").setExecutor(eggCommand);
            getCommand("dragonegg").setTabCompleter(eggCommand);
        }
    }

    /** Saves tracked state and removes the plugin-managed holder glow when the plugin stops. */
    @Override
    public void onDisable() {
        if (eggManager != null) {
            eggManager.shutdown();
        }
        saveData();
    }

    /** Returns the loaded persistent data configuration. */
    public FileConfiguration data() {
        return data;
    }

    /** Persists all current player and toggle state to data.yml. */
    public void saveData() {
        if (data == null || dataFile == null) {
            return;
        }
        try {
            data.save(dataFile);
        } catch (IOException exception) {
            getLogger().severe("Could not save data.yml: " + exception.getMessage());
        }
    }

    /** Returns the switch manager. */
    public ToggleManager toggles() {
        return toggleManager;
    }

    /** Returns the dragon kill tracker and announcer. */
    public DragonManager dragons() {
        return dragonManager;
    }

    /** Returns the egg holder tracker and announcer. */
    public EggManager eggs() {
        return eggManager;
    }
}