Lakshay Ahlawat

Create a completely NEW Minecraft Paper plugin from scratch called "Events".

Target:

  • Paper 1.21.11
  • Java
  • No external dependencies
  • Use Paper/Bukkit API + Adventure MiniMessage

PURPOSE:

This is a simple vanilla-style SMP event announcement plugin specifically for an End War event.

================================================== PLUGIN INFORMATION ==================================================

Plugin name: Events Main feature: End War event BossBar + screen announcements

Commands:

/endwar start /endwar stop /endwar status /endwar reload

Permission: endwar.admin

================================================== /ENDWAR START ==================================================

When an admin runs:

/endwar start

Do ALL of the following:

  1. Show a BossBar to every online player.

BossBar text:

<gradient:#ff0000:#ffcc00><bold>⚔ END WAR — SEASON 2</bold></gradient>

BossBar:

  • Style: SOLID
  • Actual BossBar color: RED
  • Progress: 100%
  • No timer
  • Remains visible until End War is stopped
  1. Show a large Title to every online player:

Title: <gradient:#ff0000:#ffcc00><bold>⚔ END WAR STARTED!</bold></gradient>

Subtitle: <aqua><bold>SEASON 2</bold></aqua> <white>FINALE</white>

  1. Send chat announcement:

<red>⚔</red> <dark_red><bold>END WAR</bold></dark_red> <gold>has officially started!</gold>

  1. Play:

ENTITY_ENDER_DRAGON_GROWL

to every online player.

================================================== /ENDWAR STOP ==================================================

When an admin runs:

/endwar stop

Do ALL of the following:

  1. Remove the BossBar from every player.
  1. Show:

Title: <gradient:#8b0000:#ff0000><bold>⚔ END WAR ENDED!</bold></gradient>

Subtitle: <gold><bold>SEASON 2</bold></gold> <white>has come to an end.</white>

  1. Send:

<red>⚔</red> <dark_red><bold>END WAR</bold></dark_red> <gold>has officially ended!</gold>

  1. Play:

UI_TOAST_CHALLENGE_COMPLETE

================================================== PLAYER JOIN ==================================================

If End War is already active and a player joins:

  • Automatically show them the current BossBar.
  • Do NOT show the start Title.
  • Do NOT play the start sound.
  • Do NOT send the start chat announcement.

================================================== DUPLICATE PROTECTION ==================================================

If /endwar start is used while End War is already active:

<yellow>⚔ End War is already active!</yellow>

Do not create another BossBar.

If /endwar stop is used while End War is inactive:

<gray>⚔ End War is not currently active.</gray>

================================================== STATUS ==================================================

/endwar status

If active:

<green>⚔ <bold>End War</bold> is currently ACTIVE.</green>

If inactive:

<gray>⚔ <bold>End War</bold> is currently INACTIVE.</gray>

================================================== RELOAD ==================================================

/endwar reload

Must reload config.yml without restarting the server.

If End War is active:

  • Remove the old BossBar.
  • Reload config.
  • Recreate the BossBar using the new configuration.
  • Apply all new colors/text immediately.

================================================== CONFIG.YML ==================================================

Create a complete config.yml.

EVERY text must be configurable.

Use Adventure MiniMessage for ALL text.

The following must support MiniMessage:

  • BossBar text
  • Start title
  • Start subtitle
  • Start chat
  • Stop title
  • Stop subtitle
  • Stop chat
  • All command messages

Default config:

bossbar: enabled: true text: "<gradient:#ff0000:#ffcc00><bold>⚔ END WAR — SEASON 2</bold></gradient>" color: RED style: SOLID

start: title: "<gradient:#ff0000:#ffcc00><bold>⚔ END WAR STARTED!</bold></gradient>" subtitle: "<aqua><bold>SEASON 2</bold></aqua> <white>FINALE</white>" chat: "<red>⚔</red> <dark_red><bold>END WAR</bold></dark_red> <gold>has officially started!</gold>"

fade-in: 10 stay: 70 fade-out: 20

sound: enabled: true type: "ENTITY_ENDER_DRAGON_GROWL" volume: 1.0 pitch: 1.0

stop: title: "<gradient:#8b0000:#ff0000><bold>⚔ END WAR ENDED!</bold></gradient>" subtitle: "<gold><bold>SEASON 2</bold></gold> <white>has come to an end.</white>" chat: "<red>⚔</red> <dark_red><bold>END WAR</bold></dark_red> <gold>has officially ended!</gold>"

fade-in: 10 stay: 70 fade-out: 20

sound: enabled: true type: "UI_TOAST_CHALLENGE_COMPLETE" volume: 1.0 pitch: 1.0

