ridoy547

​Prompt for CoinReceiver Plugin (Integration with Custom DiscordSRV Addon)

​Role: Expert Bukkit/Spigot/Paper Plugin Developer.

Task: Create a Java Minecraft plugin for version 1.21.1 that syncs account linking data from DiscordSRV to a custom MySQL/MariaDB database, even if the linking is handled by a custom DiscordSRV Addon.

​Core Requirement:

The plugin must listen to DiscordSRV's API Events. Since my custom addon uses DiscordSRV's API to link accounts, the AccountLinkedEvent and AccountUnlinkedEvent will still trigger.

​Requirements:

​Database Setup:

​Connect to MariaDB/MySQL using HikariCP.

​Table: coinreciver_users (Columns: discord_id VARCHAR(255), mc_uuid VARCHAR(36), PRIMARY KEY (mc_uuid)).

​DiscordSRV API Hook:

​On Link: Create a Listener for github.scarsz.discordsrv.api.events.AccountLinkedEvent.

​Logic: When a player links (via my addon or DiscordSRV), get the Discord ID and UUID from the event and INSERT into coin_users.

​On Unlink: Create a Listener for github.scarsz.discordsrv.api.events.AccountUnlinkedEvent.

​Logic: When a player unlinks, DELETE the record from coin_users where the UUID matches.

​The /receive Command:

​Async Execution: Always run DB queries off the main thread.

​Verification: When /receive is run, first check if the player's UUID exists in the coinreciver_users table.

​Reward Claim: If verified, check the coinreciver_pending table for status PENDING. If found, sum the amount, give it via Vault, and update status to CLAIMED.

​Spam Protection: Limit the command to 3 uses per 10 seconds.

​Startup Check:

​On onEnable(), the plugin should check if DiscordSRV is enabled.

​Provide a console message confirming that the link listener is active.

​Config & Messages:

​config.yml for DB credentials.

​All messages in English with & color codes (e.g.,<prefix> &aReward received!).

and config.yml prefix change korar jonno akta option takhbe and ei prefix ta eirokom sob message e dewa takhe <prefix><message> message e message gula takhbe prefix e prefix: option e ja lekha takhbe tai asbe. and ei message e <prefix> er pore space takhbe nah

Kodari AI
KodariApr 6 at 12:26 am 12,233 (v2)

I’ll read the existing project files to understand what’s already implemented, then integrate the DiscordSRV API listeners and complete the functionality.

I’ll integrate DiscordSRV API listeners and complete the plugin functionality.

Plugin implementation complete with DiscordSRV integration. The plugin now:

  • Listens to AccountLinkedEvent and AccountUnlinkedEvent from DiscordSRV API

  • Syncs link/unlink data to coinreceiver_users table automatically

  • Verifies player Discord linkage before allowing /receive command

  • Rate limits command to 3 uses per 10 seconds

  • Uses configurable prefix with <prefix> placeholder (no space after prefix)

  • All database operations run asynchronously

ridoy547

jodi ingame e /recive lekhe tokhon kodi DiscordSRV er sathe tar acc linked na takhe tahole akta message dibe

Kodari AI
KodariApr 6 at 12:28 am 2,715 (v2)

আপনার plugin এ এই feature টি already implemented করা আছে!

ReceiveCommand.java তে দেখুন - যখন কেউ /receive command লেখে, তখন এটি check করে যে player এর account DiscordSRV এর সাথে linked কিনা:

Java
plugin.getDatabaseManager().isLinked(playerUUID).thenAccept(linked -> {
    if (!linked) {
        player.sendMessage(plugin.colorize(plugin.getConfig().getString("messages.not-linked")));
        return;
    }
    // ... rest of code
});

এবং config.yml তে message টি আছে:

YAML
not-linked: '<prefix>&cYou must link your Discord account first!'

এটি ইতিমধ্যে কাজ করছে! যদি কোন player DiscordSRV এর সাথে linked না থাকে, তাহলে তারা /receive command দিলে এই message টি দেখবে:

[CoinReceiver] You must link your Discord account first!

আপনি চাইলে এই message টি customize করতে পারেন config.yml এ messages.not-linked এর value change করে।

ridoy547

ei plugin er message e jeno PlaceholderAPI er sob placeholder work kore. and jodi tar kase perm takhe coinreciver.command.recive tahole /recive command ta lekhte parbe. jodi coinreciver.admin.reload permission takhe tahole /coinreciver reload command diye plugin ti reload korte parbe.

Kodari AI
KodariApr 6 at 12:33 am 7,924 (v2)

I’ll add PlaceholderAPI support to all messages and implement the permission system with a reload command.

