conspiracyyy
📎 1 file 3,345 chars
📄
pasted-code-1781077378199.txt
txt 1 lines
▶
Create a production-ready Minecraft Coinflip plugin for the latest Spigot/Paper API. Requirements: Full INVENTORY GUI integration using inventory menus. Clean, modular, and maintainable code structure. Secure implementation with validation, error handling, and exploit prevention. Database support with an abstraction layer supporting SQLite by default and MySQL/MariaDB optionally. Complete API for developers to hook into coinflip creation, joining, winning, cancellation, and completion events. Menu system for: Main coinflip browser. Active coinflips. Coinflip creation. Coinflip history. Statistics. Admin management. Configurable item-based or economy-based coinflips. Support Vault economy integration. Support PlaceholderAPI placeholders. Support hex colors and MiniMessage formatting throughout all messages, GUIs, and configuration files. Fully customizable INVENTORY GUI titles, lore, buttons, sounds, and messages. Use config.yml for settings and feature configuration. Use messages.yml for all user-facing messages. No hardcoded messages. No comments in generated code or configuration files. Coinflip Features: Configurable minimum coinflip amount. Configurable maximum coinflip amount. Per-player coinflip limits. Global coinflip limits. Cooldowns for creating coinflips. Permission-based limits. Tax/fee system. Blacklisted worlds support. Blacklisted commands while in coinflip menus. Coinflip expiration system. Auto-cancel expired coinflips. Confirmation menus before creating or joining coinflips. Randomized winner selection using secure randomization methods. Protection against duplication exploits, packet abuse, inventory desyncs, and race conditions. Async database operations where appropriate. Proper thread safety. Admin Features: Force-cancel coinflips. Force-end coinflips. Reload command. Statistics command. View active coinflips. Audit logs. Transaction logs. Player coinflip history. Permission-based admin tools. Database Features: Store: Active coinflips. Completed coinflips. Cancelled coinflips. Player statistics. Win/loss records. Transaction history. Automatic table creation. Data migration support. Commands: /coinflip /coinflip create /coinflip join /coinflip history /coinflip stats /coinflip cancel /coinflip reload /coinflip admin Permissions: Granular permission system. Separate permissions for: Creating coinflips. Joining coinflips. Admin actions. Bypass limits. Bypass cooldowns. Special coinflip tiers. Development Standards: Use modern Java practices. Dependency injection where appropriate. Event-driven architecture. Service-based design. Repository pattern for database access. Proper package organization. Efficient memory usage. No code generation artifacts. No placeholder implementations. No AI-style naming conventions. Production-quality code suitable for a public premium plugin release. Generate: Full project structure. plugin.yml. config.yml. messages.yml. Database schema. API events. Core classes. INVENTORY GUI classes. Command classes. Manager classes. Repository classes. Utility classes. Complete implementation code. Please use standard color codes andf hex for mc &#FF0000 instead of whatever and &c but keep minimessage to, make in the INVENTORY GUI a refresh button, back page button and next page button make the items configurable with sounds, lore etc make it nice
Kodari AI
KodariJun 10 at 7:51 am 66

I’ll create a production-ready Coinflip plugin with full inventory GUI integration, database support, economy integration, and comprehensive security features.

CoinflipPlugin
A premium coinflip gambling plugin with full inventory GUI system, database persistence, economy integration, and developer API. Features include configurable limits, cooldowns, tax system, admin tools, transaction logging, exploit prevention, PlaceholderAPI support, and MiniMessage formatting. Supports SQLite and MySQL with async operations. Includes browser menu, creation wizard, history viewer, statistics display, and admin management interface.

Production-ready Coinflip plugin created with:

Core Features:

  • Full inventory GUI system with browser, creation wizard, history, stats, admin panel

  • SQLite (default) + MySQL database support with async operations

  • Vault economy integration with tax system

  • Configurable limits (amount, per-player, global, tier-based)

  • Cooldown system (create/join)

  • Expiration system with auto-cancel

  • Secure random winner selection

  • Complete validation and exploit prevention

  • Command blacklist while in menus

  • World blacklist

