D
📎 1 file 4,349 chars
📄
pasted-code-1774827243707.txt
txt 159 lines
▶
Crea un plugin Minecraft per Paper/Spigot chiamato TlCAIRDROPS.

Obiettivo: generare airdrop casuali o manuali nel mondo, con casse/eventi loot configurabili, annunci in chat/title/actionbar, marker visivi, protezioni anti-abuso e compatibilità completa con ItemsAdder.

Requisiti principali:

Compatibilità con versioni Paper moderne.

Sistema di airdrop automatici a intervalli configurabili.

Comando per spawn manuale dell’airdrop.

Possibilità di definire più tipi di airdrop con loot diversi, rarità diverse, nomi, hologrammi, suoni, particelle e countdown.

Atterraggio dell’airdrop in posizioni sicure e configurabili.

Protezione dell’area dell’airdrop per evitare exploit.

Apertura con timer, lock PvP opzionale, contestazione dell’evento e ricompense finali.

Configurazione completa via YAML.
Compatibilità obbligatoria con ItemsAdder:

Il plugin deve poter leggere item vanilla e item custom di ItemsAdder nei loot.

I loot custom devono essere referenziabili sia per id sia per namespace:id, perché la documentazione di ItemsAdder mostra questo approccio per recuperare gli item custom.

Per ottenere un item custom usa CustomStack.getInstance("namespace:id") oppure CustomStack.getInstance("id"); se l’oggetto esiste, converti in ItemStack con getItemStack().

Per verificare se un item in inventario o in una cassa è un item custom di ItemsAdder, usa CustomStack.byItemStack(itemStack) oppure i controlli ItemsAdder.isCustomItem(...) / matchCustomItemName(...) quando servono confronti specifici.

Il plugin non deve caricare o usare item ItemsAdder troppo presto: deve aspettare il caricamento completo di ItemsAdder tramite il relativo evento di load, perché la documentazione e i report pubblici indicano che altrimenti CustomStack può risultare null.

Se ItemsAdder non è installato, il plugin deve continuare a funzionare con i loot vanilla senza errori.

Se un item custom configurato non esiste, il plugin deve loggare un warning chiaro e saltare solo quell’item, senza rompere l’airdrop.
Architettura richiesta:

Codice pulito, modulare e production-ready.

softdepend: [ItemsAdder] nel plugin.yml, così l’integrazione resta opzionale ma supportata, in linea con le pratiche comuni per compatibilità plugin.

Classi separate per: manager airdrop, scheduler, loot parser, hooks esterni, listener eventi, comandi, config manager.

Hook dedicato ItemsAdderHook.

API interna semplice per creare nuovi tipi di airdrop in futuro.
Config richieste:

config.yml

intervallo spawn

mondi abilitati

altezza minima/massima

broadcast

effetti visivi

protezione zona

tempo di unlock

durata evento

airdrops.yml

lista dei tipi di airdrop

nome

rarità

peso spawn

blocco/cassa usata

hologramma

comandi eseguiti all’apertura

loot table

messages.yml

tutti i messaggi personalizzabili
Formato loot richiesto:

supporta item vanilla

supporta item custom ItemsAdder

quantità minima/massima

chance percentuale

enchant vanilla opzionali

lore/name opzionali se necessario
Esempio loot:
text
loot:
  - type: VANILLA
    material: DIAMOND
    min: 1
    max: 3
    chance: 25
  - type: ITEMSADDER
    item: "iasurvival:ruby"
    min: 1
    max: 2
    chance: 10

Funzioni extra desiderate:

placeholder per stato airdrop, tempo rimanente, posizione e tipo evento.

supporto reload sicuro.

log di debug opzionale.

protezione contro spawn in acqua/lava/zone non valide.

supporto world blacklist/whitelist.

possibilità di usare beacon, crate, chest o blocchi custom come contenitore/marker.
Output che voglio da te:

struttura completa del plugin

tutto il codice Java

plugin.yml

file config di esempio

commenti essenziali

istruzioni compilazione Maven o Gradle

spiegazione di dove gestisci l’hook con ItemsAdder

gestione errori robusta
Vincoli importanti:

niente codice incompleto o pseudocodice

niente dipendenze inutili

codice compatibile con server reali

