porilia

eikhane sobar upore "#" diye lekha ase kontar kaj ki. akhon eitao fix kore daw.

📎 1 file 2,009 chars
📄
pasted-code-1774426924001.txt
txt 24 lines
▶
# Minecraft group <-> Discord role synchronization
# Requires Vault
#
# GroupRoleSynchronizationGroupsAndRolesToSync: these are roles/groups you'd like synchronized between Discord and Minecraft
#                                               {"MC_GROUP_NAME": "DISCORD_ROLE_ID"} is the format to go by when adding more group/role pairs
#                                               to get your Discord guild's role IDs, run "/discord debug" and look at the first section
# GroupRoleSynchronizationMinecraftIsAuthoritative: whether Minecraft group changes override Discord role changes
# GroupRoleSynchronizationOneWay: whether to synchronise only one way, the way it is synchronised depends on the value
#                                 of GroupRoleSynchronizationMinecraftIsAuthoritative.
# GroupRoleSynchronizationEnableDenyPermission: whether discordsrv.sync.deny. permissions are enabled
# GroupRoleSynchronizationPrimaryGroupOnly: if true, only the player's primary group is counted for synchronization,
#                                           otherwise, group sync counts all groups the player is in, including parent groups
# GroupRoleSynchronizationOnLink: whether to resync when a player links
# GroupRoleSynchronizationCycleTime: amount of minutes between repeatedly triggering synchronization for all online players
# GroupRoleSynchronizationCycleCompletely: whether synchronizations running on a timer should synchronize every member in the bots Discord servers
#
GroupRoleSynchronizationGroupsAndRolesToSync: {"trusted": "000000000000000000", "vip": "000000000000000000"}
GroupRoleSynchronizationMinecraftIsAuthoritative: true
GroupRoleSynchronizationOneWay: false
GroupRoleSynchronizationEnableDenyPermission: false
GroupRoleSynchronizationPrimaryGroupOnly: false
GroupRoleSynchronizationOnLink: true
GroupRoleSynchronizationCycleTime: 5
GroupRoleSynchronizationCycleCompletely: false     .... eitar kaj ki oita upore lekha ase. eita jeno work kore account link korar sathe sathe.
Kodari AI
KodariMar 25 at 8:25 am 19,392 (v2)

Bujhechhi! User group/role synchronization feature implement korte hobe - mane Minecraft e kono player “trusted” ba “vip” group e thakle, Discord e automatically tader sei role add hobe. Chalun age code dekhche:

Thik ache! Group/Role synchronization feature add korchi. Jkhn player link korbe, tader Minecraft group (trusted, vip) automatically Discord e role pabe.

Perfect! Group/Role synchronization feature implement kora hoyeche. Ekhon:

Key Features:

  • Account link korar sathe sathe Minecraft group automatice Discord role e sync hobe

  • synchronization.yml file theke config read kore (DiscordSRV er moto)

  • Minecraft group → Discord role mapping support kore

  • One-way/two-way sync support

  • Periodic auto-sync (configurable minutes)

  • Vault permission system use kore group detect kore

  • Primary group only ba all groups support

Configuration Example (DiscordSRV/synchronization.yml):

YAML
GroupRoleSynchronizationGroupsAndRolesToSync: {"trusted": "123456789012345678", "vip": "987654321098765432"}
GroupRoleSynchronizationMinecraftIsAuthoritative: true
GroupRoleSynchronizationOnLink: true
GroupRoleSynchronizationCycleTime: 5

Player jkhn link korbe, automatically tader Minecraft group check kore Discord e role add/remove korbe!

porilia

jokhon unlink korbe othoba group/rank soriye nile ba expire hoye gele role remove hobe?

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
23 1,933
src/main/java/com/niloy/discordsrvlinkembed/DiscordSRVLinkingEmbed.java
package com.niloy.discordsrvlinkembed;

