cosmeticggs.

Fix the hologram duplication bug for the Collector.

Issue:

* Before a server restart, each Collector has one hologram. * After restarting the server, the old hologram is not removed, and a new hologram is created, causing multiple holograms to stack at the same location.

Required Fixes:

  1. Ensure all previously spawned Collector holograms are properly removed when the plugin loads or the server restarts.
  2. Prevent duplicate holograms from being created for the same Collector.
  3. Each Collector should always have only one active hologram.

Hologram Format: The hologram should have two lines:

Line 1: Collector Radius: [radius]

Line 2: Stored Value >> [money]

Replace [radius] with the Collector's current collection radius and [money] with the total stored value, updating both values in real time whenever they change.

Kodari AI
KodariJul 6 at 5:09 am 12

Now I have full visibility into the issue. Here’s the root cause and plan:

Root cause: CollectorManager.load() calls register() → spawnHologram() for each collector on startup, but never cleans up leftover ArmorStand entities from the previous session (when the server was stopped without a clean onDisable()). The hologram field is transient so it’s always null on reload, triggering a new spawn each time — accumulating duplicates.

Plan (3 tasks):

  1. Collector.java — Replace single hologram field with hologramLine1/hologramLine2 for the two-line format

  2. CollectorManager.java — Add stale cleanup, duplicate guard, two-line spawn/update/remove

  3. config.yml — Update hologram-text to match new two-line format

Now let me check the ConfigManager.render() method before patching

Now let me apply all the fixes. I need to update CollectorManager (4 method patches), ConfigManager (new fields), and config.yml

Now add the two-line hologram text config fields

Let me verify the final state is consistent:

All 4 files are consistent. Here’s a summary of the changes:

Root cause: CollectorManager.load() calls register() → spawnHologram() for each collector on startup, but never cleaned up leftover ArmorStand entities from the previous session. Since the hologram field was transient, it was always null on reload, so a new hologram spawned every time — accumulating duplicates.

Changes across 4 files:

  1. Collector.java — Split hologram into hologramLine1 / hologramLine2 (both transient) with matching getters/setters for the two-line format.

  2. CollectorManager.java:

    • spawnHologram() — cleans up any leftover ArmorStands at the target positions (0.1 block radius) before spawning new ones. This kills orphaned entities from crashes or improper shutdowns.

    • spawnHologram() — Spawns two ArmorStands: line1 at +1.8y (radius), line2 at +1.6y (value).

    • updateHolograms() — Updates both lines in real time using <radius> and <value> placeholders.

    • removeHologram() — New shared private method that removes both lines and nulls them. Used by unregisterAt() (break) and removeHolograms() (disable).

    • unregisterAt() — Now calls removeHologram() instead of inline null checks.

  3. ConfigManager.java — Replaced hologramText with hologramLine1Text / hologramLine2Text with getters and config-key defaults.

  4. config.yml — hologram-text replaced by hologram-line1 (Collector Radius: <radius>) and hologram-line2 (Stored Value >> $<value>).

cosmeticggs.

Make it work for economyshopgui and other economy plugins also and fix some bugs

Kodari AI
KodariJul 15 at 11:12 am 1

The generation was stopped before any content could be produced.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
14 1,453
src/main/java/com/dragoncollector/DragonCollector.java
package com.dragoncollector;

import com.dragoncollector.collector.CollectorManager;
import com.dragoncollector.economy.EconomyManager;
import com.dragoncollector.listener.CollectorListener;
import com.dragoncollector.util.CollectorItem;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

public final class DragonCollector extends JavaPlugin {

    private ConfigManager configManager;
    private CollectorManager collectorManager;
    private EconomyManager economyManager;
    private Economy economy;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        this.configManager = new ConfigManager(this);
        this.configManager.load();

        if (!setupEconomy()) {
            getLogger().severe("Vault economy not found! Disabling.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        CollectorItem.init(this);
        this.economyManager = new EconomyManager(economy);
        this.collectorManager = new CollectorManager(this, configManager, economyManager);
        this.collectorManager.load();
        this.collectorManager.startTasks();

        getServer().getPluginManager().registerEvents(new CollectorListener(collectorManager, economyManager), this);
        CollectorCommand command = new CollectorCommand(this, configManager);
        getCommand("collector").setExecutor(command);
        getCommand("collector").setTabCompleter(command);
    }

    @Override
    public void onDisable() {
        if (collectorManager != null) {
            collectorManager.removeHolograms();
            collectorManager.save();
        }
    }

    private boolean setupEconomy() {
        RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
        if (rsp == null) return false;
        this.economy = rsp.getProvider();
        return true;
    }

    public ConfigManager configManager() {
        return configManager;
    }

    public CollectorManager collectorManager() {
        return collectorManager;
    }

    public Economy economy() {
        return economy;
    }
}