massima attenzione alla compatibilità con ItemsAdder

fallback automatico ai soli item vanilla se ItemsAdder non è presente
Prendi come riferimento il comportamento dei plugin airdrop moderni che supportano loot configurabili e integrazione con ItemsAdder per inserire item custom nelle casse evento.

Kodari AI
KodariMar 29 at 11:39 pm 38,012 (v2)

Now I have everything I need. Let me plan the full architecture before writing:

  • 13 Java classes across packages: model, hooks, listener, command

  • ItemsAdder loaded lazily via ItemsAdderLoadDataEvent

  • Active airdrops tracked by chest Location key in AirdropManager

  • Chest placed at safe ground level, hologram via ArmorStand(s), countdown via actionbar/title

  • Full XSeries usage for particles, sounds, enchantments, materials

  • No GUI system needed (chests are used as in-world containers)

TlCAirdrops
A fully-featured airdrop plugin for Paper/Spigot that spawns configurable loot crates at random or manual locations. Supports multiple airdrop types with weighted rarity, ItemsAdder custom item loot integration, area protection, PvP zones, holographic markers via ArmorStands, sound/particle effects, countdown announcements via title/actionbar/chat, safe landing detection, world whitelist/blacklist, and complete YAML configuration for all messages, loot tables, and airdrop types.

Here’s a summary of the complete plugin structure:

13 Java classes across 5 packages:

  • TlCAirdrops — main plugin, initializes all managers, handles soft-dep detection

  • ConfigManager — loads all 3 YAML files, parses airdrop types and loot entries

  • LootParser — generates ItemStack loot from entries using XSeries + ItemsAdder hook

  • AirdropManager — core engine: spawns, landing sequence, unlock timer, expire timer, hologram ArmorStands, protection zone, PvP logic

  • AirdropScheduler — BukkitRunnable triggering automatic random spawns at configured intervals

  • model/ — AirdropType, ActiveAirdrop (state machine: INCOMING→LANDED→UNLOCKED→EXPIRED), LootEntry

  • hooks/ItemsAdderHook — waits for ItemsAdderLoadDataEvent, provides getCustomItem() / isCustomItem(), logs warnings for missing items

  • listener/AirdropListener — blocks interactions, chest opens, block break/place in zone, PvP handling

  • listener/ItemsAdderListener — delegates to the hook, kept separate so it’s only registered if ItemsAdder is present

  • command/AirdropCommand — /airdrop spawn [type] [world] [x] [z], list, types, reload with full tab-completion

Key behaviors: safe location finder avoids water/lava/void with 30 attempts; hologram uses two invisible marker ArmorStands; area protection uses distance check; ItemsAdder items are only resolved after ItemsAdderLoadDataEvent fires; if ItemsAdder is absent the plugin runs fully in vanilla-only mode.

D

sistema gli hologrammi, che se spacco la chest non spariscono, poi il loot, faiche posso mettere il loot, qualsiasi sia da un INVENTORY GUI, fai un INVENTORY GUI per gestireo tutto, tutto, e fai che posso modificare tutto

Kodari AI
KodariMar 29 at 11:55 pm 66,706 (v2)

Now I have a complete picture. Here’s my plan:

  • Fix holograms bug: Refactor onBlockBreak so holograms are always removed when the chest block is destroyed (including bypass players)

  • Add save/edit methods to ConfigManager: setTypeField, createAirdropType, removeAirdropType, getLootMaps, saveLootMaps, etc.

  • Build full GUI system: ChatInputManager, BaseGUI, GUIManager, GUIListener, AdminMainGUI, AirdropTypeGUI, CommandsEditorGUI, LootEditorGUI, LootEntryGUI

  • Add gui command and register everything in main plugin class

Now update ConfigManager with all the save/edit methods:

Now let me fix the GUIManager — getLastGUI is relied on in ChatInputManager but needs to handle null gracefully, and ChatInputManager shouldn’t call open(null):

Also fix AirdropCommand constructor call in TlCAirdrops — I already updated both files to match the new 4-arg constructor. Let me verify the AirdropManager still compiles by checking if notifyChestBreak is now unused (it is — the new listener directly calls removeAirdrop). Let me clean that up:


Here’s a summary of everything that was done:

