Mateusz Cyrzan

6 new boss

Kodari AI
KodariToday at 9:25 pm 1
BossArena
BossArena is a Minecraft plugin that spawns customizable boss mobs at configured locations with configurable health, damage, abilities, loot tables, and respawn timers. Players receive combat notifications, boss health bars, kill rewards, and arena management commands. The plugin includes a configuration system for defining multiple boss types, spawn points, difficulty scaling, and particle effects. It provides admin commands for spawning, despawning, and managing boss arenas, along with permission-based access control and cooldown tracking.
  • Add six summonable bosses, each with its own combat ability.

  • Register an admin command and announce boss defeats.

Created six bosses with distinct abilities and defeat announcements.

Summon one with /boss spawn <boss>; use tab completion to see the names. The command defaults to operators.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 200
src/main/java/com/kodari/sixbosses/SixBosses.java
package com.kodari.sixbosses;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.NamespacedKey;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Mob;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

public final class SixBosses extends JavaPlugin implements Listener, TabExecutor {
    private NamespacedKey bossKey;

    private enum Boss {
        GRAVEKING("Grave King", EntityType.ZOMBIE, 200),
        STORMARCHER("Storm Archer", EntityType.SKELETON, 150),
        VENOMQUEEN("Venom Queen", EntityType.SPIDER, 180),
        CINDERLORD("Cinder Lord", EntityType.BLAZE, 160),
        HEXMOTHER("Hex Mother", EntityType.WITCH, 180),
        VOIDREAPER("Void Reaper", EntityType.WITHER_SKELETON, 220);

        final String title;
        final EntityType type;
        final double health;

        Boss(String title, EntityType type, double health) {
            this.title = title;
            this.type = type;
            this.health = health;
        }
    }

    @Override
    public void onEnable() {
        bossKey = new NamespacedKey(this, "boss");
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("boss").setExecutor(this);
        getCommand("boss").setTabCompleter(this);
        getServer().getScheduler().runTaskTimer(this, this::useAbilities, 100L, 100L);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("Only players can summon a boss.");
            return true;
        }
        if (args.length != 2 || !args[0].equalsIgnoreCase("spawn")) {
            return false;
        }
        Boss boss;
        try {
            boss = Boss.valueOf(args[1].toUpperCase(Locale.ROOT));
        } catch (IllegalArgumentException ex) {
            sender.sendMessage(ChatColor.RED + "Unknown boss. Use tab completion to see the available bosses.");
            return true;
        }
        Player player = (Player) sender;
        LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), boss.type);
        entity.setMaxHealth(boss.health);
        entity.setHealth(boss.health);
        entity.setCustomName(ChatColor.DARK_RED + "☠ " + boss.title);
        entity.setCustomNameVisible(true);
        entity.setRemoveWhenFarAway(false);
        entity.getPersistentDataContainer().set(bossKey, PersistentDataType.STRING, boss.name());
        if (entity instanceof Mob) {
            ((Mob) entity).setTarget(player);
        }
        Bukkit.broadcastMessage(ChatColor.RED + boss.title + " has appeared!");
        return true;
    }

    private void useAbilities() {
        for (org.bukkit.World world : Bukkit.getWorlds()) {
            for (LivingEntity entity : world.getLivingEntities()) {
                String id = entity.getPersistentDataContainer().get(bossKey, PersistentDataType.STRING);
                if (id == null || !(entity instanceof Mob) || entity.isDead()) continue;
                Boss boss;
                try {
                    boss = Boss.valueOf(id);
                } catch (IllegalArgumentException ex) {
                    continue;
                }
                LivingEntity target = ((Mob) entity).getTarget();
                if (!(target instanceof Player) || target.isDead() || target.getWorld() != world
                        || target.getLocation().distanceSquared(entity.getLocation()) > 400) continue;
                switch (boss) {
                    case GRAVEKING:
                        for (int i = 0; i < 2; i++) {
                            Mob minion = (Mob) world.spawnEntity(entity.getLocation(), EntityType.ZOMBIE);
                            minion.setTarget(target);
                        }
                        break;
                    case STORMARCHER:
                        world.strikeLightningEffect(target.getLocation());
                        target.damage(5.0, entity);
                        break;
                    case VENOMQUEEN:
                        target.damage(3.0, entity);
                        target.setVelocity(target.getVelocity().multiply(0.2));
                        break;
                    case CINDERLORD:
                        target.setFireTicks(Math.max(target.getFireTicks(), 100));
                        break;
                    case HEXMOTHER:
                        entity.setHealth(Math.min(entity.getMaxHealth(), entity.getHealth() + 12.0));
                        target.damage(3.0, entity);
                        break;
                    case VOIDREAPER:
                        Vector direction = entity.getLocation().toVector().subtract(target.getLocation().toVector());
                        if (direction.lengthSquared() > 0.01) {
                            target.setVelocity(direction.normalize().multiply(1.1).setY(0.35));
                        }
                        target.damage(4.0, entity);
                        break;
                }
            }
        }
    }

    @EventHandler
    public void onDeath(EntityDeathEvent event) {
        Entity entity = event.getEntity();
        String id = entity.getPersistentDataContainer().get(bossKey, PersistentDataType.STRING);
        if (id == null) return;
        try {
            Boss boss = Boss.valueOf(id);
            event.setDroppedExp(200);
            Player killer = event.getEntity().getKiller();
            Bukkit.broadcastMessage(ChatColor.GOLD + boss.title + " was defeated"
                    + (killer == null ? "!" : " by " + killer.getName() + "!"));
        } catch (IllegalArgumentException ignored) {
        }
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
        if (args.length == 1) {
            return "spawn".startsWith(args[0].toLowerCase(Locale.ROOT))
                    ? Collections.singletonList("spawn") : Collections.emptyList();
        }
        if (args.length == 2 && args[0].equalsIgnoreCase("spawn")) {
            List<String> result = new ArrayList<>();
            Arrays.stream(Boss.values()).map(b -> b.name().toLowerCase(Locale.ROOT))
                    .filter(name -> name.startsWith(args[1].toLowerCase(Locale.ROOT)))
                    .forEach(result::add);
            return result;
        }
        return Collections.emptyList();
    }
}