true_mat

can u combine the plugin with the resouce pack

Kodari AI
KodariAug 26 at 11:05 am 2
  1. Inspect the plugin and pack contents.

  2. Add the pack files/build packaging and connect custom items to client models.

  3. Add configurable automatic delivery on player join, then report any missing pack assets that prevent a usable ZIP.

Combined the plugin with the resource-pack setup.

Changes made:

  • Added resource-pack files under 543/src/main/resources/resourcepack.

  • Added pack.mcmeta.

  • Added model definitions for:

    • Blood Sword

    • Fire Sword

    • Thunder Axe

  • Connected those custom items to their Minecraft item models.

  • Added automatic resource-pack delivery when players join.

  • Added configurable settings in config.yml.

  • Added a Gradle task that creates:

    • build/resourcepack/CatalystSMP-resourcepack.zip

Configure this before enabling delivery:

YAML
resource-pack:
  enabled: true
  url: "https://your-domain.com/CatalystSMP-resourcepack.zip"
  sha1: ""
  prompt: "Download the CatalystSMP resource pack?"
  required: false

The ZIP must be uploaded to a publicly accessible HTTPS URL. The current pack includes placeholder models based on vanilla diamond weapons because the original folder only contained item JSON files and no custom textures or model geometry.

Kodari can make mistakes. Review important code before using.
Files
543
EchantedMC - Copy
Code
28 3,440
543/src/main/java/com/catalyst/smp/CatalystSMP.java
package com.catalyst.smp;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public final class CatalystSMP extends JavaPlugin {
    private CatalystItems items;
    private CatalystPoints points;
    private CatalystBosses bosses;
    private CatalystManager catalysts;
    private CombatEffects effects;
    private TrustManager trusts;
    private CatalystAuditLog auditLog;
    private CatalystListener listener;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        this.items = new CatalystItems(this);
        this.items.registerRecipes();
        this.auditLog = new CatalystAuditLog(this);
        this.points = new CatalystPoints(this, auditLog);
        this.effects = new CombatEffects();
        this.trusts = new TrustManager(this, auditLog);
        this.catalysts = new CatalystManager(this, items, effects, auditLog);
        this.bosses = new CatalystBosses(this, items, effects, auditLog);
        this.listener = new CatalystListener(this, items, points, bosses, catalysts, effects, trusts, auditLog);

        Bukkit.getPluginManager().registerEvents(listener, this);
        BossCommand bossCommand = new BossCommand(bosses, auditLog);
        getCommand("boss").setExecutor(bossCommand);
        getCommand("boss").setTabCompleter(bossCommand);
        CatalystCommand catalystCommand = new CatalystCommand(items, points, catalysts, auditLog);
        getCommand("catalyst").setExecutor(catalystCommand);
        getCommand("catalyst").setTabCompleter(catalystCommand);
        TrustCommand trustCommand = new TrustCommand(trusts, auditLog);
        getCommand("trust").setExecutor(trustCommand);
        getCommand("trust").setTabCompleter(trustCommand);
        listener.startPassiveTask();
        auditLog.log("PLUGIN enabled");
    }

    @Override
    public void onDisable() {
        if (auditLog != null) {
            auditLog.log("PLUGIN disabled");
        }
        if (points != null) {
            points.save();
        }
        if (catalysts != null) {
            catalysts.save();
        }
        if (bosses != null) {
            bosses.shutdown();
        }
    }

    public void sendResourcePack(Player player) {
        if (!getConfig().getBoolean("resource-pack.enabled", false)) {
            return;
        }

        String url = getConfig().getString("resource-pack.url", "").trim();
        if (url.isEmpty()) {
            return;
        }

        String sha1 = getConfig().getString("resource-pack.sha1", "").trim();
        byte[] hash = sha1.isEmpty() ? null : decodeSha1(sha1);
        String prompt = getConfig().getString("resource-pack.prompt", "Download the CatalystSMP resource pack?");
        boolean required = getConfig().getBoolean("resource-pack.required", false);
        player.setResourcePack(url, hash, prompt, required);
    }

    private byte[] decodeSha1(String value) {
        if (!value.matches("(?i)[0-9a-f]{40}")) {
            getLogger().warning("resource-pack.sha1 must be exactly 40 hexadecimal characters; ignoring it.");
            return null;
        }

        byte[] hash = new byte[20];
        for (int i = 0; i < hash.length; i++) {
            hash[i] = (byte) Integer.parseInt(value.substring(i * 2, i * 2 + 2), 16);
        }
        return hash;
    }
}