Bug fix — Holograms not disappearing on chest break:

  • AirdropListener.onBlockBreak was rewritten: any player (with bypass perm OR when the airdrop is UNLOCKED) now always calls airdropManager.removeAirdrop(airdrop, false), which removes both hologramTop and hologramBottom ArmorStands unconditionally.

Full GUI system (/airdrop gui):

GUI
What it does
AdminMainGUI
Lists all airdrop types; create new / delete / reload
AirdropTypeGUI
Edit display name, weight, rarity, container, hologram, sound, particle, PVP toggle, commands, loot
CommandsEditorGUI
Add / remove per-type on-claim commands
LootEditorGUI
Lists all loot entries; add / remove / edit
LootEntryGUI
Edit item (captured from main hand — supports
ItemsAdder
auto-detection), chance, min, max, display name, lore, enchants

Chat input system (ChatInputManager): all string/number values are edited by chat — type the value or cancelled to abort. All changes are saved live to airdrops.yml and the in-memory type map is hot-reloaded without a full server restart.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
28 2,976
src/main/java/com/tlcplugins/tlcairdrops/TlCAirdrops.java
package com.tlcplugins.tlcairdrops;

import com.tlcplugins.tlcairdrops.command.AirdropCommand;
import com.tlcplugins.tlcairdrops.gui.ChatInputManager;
import com.tlcplugins.tlcairdrops.gui.GUIListener;
import com.tlcplugins.tlcairdrops.gui.GUIManager;
import com.tlcplugins.tlcairdrops.hooks.ItemsAdderHook;
import com.tlcplugins.tlcairdrops.listener.AirdropListener;
import com.tlcplugins.tlcairdrops.listener.ItemsAdderListener;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class TlCAirdrops extends JavaPlugin {

    @Getter
    private static TlCAirdrops instance;

    @Getter
    private ConfigManager configManager;

    @Getter
    private AirdropManager airdropManager;

    @Getter
    private AirdropScheduler airdropScheduler;

    @Getter
    private LootParser lootParser;

    @Getter
    private ItemsAdderHook itemsAdderHook;

    @Getter
    private GUIManager guiManager;

    @Getter
    private ChatInputManager chatInputManager;

    @Override
    public void onEnable() {
        instance = this;

        configManager = new ConfigManager(this);
        configManager.load();

        guiManager = new GUIManager();
        chatInputManager = new ChatInputManager(this);

        boolean itemsAdderAvailable = Bukkit.getPluginManager().getPlugin("ItemsAdder") != null;
        if (itemsAdderAvailable) {
            itemsAdderHook = new ItemsAdderHook(this);
            getLogger().info("ItemsAdder detected. Registering hook (waiting for load event).");
        } else {
            getLogger().info("ItemsAdder not found. Custom item loot will not be available.");
        }

        lootParser = new LootParser(itemsAdderHook, getLogger());
        airdropManager = new AirdropManager(this, configManager, lootParser);
        airdropScheduler = new AirdropScheduler(this, configManager, airdropManager);

        registerListeners(itemsAdderAvailable);
        registerCommands();

        airdropScheduler.start();

        getLogger().info("TlCAirdrops enabled successfully.");
    }

    @Override
    public void onDisable() {
        if (airdropScheduler != null) {
            airdropScheduler.stop();
        }
        if (airdropManager != null) {
            airdropManager.cleanup();
        }
        getLogger().info("TlCAirdrops disabled. All airdrops have been cleaned up.");
    }

    private void registerListeners(boolean itemsAdderAvailable) {
        Bukkit.getPluginManager().registerEvents(new AirdropListener(airdropManager, configManager), this);
        Bukkit.getPluginManager().registerEvents(new GUIListener(this), this);
        Bukkit.getPluginManager().registerEvents(chatInputManager, this);
        if (itemsAdderAvailable && itemsAdderHook != null) {
            Bukkit.getPluginManager().registerEvents(new ItemsAdderListener(this, itemsAdderHook), this);
        }
    }

    private void registerCommands() {
        AirdropCommand cmd = new AirdropCommand(this, airdropManager, airdropScheduler, configManager);
        getCommand("airdrop").setExecutor(cmd);
        getCommand("airdrop").setTabCompleter(cmd);
    }
}