import com.niloy.discordsrvlinkembed.commands.ReloadCommand;
import com.niloy.discordsrvlinkembed.config.ConfigManager;
import com.niloy.discordsrvlinkembed.config.EmbedConfig;
import com.niloy.discordsrvlinkembed.discord.DiscordListener;
import com.niloy.discordsrvlinkembed.discord.DiscordSRVEventListener;
import com.niloy.discordsrvlinkembed.license.LicenseManager;
import com.niloy.discordsrvlinkembed.storage.AOFStorage;
import com.niloy.discordsrvlinkembed.storage.MySQLStorage;
import com.niloy.discordsrvlinkembed.storage.StorageManager;
import com.niloy.discordsrvlinkembed.sync.GroupRoleSyncManager;
import com.niloy.discordsrvlinkembed.sync.NicknameSyncManager;
import github.scarsz.discordsrv.DiscordSRV;
import github.scarsz.discordsrv.dependencies.jda.api.JDA;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class DiscordSRVLinkingEmbed extends JavaPlugin {
    
    @Getter
    private static DiscordSRVLinkingEmbed instance;
    
    private ConfigManager configManager;
    private EmbedConfig embedConfig;
    private StorageManager storageManager;
    private DiscordListener discordListener;
    private DiscordSRVEventListener discordSRVEventListener;
    private NicknameSyncManager nicknameSyncManager;
    private GroupRoleSyncManager groupRoleSyncManager;
    
    @Override
    public void onEnable() {
        instance = this;

        log("========================================");
        log("Loading license configuration...");
        log("========================================");

        LicenseManager licenseManager = new LicenseManager(this);
        if (!licenseManager.verifyLicense()) {
            logSevere("========================================");
            logSevere("Plugin will not load until license is valid!");
            logSevere("========================================");
            Bukkit.getScheduler().runTask(this, () -> 
                Bukkit.getPluginManager().disablePlugin(this)
            );
            return;
        }

        if (!setupDiscordSRV()) {
            logSevere("DiscordSRV not found! Disabling plugin...");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }

        log("Loading config.yml...");
        saveDefaultConfig();
        this.configManager = new ConfigManager(this);
        
        log("Loading embed configurations...");
        this.embedConfig = new EmbedConfig(this);
        
        if (!setupStorage()) {
            logSevere("Failed to setup storage! Disabling plugin...");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        
        if (!setupDiscordListener()) {
            logSevere("Failed to setup Discord listener! Disabling plugin...");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        
        getCommand("linkingaddon").setExecutor(new ReloadCommand(this));
        
        this.discordSRVEventListener = new DiscordSRVEventListener(this);
        DiscordSRV.api.subscribe(discordSRVEventListener);
        
        this.nicknameSyncManager = new NicknameSyncManager(this);
        this.groupRoleSyncManager = new GroupRoleSyncManager(this);
        
        log("DiscordSRVLinkingEmbed has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (nicknameSyncManager != null) {
            nicknameSyncManager.stopSyncTask();
        }
        
        if (groupRoleSyncManager != null) {
            groupRoleSyncManager.stopSyncTask();
        }
        
        if (storageManager != null) {
            storageManager.close();
        }
        
        if (discordListener != null) {
            JDA jda = DiscordSRV.getPlugin().getJda();
            if (jda != null) {
                jda.removeEventListener(discordListener);
            }
        }
        
        if (discordSRVEventListener != null) {
            DiscordSRV.api.unsubscribe(discordSRVEventListener);
        }
        
        log("DiscordSRVLinkingEmbed has been disabled!");
    }
    
    private boolean setupDiscordSRV() {
        return Bukkit.getPluginManager().getPlugin("DiscordSRV") != null;
    }
    
    private boolean setupStorage() {
        boolean useMysql = configManager.isMysqlEnabled();
        
        if (useMysql) {
            log("Attempting to use MySQL storage...");
            StorageManager mysqlStorage = new MySQLStorage(this);
            
            if (mysqlStorage.initialize()) {
                this.storageManager = mysqlStorage;
                log("Successfully connected to MySQL!");
                return true;
            } else {
                logWarning("MySQL connection failed! Falling back to AOF storage...");
            }
        }
        
        log("Using AOF file storage...");
        this.storageManager = new AOFStorage(this);
        return storageManager.initialize();
    }
    
    private boolean setupDiscordListener() {
        JDA jda = DiscordSRV.getPlugin().getJda();
        if (jda == null) {
            logWarning("JDA not ready yet, will retry in 5 seconds...");
            Bukkit.getScheduler().runTaskLater(this, () -> {
                if (!setupDiscordListener()) {
                    logSevere("Failed to setup Discord listener after retry!");
                    Bukkit.getPluginManager().disablePlugin(this);
                }
            }, 100L);
            return true;
        }

        this.discordListener = new DiscordListener(this);
        jda.addEventListener(discordListener);
        log("Discord listener registered successfully!");
        return true;
    }
    
    public void reload() {
        configManager.reload();
        embedConfig.reload();
        if (nicknameSyncManager != null) {
            nicknameSyncManager.reload();
        }
        if (groupRoleSyncManager != null) {
            groupRoleSyncManager.reload();
        }
        log("Configuration and embeds reloaded!");
    }

    public static void log(String message) {
        instance.getLogger().info(message);
    }

    public static void logWarning(String message) {
        instance.getLogger().warning(message);
    }

    public static void logSevere(String message) {
        instance.getLogger().severe(message);
    }
}