messages: no-permission: "<red>You don't have permission to use this command.</red>" already-active: "<yellow>⚔ End War is already active!</yellow>" not-active: "<gray>⚔ End War is not currently active.</gray>" started: "<green>✓ End War started successfully.</green>" stopped: "<green>✓ End War stopped successfully.</green>" reloaded: "<aqua>✓ Events configuration reloaded.</aqua>" status-active: "<green>⚔ <bold>End War</bold> is currently ACTIVE.</green>" status-inactive: "<gray>⚔ <bold>End War</bold> is currently INACTIVE.</gray>"

permissions: admin: "endwar.admin"

================================================== COLOR REQUIREMENT ==================================================

IMPORTANT:

Use Adventure MiniMessage.deserialize() for EVERY configurable text.

Do NOT use plain Bukkit ChatColor translation as the primary parser.

MiniMessage tags must NEVER appear literally to players.

Support:

  • <red>
  • <dark_red>
  • <gold>
  • <yellow>
  • <aqua>
  • <blue>
  • <green>
  • <white>
  • <gray>
  • <bold>
  • <italic>
  • <gradient:#hex:#hex>

Gradient text must actually render as a gradient.

================================================== PROJECT FILES ==================================================

Provide the complete project:

Events/ ├── pom.xml ├── src/main/resources/ │ ├── plugin.yml │ └── config.yml └── src/main/java/ └── [package]/ └── Events.java

Include ALL required code.

The project must compile successfully for Paper 1.21.11 without modifications.

Keep the plugin lightweight and clean.

Do not add any unnecessary features.

Kodari AI
KodariSep 26 at 3:58 pm 1
EndWarAnnouncer
A lightweight Paper plugin for SMP End War events. Provides admin commands (/endwar start, stop, status, reload) with permission endwar.admin. Displays gradient BossBars, titles, subtitles, and chat announcements to all online players. Automatically shows active BossBar to joining players. Fully configurable via config.yml using Adventure MiniMessage for all text, colors, sounds, and timing. Includes duplicate protection and live config reload without restart.

I’ll create the Maven project, Paper descriptor, default configuration, and the End War command/listener implementation.

Created the Events Maven project with Paper 1.21.11 metadata, the full configurable MiniMessage config, and the /endwar start, stop, status, and reload implementation. It includes persistent BossBar handling, join behavior, announcements, sounds, and the endwar.admin permission.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
4 302
src/main/java/com/kodari/events/Events.java
package com.kodari.events;

import java.time.Duration;
import java.util.Locale;
import net.kyori.adventure.bossbar.BossBar;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.title.Title;

public final class Events extends JavaPlugin implements CommandExecutor, Listener {
    private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage();
    private static final String DEFAULT_BOSSBAR_TEXT = "<gradient:#ff0000:#ffcc00><bold>⚔ END WAR — SEASON 2</bold></gradient>";

