No chat to show

This project's files are all here to explore.

Files
src
pom.xml
Code
8 1,023
src/main/java/com/example/ifritboss/IfritBossPlugin.java
package com.example.ifritboss;

import com.example.ifritboss.boss.IfritBoss;
import com.example.ifritboss.command.GiveAxeCommand;
import com.example.ifritboss.command.SpawnBossCommand;
import com.example.ifritboss.listener.BossListener;
import org.bukkit.NamespacedKey;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public final class IfritBossPlugin extends JavaPlugin {

    // Все живые боссы на сервере: UUID сущности-босса -> объект логики босса
    private final Map<UUID, IfritBoss> activeBosses = new HashMap<>();

    // Ключи PersistentDataContainer
    private NamespacedKey bossTagKey;       // стоит на самой сущности-боссе
    private NamespacedKey bossIdKey;        // стоит на миньонах и файерболах, хранит UUID босса-владельца
    private NamespacedKey fireballDamageKey;
    private NamespacedKey legendaryAxeKey;  // метка "это топор ифрита, зачаровывать нельзя"

    @Override
    public void onEnable() {
        this.bossTagKey = new NamespacedKey(this, "ifrit_boss_tag");
        this.bossIdKey = new NamespacedKey(this, "ifrit_boss_owner_id");
        this.fireballDamageKey = new NamespacedKey(this, "ifrit_fireball_damage");
        this.legendaryAxeKey = new NamespacedKey(this, "ifrit_legendary_axe");

        getServer().getPluginManager().registerEvents(new BossListener(this), this);

        SpawnBossCommand spawnCommand = new SpawnBossCommand(this);
        getCommand("spawnifrit").setExecutor(spawnCommand);
        getCommand("spawnifrit").setTabCompleter(spawnCommand);

        GiveAxeCommand giveAxeCommand = new GiveAxeCommand(this);
        getCommand("giveifritaxe").setExecutor(giveAxeCommand);
        getCommand("giveifritaxe").setTabCompleter(giveAxeCommand);

        getLogger().info("IfritBossPlugin включён.");
    }

    @Override
    public void onDisable() {
        for (IfritBoss boss : new HashMap<>(activeBosses).values()) {
            boss.cleanup();
        }
        activeBosses.clear();
        getLogger().info("IfritBossPlugin выключён.");
    }

    public Map<UUID, IfritBoss> getActiveBosses() {
        return activeBosses;
    }

    public void registerBoss(IfritBoss boss) {
        activeBosses.put(boss.getEntityId(), boss);
    }

    public void unregisterBoss(UUID entityId) {
        activeBosses.remove(entityId);
    }

    public NamespacedKey getBossTagKey() {
        return bossTagKey;
    }

    public NamespacedKey getBossIdKey() {
        return bossIdKey;
    }

    public NamespacedKey getFireballDamageKey() {
        return fireballDamageKey;
    }

    public NamespacedKey getLegendaryAxeKey() {
        return legendaryAxeKey;
    }
}