K

Rename build. file to build.gradle and paste this code,,,,

📎 1 file 1,540 chars
📄
pasted-code-1782404949962.txt
txt 50 lines
▶
plugins {
    id 'java'
}

group = 'com.niloy'
version = '2.0'

repositories {
    mavenCentral()
    maven { url 'https://repo.papermc.io/repository/maven-public/' }
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    maven { url 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
    // JitPack layer local bypass configuration handling jate build crash na khay
    maven { url 'https://jitpack.io' }
}

dependencies {
    compileOnly 'io.papermc.paper:paper-api:26.1.2.build.66-stable'
    compileOnly 'me.clip:placeholderapi:2.11.5'
    compileOnly 'com.github.NuVotifier:NuVotifier:2.7.3'
    compileOnly 'org.projectlombok:lombok:1.18.30'
    annotationProcessor 'org.projectlombok:lombok:1.18.30'
}

java {
    sourceCompatibility = JavaVersion.VERSION_25
    targetCompatibility = JavaVersion.VERSION_25
}

jar {
    from configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    
    // Core manifest declaration
    manifest {
        attributes(
            'Main-Class': 'com.auluckyblockparty.AuLuckyBlockParty'
        )
    }

    // --- AUTOMATED COMPILE-TIME OBFUSCATION TASK ---
    // Kodari compiler system wrapper flow optimization
    doLast {
        println "[Obfuscation System] Starting bytecode masking rules..."
        
        // Ekhane system post-compile runtime analysis logic execute korbe
        // Jate dynamic class configurations safe level optimization generate hoy
    }
}
Kodari AI
KodariJun 25 at 4:29 pm 3

Updated build.gradle with the provided configuration.

Kodari can make mistakes. Review important code before using.
Files
src
build_copy.gradle
build.gradle
README.md
Code
25 2,327
src/main/java/com/auluckyblockparty/AuLuckyBlockParty.java
package com.auluckyblockparty;

import com.auluckyblockparty.license.LicenseCommand;
import com.auluckyblockparty.license.LicensedCommandExecutor;
import com.auluckyblockparty.license.LicenseManager;
import com.niloy.auluckyblockparty.*;
import com.niloy.auluckyblockparty.command.LvpCommand;
import com.niloy.auluckyblockparty.listener.BlockInteractListener;
import com.niloy.auluckyblockparty.listener.VoteListener;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class AuLuckyBlockParty extends JavaPlugin {

    private LicenseManager licenseManager;
    
    // Feature managers
    private ConfigManager configManager;
    private DataManager dataManager;
    private VoteManager voteManager;
    private BlockManager blockManager;
    private RewardManager rewardManager;
    private HologramManager hologramManager;

    // Guards against loadFeatures() being called more than once.
    private boolean featuresLoaded = false;

    @Override
    public void onEnable() {
        // Step 1: Create the data folder and save license.yml only
        if (!getDataFolder().exists()) {
            getDataFolder().mkdirs();
        }
        saveLicenseConfig();

        // Step 2: Bootstrap the license subsystem
        licenseManager = new LicenseManager(this);

        // Register the license-reload command immediately - it must always work.
        PluginCommand adminCmd = getCommand("admin");
        if (adminCmd != null) {
            LicenseCommand licenseCommand = new LicenseCommand(this, licenseManager);
            adminCmd.setExecutor(licenseCommand);
            adminCmd.setTabCompleter(licenseCommand);
        }

        // Step 3: Async license check - no other files loaded until valid
        // Auto-gate all feature commands immediately, before the async check finishes.
        // This prevents a tiny race window where a command could fire before the
        // async verification returns its result.
        autoGateAllCommands();

        licenseManager.verifyAsync(
                /* onValid   */ this::loadFeatures,
                /* onInvalid */ this::disableFeatures
        );
    }

    @Override
    public void onDisable() {
        // Clean shutdown - cancel any tasks, close resources, etc.
        if (featuresLoaded) {
            if (hologramManager != null) {
                hologramManager.removeHologram();
            }
            if (voteManager != null && voteManager.isEventActive()) {
                blockManager.deactivateBlock();
            }
            if (dataManager != null) {
                dataManager.save();
            }
        }
        getLogger().info("AuLuckyBlockParty has been disabled.");
    }

    // Feature gate

    /**
     * Called exactly once when the license first becomes valid (either on startup
     * or after a successful /admin license-reload while previously invalid).
     * Loads config.yml and data.yml and registers all plugin internals.
     */
    public void loadFeatures() {
        if (featuresLoaded) return;
        featuresLoaded = true;

        getLogger().info("License validated. Loading plugin features...");

        // Load configuration files - only when license is valid
        saveDefaultConfig();

        // Initialize all managers
        configManager = new ConfigManager(this);
        dataManager = new DataManager(this);
        voteManager = new VoteManager(this);
        blockManager = new BlockManager(this);
        rewardManager = new RewardManager(this);
        hologramManager = new HologramManager(this);

        // Register feature commands
        registerLicensedCommand("lvp", new LvpCommand(this));

        // Register event listeners
        Bukkit.getPluginManager().registerEvents(new BlockInteractListener(this), this);

        // Hook Votifier if present
        if (Bukkit.getPluginManager().getPlugin("Votifier") != null
                || Bukkit.getPluginManager().getPlugin("NuVotifier") != null) {
            Bukkit.getPluginManager().registerEvents(new VoteListener(this), this);
            getLogger().info("Votifier hooked successfully.");
        }

        // Hook PlaceholderAPI if present
        if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
            new AuLuckyBlockPartyPlaceholder(this).register();
            getLogger().info("PlaceholderAPI hooked successfully.");
        }

        getLogger().info("AuLuckyBlockParty is fully enabled.");
    }

    /**
     * Unloads all features when license becomes invalid.
     * Saves data, cleans up resources, and nullifies all managers.
     */
    public void unloadFeatures() {
        if (!featuresLoaded) return;

        getLogger().warning("License is invalid. Unloading all features...");

        // Save data before shutdown
        if (dataManager != null) {
            dataManager.save();
        }

        // Clean up hologram
        if (hologramManager != null) {
            hologramManager.removeHologram();
        }

        // Stop active events
        if (voteManager != null && voteManager.isEventActive()) {
            blockManager.deactivateBlock();
        }

        // Nullify all managers - config.yml and data.yml no longer accessible
        configManager = null;
        dataManager = null;
        voteManager = null;
        blockManager = null;
        rewardManager = null;
        hologramManager = null;

        featuresLoaded = false;
        getLogger().warning("All features have been disabled. Config and data files are no longer loaded.");
    }

    private void disableFeatures() {
        unloadFeatures();
    }

    // Helpers

    /**
     * Registers a command executor behind the license gate.
     * If the command was already auto-gated by autoGateAllCommands(), this replaces
     * the inner delegate instead of stacking a second wrapper on top.
     *
     * @param commandName name as declared in plugin.yml (without the slash)
     * @param executor    the real executor to delegate to when license is valid
     */
    public void registerLicensedCommand(String commandName, CommandExecutor executor) {
        PluginCommand cmd = getCommand(commandName);
        if (cmd == null) {
            getLogger().warning("Command '" + commandName + "' is not declared in plugin.yml.");
            return;
        }
        // Always create a fresh wrapper with the real executor - avoids double-wrapping.
        cmd.setExecutor(new LicensedCommandExecutor(licenseManager, executor));
        
        // Set tab completer if executor supports it
        if (executor instanceof org.bukkit.command.TabExecutor) {
            cmd.setTabCompleter((org.bukkit.command.TabExecutor) executor);
        }
    }

    /**
     * Automatically wraps ALL commands declared in plugin.yml (except "admin") with
     * LicensedCommandExecutor. This is called immediately in onEnable() so that even
     * commands whose real executors haven't been set yet are gated - they will block
     * with the license error message until loadFeatures() sets the real executor
     * (which itself is wrapped).
     *
     * This means developers NEVER need to remember to call registerLicensedCommand();
     * every new command added to plugin.yml is automatically protected.
     */