GUI Features (All Configurable):

  • Browser: pagination, refresh button, create button, clickable coinflips

  • Create: amount presets, confirmation flow

  • History: paginated results with win/loss colors

  • Stats: wins, losses, winrate, profit, total wagered/won

  • Admin: active count, force cancel all, reload

  • All items: custom material, name, lore, sounds

Developer API:

  • 5 cancellable events (Create, Join, Win, Cancel, Complete)

  • Public API for getting active coinflips, player stats

  • Repository pattern for extending data access

Security:

  • Thread-safe coinflip management

  • SecureRandom for winner selection

  • Validation at every step

  • Async database operations

  • Race condition protection

Configuration:

  • MiniMessage + legacy colors (&#FF0000 and &c)

  • No hardcoded messages (all in messages.yml)

  • Zero comments as requested

  • Per-tier permissions with custom limits

  • Complete sound customization

The plugin is production-ready with proper error handling, async operations, exploit prevention, and a clean modular architecture.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
50 4,255
src/main/java/com/example/coinflip/CoinflipPlugin.java
package com.example.coinflip;

import com.example.coinflip.api.CoinflipAPI;
import com.example.coinflip.command.CoinflipCommand;
import com.example.coinflip.command.subcommands.*;
import com.example.coinflip.config.ConfigManager;
import com.example.coinflip.config.MessageManager;
import com.example.coinflip.database.DatabaseManager;
import com.example.coinflip.database.repository.CoinflipRepository;
import com.example.coinflip.database.repository.PlayerStatsRepository;
import com.example.coinflip.inventory.gui.GUIListener;
import com.example.coinflip.inventory.gui.GUIManager;
import com.example.coinflip.listener.PlayerListener;
import com.example.coinflip.manager.CoinflipManager;
import com.example.coinflip.manager.CooldownManager;
import com.example.coinflip.manager.EconomyManager;
import com.example.coinflip.service.CoinflipService;
import com.example.coinflip.service.ValidationService;
import com.example.coinflip.task.ExpirationTask;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class CoinflipPlugin extends JavaPlugin {
    private ConfigManager configManager;
    private MessageManager messageManager;
    private DatabaseManager databaseManager;
    private EconomyManager economyManager;
    private CoinflipManager coinflipManager;
    private CooldownManager cooldownManager;
    private GUIManager guiManager;
    
    private CoinflipRepository coinflipRepository;
    private PlayerStatsRepository statsRepository;
    
    private ValidationService validationService;
    private CoinflipService coinflipService;
    
    private CoinflipAPI api;
    
    private CreateSubcommand createSubcommand;
    private JoinSubcommand joinSubcommand;
    private CancelSubcommand cancelSubcommand;
    private HistorySubcommand historySubcommand;
    private StatsSubcommand statsSubcommand;
    private AdminSubcommand adminSubcommand;
    private ReloadSubcommand reloadSubcommand;

    @Override
    public void onEnable() {
        this.configManager = new ConfigManager(this);
        this.messageManager = new MessageManager(this);
        
        this.databaseManager = new DatabaseManager(this, this.configManager);
        this.databaseManager.connect();
        
        this.economyManager = new EconomyManager(this);
        if (this.configManager.isEconomyEnabled()) {
            if (!this.economyManager.setupEconomy()) {
                if (this.configManager.isVaultRequired()) {
                    this.getLogger().severe("Vault not found! Disabling plugin.");
                    this.getServer().getPluginManager().disablePlugin(this);
                    return;
                }
                this.getLogger().warning("Vault not found! Economy features disabled.");
            }
        }
        
        this.coinflipManager = new CoinflipManager();
        this.cooldownManager = new CooldownManager();
        this.guiManager = new GUIManager();
        
        this.coinflipRepository = new CoinflipRepository(this.databaseManager);
        this.statsRepository = new PlayerStatsRepository(this.databaseManager);
        
        this.validationService = new ValidationService(
            this.configManager,
            this.economyManager,
            this.coinflipManager,
            this.cooldownManager
        );
        
        this.coinflipService = new CoinflipService(
            this,
            this.configManager,
            this.messageManager,
            this.economyManager,
            this.coinflipManager,
            this.cooldownManager,
            this.coinflipRepository,
            this.statsRepository
        );
        
        this.api = new CoinflipAPI(this.coinflipManager, this.statsRepository);
        
        this.loadActiveCoinflips();
        
        this.createSubcommand = new CreateSubcommand(this, this.messageManager);
        this.joinSubcommand = new JoinSubcommand(this, this.messageManager);
        this.cancelSubcommand = new CancelSubcommand(this, this.messageManager, this.coinflipService);
        this.historySubcommand = new HistorySubcommand(this, this.messageManager);
        this.statsSubcommand = new StatsSubcommand(this, this.messageManager);
        this.adminSubcommand = new AdminSubcommand(this, this.messageManager);
        this.reloadSubcommand = new ReloadSubcommand(this, this.configManager, this.messageManager);
        
        CoinflipCommand coinflipCommand = new CoinflipCommand(this, this.messageManager);
        this.getCommand("coinflip").setExecutor(coinflipCommand);
        this.getCommand("coinflip").setTabCompleter(coinflipCommand);
        
        Bukkit.getPluginManager().registerEvents(new GUIListener(this.guiManager), this);
        Bukkit.getPluginManager().registerEvents(new PlayerListener(this.configManager, this.messageManager, this.coinflipManager), this);
        
        if (this.configManager.isExpirationEnabled()) {
            int intervalTicks = this.configManager.getExpirationCheckInterval() * 20;
            Bukkit.getScheduler().runTaskTimer(this, new ExpirationTask(this.coinflipManager, this.coinflipService), intervalTicks, intervalTicks);
        }
        
        this.getLogger().info("CoinflipPlugin enabled successfully!");
    }

    @Override
    public void onDisable() {
        if (this.databaseManager != null) {
            this.databaseManager.disconnect();
        }
        this.getLogger().info("CoinflipPlugin disabled successfully!");
    }

    private void loadActiveCoinflips() {
        this.coinflipRepository.getActiveCoinflips().thenAccept(coinflips -> {
            Bukkit.getScheduler().runTask(this, () -> {
                for (var coinflip : coinflips) {
                    if (coinflip.isExpired()) {
                        coinflip.setStatus(com.example.coinflip.model.Coinflip.CoinflipStatus.CANCELLED);
                        this.coinflipRepository.updateCoinflip(coinflip);
                    } else {
                        this.coinflipManager.addCoinflip(coinflip);
                    }
                }
                this.getLogger().info("Loaded " + coinflips.size() + " active coinflips from database.");
            });
        });
    }

    public ConfigManager getConfigManager() {
        return this.configManager;
    }

    public MessageManager getMessageManager() {
        return this.messageManager;
    }

    public DatabaseManager getDatabaseManager() {
        return this.databaseManager;
    }

    public EconomyManager getEconomyManager() {
        return this.economyManager;
    }

    public CoinflipManager getCoinflipManager() {
        return this.coinflipManager;
    }

    public CooldownManager getCooldownManager() {
        return this.cooldownManager;
    }

    public GUIManager getGuiManager() {
        return this.guiManager;
    }

    public CoinflipRepository getCoinflipRepository() {
        return this.coinflipRepository;
    }

    public PlayerStatsRepository getStatsRepository() {
        return this.statsRepository;
    }

    public ValidationService getValidationService() {
        return this.validationService;
    }

    public CoinflipService getCoinflipService() {
        return this.coinflipService;
    }

    public CoinflipAPI getAPI() {
        return this.api;
    }

    public CreateSubcommand getCreateSubcommand() {
        return this.createSubcommand;
    }

    public JoinSubcommand getJoinSubcommand() {
        return this.joinSubcommand;
    }

    public CancelSubcommand getCancelSubcommand() {