    private BossBar bossBar;
    private boolean active;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        getCommand("endwar").setExecutor(this);
        getServer().getPluginManager().registerEvents(this, this);
    }

    @Override
    public void onDisable() {
        removeBossBar();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        String permission = getConfig().getString("permissions.admin", "endwar.admin");
        if (!sender.hasPermission(permission)) {
            send(sender, "messages.no-permission", "<red>You don't have permission to use this command.</red>");
            return true;
        }

        if (args.length != 1) {
            send(sender, "messages.usage", "<yellow>Usage: /endwar start, stop, status, or reload</yellow>");
            return true;
        }

        switch (args[0].toLowerCase(Locale.ROOT)) {
            case "start" -> start(sender);
            case "stop" -> stop(sender);
            case "status" -> send(sender, active ? "messages.status-active" : "messages.status-inactive",
                    active ? "<green>⚔ <bold>End War</bold> is currently ACTIVE.</green>"
                            : "<gray>⚔ <bold>End War</bold> is currently INACTIVE.</gray>");
            case "reload" -> reload(sender);
            default -> send(sender, "messages.usage", "<yellow>Usage: /endwar start, stop, status, or reload</yellow>");
        }
        return true;
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        if (active && bossBar != null) {
            event.getPlayer().showBossBar(bossBar);
        }
    }

    private void start(CommandSender sender) {
        if (active) {
            send(sender, "messages.already-active", "<yellow>⚔ End War is already active!</yellow>");
            return;
        }

        active = true;
        createBossBar();
        announce("start");
        send(sender, "messages.started", "<green>✓ End War started successfully.</green>");
    }

    private void stop(CommandSender sender) {
        if (!active) {
            send(sender, "messages.not-active", "<gray>⚔ End War is not currently active.</gray>");
            return;
        }

        active = false;
        removeBossBar();
        announce("stop");
        send(sender, "messages.stopped", "<green>✓ End War stopped successfully.</green>");
    }

    private void reload(CommandSender sender) {
        boolean wasActive = active;
        removeBossBar();
        reloadConfig();
        if (wasActive) {
            createBossBar();
        }
        send(sender, "messages.reloaded", "<aqua>✓ Events configuration reloaded.</aqua>");
    }

    private void createBossBar() {
        removeBossBar();
        if (!getConfig().getBoolean("bossbar.enabled", true)) {
            return;
        }

        BossBar.Color color = enumValue(BossBar.Color.class, getConfig().getString("bossbar.color", "RED"), BossBar.Color.RED);
        BossBar.Overlay overlay = switch (getConfig().getString("bossbar.style", "SOLID").toUpperCase(Locale.ROOT)) {
            case "SEGMENTED_6" -> BossBar.Overlay.NOTCHED_6;
            case "SEGMENTED_10" -> BossBar.Overlay.NOTCHED_10;
            case "SEGMENTED_12" -> BossBar.Overlay.NOTCHED_12;
            case "SEGMENTED_20" -> BossBar.Overlay.NOTCHED_20;
            default -> BossBar.Overlay.PROGRESS;
        };
        Component title = text("bossbar.text", DEFAULT_BOSSBAR_TEXT);
        bossBar = BossBar.bossBar(title, 1.0f, color, overlay);
        for (Player player : Bukkit.getOnlinePlayers()) {
            player.showBossBar(bossBar);
        }
    }

    private void removeBossBar() {
        if (bossBar != null) {
            for (Player player : Bukkit.getOnlinePlayers()) {
                player.hideBossBar(bossBar);
            }
            bossBar = null;
        }
    }

    private void announce(String section) {
        String fallbackTitle = section.equals("start")
                ? "<gradient:#ff0000:#ffcc00><bold>⚔ END WAR STARTED!</bold></gradient>"
                : "<gradient:#8b0000:#ff0000><bold>⚔ END WAR ENDED!</bold></gradient>";
        String fallbackSubtitle = section.equals("start")
                ? "<aqua><bold>SEASON 2</bold></aqua> <white>FINALE</white>"
                : "<gold><bold>SEASON 2</bold></gold> <white>has come to an end.</white>";
        String fallbackChat = section.equals("start")
                ? "<red>⚔</red> <dark_red><bold>END WAR</bold></dark_red> <gold>has officially started!</gold>"
                : "<red>⚔</red> <dark_red><bold>END WAR</bold></dark_red> <gold>has officially ended!</gold>";

        Title.Times times = Title.Times.times(
                ticks(getConfig().getInt(section + ".fade-in", 10)),
                ticks(getConfig().getInt(section + ".stay", 70)),
                ticks(getConfig().getInt(section + ".fade-out", 20)));
        Title title = Title.title(
                text(section + ".title", fallbackTitle),
                text(section + ".subtitle", fallbackSubtitle),
                times);
        Component chat = text(section + ".chat", fallbackChat);

        if (getConfig().getBoolean(section + ".sound.enabled", true)) {
            String defaultSound = section.equals("start") ? "ENTITY_ENDER_DRAGON_GROWL" : "UI_TOAST_CHALLENGE_COMPLETE";
            String sound = soundKey(getConfig().getString(section + ".sound.type", defaultSound));
            float volume = (float) getConfig().getDouble(section + ".sound.volume", 1.0);
            float pitch = (float) getConfig().getDouble(section + ".sound.pitch", 1.0);
            for (Player player : Bukkit.getOnlinePlayers()) {
                player.showTitle(title);
                player.sendMessage(chat);
                player.playSound(player.getLocation(), sound, volume, pitch);
            }
            return;
        }

        for (Player player : Bukkit.getOnlinePlayers()) {
            player.showTitle(title);
            player.sendMessage(chat);
        }
    }

    private Component text(String path, String fallback) {
        String configured = getConfig().getString(path);
        return MINI_MESSAGE.deserialize(configured == null ? fallback : configured);
    }

    private void send(CommandSender sender, String path, String fallback) {
        sender.sendMessage(text(path, fallback));
    }

    private static Duration ticks(int ticks) {
        return Duration.ofMillis(Math.max(0, ticks) * 50L);
    }

    private static String soundKey(String configured) {
        if (configured == null || configured.isBlank()) {
            return "minecraft:entity.ender_dragon.growl";
        }
        if (configured.equalsIgnoreCase("ENTITY_ENDER_DRAGON_GROWL")) {
            return "minecraft:entity.ender_dragon.growl";
        }
        if (configured.equalsIgnoreCase("UI_TOAST_CHALLENGE_COMPLETE")) {
            return "minecraft:ui.toast.challenge_complete";
        }
        if (configured.contains(":") || configured.contains(".")) {
            return configured;
        }
        return "minecraft:" + configured.toLowerCase(Locale.ROOT);