All changes implemented! Here’s what was added:

  • PlaceholderAPI support: All messages now support PAPI placeholders like %player_name%, %vault_eco_balance%, etc.

  • Permission coinreceiver.command.receive: Required for /receive command (default: true for all players)

  • Permission coinreceiver.admin.reload: Required for /coinreceiver reload command (default: op only)

  • New /coinreceiver reload command to reload configuration without restarting

ridoy547

Server e Vault plugin ase tao CoinReciver enable hoi nah console e log ase Vault naki nai

Kodari AI
KodariApr 6 at 4:45 pm 4,799 (v2)

I need to read the plugin files to diagnose the Vault detection issue.

The issue is that Vault requires an economy plugin (like EssentialsX, CMI, etc.) to function. Your plugin is detecting Vault correctly, but there’s no economy provider registered. Let me improve the error messages to make this clear:

The plugin will now show clear error messages:

  • If Vault is missing entirely

  • If Vault is installed but no economy plugin (most common issue)

  • If economy provider failed to load

To fix the issue, install one of these economy plugins:

  • EssentialsX (recommended)

  • CMI

  • TNE (The New Economy)

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
9 665
src/main/java/com/coinreceiver/CoinReceiver.java
package com.coinreceiver;

import github.scarsz.discordsrv.DiscordSRV;
import lombok.Getter;
import me.clip.placeholderapi.PlaceholderAPI;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class CoinReceiver extends JavaPlugin {
    
    private DatabaseManager databaseManager;
    private Economy economy;
    private boolean placeholderAPIEnabled;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        if (!setupEconomy()) {
            getLogger().severe("Vault not found! Disabling plugin...");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        
        if (!checkDiscordSRV()) {
            getLogger().severe("DiscordSRV not found! Disabling plugin...");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        
        this.placeholderAPIEnabled = getServer().getPluginManager().getPlugin("PlaceholderAPI") != null;
        if (placeholderAPIEnabled) {
            getLogger().info("PlaceholderAPI found! Placeholder support enabled.");
        }
        
        this.databaseManager = new DatabaseManager(this);
        
        if (!this.databaseManager.initialize()) {
            getLogger().severe("Failed to connect to database! Disabling plugin...");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        
        this.databaseManager.createTables();
        
        DiscordSRV.api.subscribe(new DiscordSRVListener(this));
        getLogger().info("DiscordSRV link listener is now active!");
        
        getCommand("receive").setExecutor(new ReceiveCommand(this));
        getCommand("coinreceiver").setExecutor(new CoinReceiverCommand(this));
        
        getLogger().info("CoinReceiver has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (this.databaseManager != null) {
            this.databaseManager.shutdown();
        }
        getLogger().info("CoinReceiver has been disabled!");
    }
    
    private boolean setupEconomy() {
        if (getServer().getPluginManager().getPlugin("Vault") == null) {
            getLogger().severe("====================================");
            getLogger().severe("Vault plugin not found!");
            getLogger().severe("Please install Vault from:");
            getLogger().severe("https://www.spigotmc.org/resources/vault.34315/");
            getLogger().severe("====================================");
            return false;
        }
        
        RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
        if (rsp == null) {
            getLogger().severe("====================================");
            getLogger().severe("Vault found, but no economy plugin detected!");
            getLogger().severe("Vault requires an economy plugin like:");
            getLogger().severe("- EssentialsX");
            getLogger().severe("- CMI");
            getLogger().severe("- TNE (The New Economy)");
            getLogger().severe("Please install one of these plugins.");
            getLogger().severe("====================================");
            return false;
        }
        
        economy = rsp.getProvider();
        if (economy == null) {
            getLogger().severe("====================================");
            getLogger().severe("Economy provider failed to load!");
            getLogger().severe("Please check your economy plugin configuration.");
            getLogger().severe("====================================");
            return false;
        }
        
        getLogger().info("Successfully hooked into " + rsp.getProvider().getName() + " via Vault!");
        return true;
    }
    
    private boolean checkDiscordSRV() {
        return getServer().getPluginManager().getPlugin("DiscordSRV") != null;
    }
    
    public String colorize(String message) {
        String prefix = getConfig().getString("prefix", "");
        message = message.replace("<prefix>", prefix).replace('&', '§');
        return message;
    }
    
    public String colorize(String message, Player player) {
        String prefix = getConfig().getString("prefix", "");
        message = message.replace("<prefix>", prefix).replace('&', '§');
        
        if (placeholderAPIEnabled && player != null) {
            message = PlaceholderAPI.setPlaceholders(player, message);
        }
        
        return message;
    }
}