D

fully modern functional crates plugin with editor

Kodari AI
KodariMar 8 at 12:20 pm 80,708 (v2)

I’ll create a comprehensive crates plugin with a full GUI editor system. Let me first read some documentation for dependencies I’ll use.

Let me plan this thoroughly and build it.

StellarCrates
A modern, fully-featured crates plugin with an intuitive in-game GUI editor. Supports unlimited crate types with customizable animations (spin, csgo-style, instant), weighted rewards with chances, preview menus, key management, crate placement with particle effects, and complete YAML persistence. Features a full click-based editor for creating and modifying crates, adding rewards with drag-and-drop, setting chances, configuring animations, and managing crate locations. Integrates with Vault for command rewards and supports PlaceholderAPI.

Now let me plan the full architecture:

Classes to create:

  1. StellarCrates - Main plugin class

  2. CrateManager - Manages all crate types, loading/saving

  3. KeyManager - Manages virtual/physical keys

  4. AnimationManager - Handles crate opening animations

  5. LocationManager - Manages placed crate locations

  6. EditorManager - Handles the GUI editor state

  7. MenuManager - Manages all GUI menus

  8. Crate - Data class for a crate type

  9. CrateReward - Data class for a reward

  10. CrateLocation - Data class for placed crate

  11. CrateAnimation - Enum for animation types

  12. SpinAnimation - Roulette-style animation

  13. CsgoAnimation - CSGO case-style animation

  14. CrateCommand - Main command handler

  15. CrateListener - Event listener for interactions

  16. EditorListener - Event listener for editor

  17. PreviewMenu - Crate preview GUI

  18. EditorMenu - Main editor GUI

  19. RewardEditorMenu - Reward editing GUI

  20. AnimationTask - Base animation task

  21. ColorUtil - Color utility

  22. ItemBuilder - Item creation utility

  23. MessageUtil - Message utility

  24. NumberUtil - Number formatting

All files created — a fully functional modern crates plugin with complete GUI editor, three animation types (spin/csgo/instant), physical + virtual key system, crate placement with particles, preview menus, reward management with items/commands/chances/broadcast, and full YAML persistence.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
24 2,938
src/main/java/com/stellarcrates/StellarCrates.java
package com.stellarcrates;

import com.stellarcrates.command.CrateCommand;
import com.stellarcrates.listener.CrateListener;
import com.stellarcrates.listener.EditorListener;
import com.stellarcrates.manager.AnimationManager;
import com.stellarcrates.manager.CrateManager;
import com.stellarcrates.manager.EditorManager;
import com.stellarcrates.manager.KeyManager;
import com.stellarcrates.manager.LocationManager;
import com.stellarcrates.manager.MenuManager;
import com.stellarcrates.util.ColorUtil;
import lombok.Getter;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class StellarCrates extends JavaPlugin {

    @Getter
    private static StellarCrates instance;

    private CrateManager crateManager;
    private KeyManager keyManager;
    private AnimationManager animationManager;
    private LocationManager locationManager;
    private EditorManager editorManager;
    private MenuManager menuManager;
    private Economy economy;

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

        setupEconomy();

        crateManager = new CrateManager(this);
        keyManager = new KeyManager(this);
        locationManager = new LocationManager(this);
        animationManager = new AnimationManager(this);
        editorManager = new EditorManager(this);
        menuManager = new MenuManager(this);

        crateManager.loadCrates();
        locationManager.loadLocations();
        keyManager.loadKeys();

        getCommand("stellarcrates").setExecutor(new CrateCommand(this));
        getCommand("stellarcrates").setTabCompleter(new CrateCommand(this));

        getServer().getPluginManager().registerEvents(new CrateListener(this), this);
        getServer().getPluginManager().registerEvents(new EditorListener(this), this);

        locationManager.startParticleTask();

        getLogger().info("StellarCrates enabled!");
    }

    @Override
    public void onDisable() {
        if (animationManager != null) {
            animationManager.cancelAll();
        }
        if (keyManager != null) {
            keyManager.saveKeys();
        }
        if (locationManager != null) {
            locationManager.saveLocations();
        }
        if (crateManager != null) {
            crateManager.saveCrates();
        }
        getLogger().info("StellarCrates disabled!");
    }

    private void setupEconomy() {
        if (getServer().getPluginManager().getPlugin("Vault") == null) return;
        RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
        if (rsp != null) {
            economy = rsp.getProvider();
        }
    }

    public String getMessage(String key) {
        String prefix = getConfig().getString("prefix", "&b&lStellarCrates &8» &7");
        String msg = getConfig().getString("messages." + key, "&cMissing message: " + key);
        return ColorUtil.color(prefix + msg);
    }

    public String getRawMessage(String key) {
        return ColorUtil.color(getConfig().getString("messages." + key, "&cMissing message: " + key));
    }

    public void reload() {
        reloadConfig();
        crateManager.loadCrates();
        locationManager.loadLocations();
        keyManager.loadKeys();
        locationManager.startParticleTask();
    }
}