Ramhet Meena

there are still some errors first the choose type when you use the choose type and click on any item and click on claim if you don't have key or even if you claim take back the player to the crates do not close the full crate menu second there are two sounds played one chest and one xp bottle so make sure only one sound is played that is xp or absorb second the message when you try to open the crate like preview the crate again and again it says please wait another seconds to use a key again instead the message should be please wait another seconds to preview the crate again if we are previewing next the random type in random type right clicking should preview the crate like the crate will we can preview the crate by opening and left clicking opens the crate if we have key we can always preview the crate if we don't have key also make sure to do this in no wait type right clicking preview left clicking claim and also when you when you are opening a crate random crate when you click escape menu instead of returning the key and cancelling the crate open skip the animation and just give the reward next the messages and sound on the key hall no messages is sent to the player so make sure to add action bar chat messages and sound when key all key is given to player next add a slash keys command I will send you the script file so make sure to add a keys command like that exactly like that next all the crates only have two to three items but I will send you the file and check there are many items so add all the items and make sure every single message has three types chat action bar and sound and all three are toggleable and editable every single crate name crate file name crate gui size every single thing is customizable nothing is hard coded and also add a slash key clear all command that clears a player's all key no matter virtual or physical all keys clear command should can also be done with console should support offline player And I am also attaching the crates file so make sure to add all the items of crates from that files all sounds are editable every message right click preview and left click claim on nowait and random cause we can preview with both click on choose type

📎 7 files 14,704 chars
📄
keys.sk
sk 33 lines
▶
Options:
    prefix: &8[&bKeys&8]&r
# Valid key types - matches your crate_keys_ placeholders
# amethyst, common, crimson, dark, gold, prime
# --- Tab completion: /keys  suggests key names ---
on tab complete for "/keys" Or "/key":
    set {_input} to raw tab complete argument 1
    add "amethyst" to tab completions
    add "common" to tab completions
    add "crimson" to tab completions
    add "dark" to tab completions
    add "gold" to tab completions
    add "prime" to tab completions
command /keys []:
    aliases: /key
    trigger:
        if arg-1 is not set:
            send "&cUsage: /keys " to player
            play sound "entity.villager.no" at player's location to player
            stop trigger
        set {_key} to arg-1
        if {_key} is not "amethyst", "common", "crimson", "dark", "gold" or "prime":
            send "&cThat crate doesn't exist." to player
            send action bar "&cThat crate doesn't exist." to player
            play sound "entity.villager.no" at player's location to player
            stop trigger
        set {_ph} to "crate_keys_%{_key}%"
        set {_amount} to the value of the placeholder {_ph} for player
        set {_msg} to "&7You have &b%{_amount}% &7%{_key}% keys"
        send {_msg} to player
        send action bar {_msg} to player
        play sound "entity.experience_orb.pickup" at player's location to player
📄
amethyst.yml
yml 119 lines
▶
amethyst-crate:
  inventory:
    name: 'ᴀᴍᴇᴛʜʏsᴛ ᴄʀᴀᴛᴇ'
    effect: CHOOSE
    rows: 3

  rewards:
    1:
      slot: 10
      icon:
        material: NETHERITE_AXE
        chance: 10%
        name: '&#A20AD6ᴀᴍᴇᴛʜʏsᴛ ᴀxᴇ'
        lore:
          - '&7Breaks Trees instantly'
          - '&8Self Destruct:'
          - '&82d 23h 59m'
        enchantments:
          mending: 1
          silk_touch: 1
          efficiency: 5
          unbreaking: 3
      commands:
        - 'tools give %player% treechopper'
    2:
      slot: 11
      icon:
        material: NETHERITE_AXE
        chance: 10%
        name: '&#A20AD6ᴀᴍᴇᴛʜʏsᴛ sᴇʟʟ ᴀxᴇ'
        lore:
          - '&7Instantly Sells All Items in A Chest'
          - '&8Self Destruct:'
          - '&82d 23h 59m'
        enchantments:
          mending: 1
          efficiency: 5
          unbreaking: 3
      commands:
        - 'sellaxe %player%'
    3:
      slot: 12
      icon:
        material: NETHERITE_PICKAXE
        chance: 10%
        name: '&#A20AD6ᴀᴍᴇᴛʜʏsᴛ ᴘɪᴄᴋᴀxᴇ'
        lore:
          - '&7Breaks 9 Blocks at Once'
          - '&8Self Destruct:'
          - '&82d 23h 59m'
        enchantments:
          mending: 1
          efficiency: 5
          unbreaking: 3
      commands:
        - 'tools give %player% drill'
    4:
      slot: 13
      icon:
        material: NETHERITE_SHOVEL
        chance: 10%
        name: '&#A20AD6ᴀᴍᴇᴛʏꜱᴛ ꜱʜᴏᴠᴇʟ'
        lore:
          - '&7Breaks 9 Blocks at Once'
          - '&8Self Destruct:'
          - '&82d 23h 59m'
        enchantments:
          mending: 1
          efficiency: 5
          unbreaking: 3
      commands:
        - 'tools give %player% shovel'
    5:
      slot: 14
      icon:
        material: NETHERITE_HOE
        chance: 10%
        name: '&#A20AD6ᴀᴍᴇᴛʏꜱᴛ ʜᴏᴇ'
        lore:
          - '&7Plants 9 Blocks at Once'
          - '&8Self Destruct:'
          - '&82d 23h 59m'
        enchantments:
          fortune: 3
          efficiency: 5
          unbreaking: 3
      commands:
        - 'tools give %player% hoe'
    6:
      slot: 15
      icon:
        material: WATER_BUCKET
        chance: 10%
        name: '&#A20AD6ᴀᴍᴇᴛʜʏꜱᴛ ᴡᴀᴛᴇʀ ʙᴜᴄᴋᴇᴛ'
        lore:
          - '&7Infinite Water Bucket'
          - '&8Durability:'
          - '&82d 23h 59m'
      commands:
        - 'tools give %player% waterbucket time 3d'
    7:
      slot: 16
      icon:
        material: FIREWORK_ROCKET
        chance: 10%
        name: '&#A20AD6ɪɴꜰɪɴɪᴛʏ ʀᴏᴄᴋᴇᴛ'
        lore:
          - '&7Boosts your Elytra flight'
          - '&8Durability:'
          - '&82d 23h 59m'
      commands:
        - 'tools give %player% rocket time 3d'
  back-button:
    enable: false
    displayname: '&#FF0000ᴄʟᴏꜱᴇ'
    material: RED_STAINED_GLASS_PANE
    slot: 18
    lore:
      - '&fClick to close'
📄
common.yml
yml 81 lines
▶
common-crate:
  inventory:
    name: ᴄᴏᴍᴍᴏɴ ᴄʀᴀᴛᴇ
    effect: CHOOSE # here you set it to choose or nowait (/dc seteffect  )
    rows: 3
  rewards:
    '1':
      slot: 10
      icon:
        material: DIAMOND_HELMET
        name: §2ᴄᴏᴍᴍᴏɴ ʜᴇʟᴍᴇᴛ
        enchantments:
          protection: 1
          respiration: 2
        trim:
          material: emerald
          pattern: wild
      chance: 100.0%
    '2':
      slot: 11
      icon:
        material: DIAMOND_CHESTPLATE
        name: §2ᴄᴏᴍᴍᴏɴ ᴄʜᴇsᴛᴘʟᴀᴛᴇ
        enchantments:
          protection: 1
        trim:
          material: emerald
          pattern: wild
      chance: 100.0%
    '3':
      slot: 12
      icon:
        material: DIAMOND_LEGGINGS
        name: §2ᴄᴏᴍᴍᴏɴ ʟᴇɢɢɪɴɢs
        enchantments:
          protection: 1
          swift_sneak: 2
        trim:
          material: emerald
          pattern: wild
      chance: 100.0%
    '4':
      slot: 13
      icon:
        material: DIAMOND_BOOTS
        name: §2ᴄᴏᴍᴍᴏɴ ʙᴏᴏᴛs
        enchantments:
          depth_strider: 2
          feather_falling: 2
          protection: 1
        trim:
          material: emerald
          pattern: wild
      chance: 100.0%
    '5':
      slot: 14
      icon:
        material: DIAMOND_SWORD
        name: §2ᴄᴏᴍᴍᴏɴ sᴡᴏʀᴅ
        enchantments:
          looting: 2
          sharpness: 1
      chance: 100.0%
    '6':
      slot: 15
      icon:
        material: DIAMOND_PICKAXE
        name: §2ᴄᴏᴍᴍᴏɴ ᴘɪᴄᴋᴀxᴇ
        enchantments:
          efficiency: 2
          fortune: 1
      chance: 100.0%
    '7':
      slot: 16
      icon:
        material: DIAMOND_SHOVEL
        name: §2ᴄᴏᴍᴍᴏɴ sʜᴏᴠᴇʟ
        enchantments:
          efficiency: 3
      chance: 100.0%
📄
crimson.yml
yml 97 lines
▶
crimson-crate:
  inventory:
    name: 'ᴄʀɪᴍsᴏɴ ᴄʀᴀᴛᴇ'
    effect: CHOOSE #here you set it to choose or nowait (/dc seteffect  )
    rows: 3

  rewards:
    1:
      slot: 10
      icon:
        material: NETHERITE_HELMET
        name: '&4ᴄʀɪᴍsᴏɴ ʜᴇʟᴍᴇᴛ'
        trim:
          material: redstone
          pattern: snout
        enchantments:
          protection: 4
          respiration: 3
          mending: 1
          thorns: 3
          unbreaking: 3
    2:
      slot: 11
      icon:
        material: NETHERITE_CHESTPLATE
        name: '&4ᴄʀɪᴍsᴏɴ ᴄʜᴇsᴛᴘʟᴀᴛᴇ'
        trim:
          material: redstone
          pattern: snout
        enchantments:
          protection: 4
          mending: 1
          thorns: 3
          unbreaking: 3
    3:
      slot: 12
      icon:
        material: NETHERITE_LEGGINGS
        name: '&4ᴄʀɪᴍsᴏɴ ʟᴇɢɢɪɴɢs'
        trim:
          material: redstone
          pattern: snout
        enchantments:
          protection: 4
          swift_sneak: 3
          mending: 1
          thorns: 3
          unbreaking: 3
    4:
      slot: 13
      icon:
        material: NETHERITE_BOOTS
        name: '&4ᴄʀɪᴍsᴏɴ ʙᴏᴏᴛs'
        trim:
          material: redstone
          pattern: snout
        enchantments:
          protection: 4
          depth_strider: 3
          feather_falling: 4
          mending: 1
          soul_speed: 3
          thorns: 3
          unbreaking: 3
    5:
      slot: 14
      icon:
        material: NETHERITE_SWORD
        name: '&4ᴄʀɪᴍsᴏɴ sᴡᴏʀᴅ'
        enchantments:
          sharpness: 5
          looting: 3
          fire_aspect: 2
          knockback: 2
          mending: 1
          unbreaking: 3
    6:
      slot: 15
      icon:
        material: NETHERITE_PICKAXE
        name: '&4ᴄʀɪᴍsᴏɴ ᴘɪᴄᴋᴀxᴇ'
        enchantments:
          mending: 1
          unbreaking: 3
          silk_touch: 1
          efficiency: 5
    7:
      slot: 16
      icon:
        material: NETHERITE_AXE
        name: '&4ᴄʀɪᴍsᴏɴ ᴀxᴇ'
        enchantments:
          efficiency: 5
          mending: 1
          sharpness: 5
          silk_touch: 1
          unbreaking: 3
📄
dark.yml
yml 131 lines
▶
dark-crate:
  inventory:
    name: 'ǡD59ᴅᴀʀᴋ ᴄʀᴀᴛᴇ'
    rows: 3
    effect: ROLLING
    filler-item:
      enable: FALSE
      material: BLACK_STAINED_GLASS_PANE
      name: ' '
  rewards:
    '1':
      slot: 9
      icon:
        material: NETHERITE_HELMET
        name: §x§4§8§1§D§5§9ᴅᴀʀᴋ ʜᴇʟᴍᴇᴛ
        enchantments:
          aqua_affinity: 1
          mending: 2
          protection: 6
          respiration: 4
          thorns: 4
          unbreaking: 4
        trim:
          material: netherite
          pattern: silence
      chance: 100.0%
    '2':
      slot: 10
      icon:
        material: NETHERITE_CHESTPLATE
        name: §x§4§8§1§D§5§9ᴅᴀʀᴋ ᴄʜᴇꜱᴛᴘʟᴀᴛᴇ
        enchantments:
          mending: 2
          protection: 6
          thorns: 4
          unbreaking: 4
        trim:
          material: netherite
          pattern: silence
      chance: 100.0%
    '3':
      slot: 11
      icon:
        material: NETHERITE_LEGGINGS
        name: §x§4§8§1§D§5§9ᴅᴀʀᴋ ʟᴇɢɢɪɴɢꜱ
        enchantments:
          mending: 2
          protection: 6
          swift_sneak: 3
          thorns: 4
          unbreaking: 4
        trim:
          material: netherite
          pattern: silence
      chance: 100.0%
    '4':
      slot: 12
      icon:
        material: NETHERITE_BOOTS
        name: §x§4§8§1§D§5§9ᴅᴀʀᴋ ʙᴏᴏᴛꜱ
        enchantments:
          depth_strider: 3
          feather_falling: 4
          mending: 2
          protection: 6
          soul_speed: 3
          thorns: 4
          unbreaking: 4
        trim:
          material: netherite
          pattern: silence
      chance: 100.0%
    '5':
      slot: 13
      icon:
        material: ELYTRA
        name: §x§4§8§1§D§5§9ᴅᴀʀᴋ ᴇʟʏᴛʀᴀ
        enchantments:
          mending: 3
          unbreaking: 5
      chance: 100.0%
    '6':
      slot: 14
      icon:
        material: NETHERITE_SWORD
        name: §x§4§8§1§D§5§9ᴅᴀʀᴋ ꜱᴡᴏʀᴅ
        enchantments:
          fire_aspect: 4
          knockback: 2
          looting: 4
          mending: 2
          sharpness: 6
          sweeping_edge: 4
          unbreaking: 4
      chance: 100.0%
    '7':
      slot: 15
      icon:
        material: NETHERITE_PICKAXE
        name: §x§4§8§1§D§5§9ᴅᴀʀᴋ ᴘɪᴄᴋᴀxᴇ
        enchantments:
          efficiency: 6
          fortune: 4
          mending: 2
          unbreaking: 4
      chance: 100.0%
    '8':
      slot: 16
      icon:
        material: NETHERITE_AXE
        name: §x§4§8§1§D§5§9ᴅᴀʀᴋ ᴀxᴇ
        enchantments:
          efficiency: 6
          fortune: 4
          mending: 2
          sharpness: 6
          unbreaking: 4
      chance: 100.0%
    '9':
      slot: 17
      icon:
        material: MACE
        name: §x§4§8§1§D§5§9ᴅᴀʀᴋ ᴍᴀᴄᴇ
        enchantments:
          density: 6
          fire_aspect: 4
          mending: 2
          unbreaking: 4
          wind_burst: 3
      chance: 100.0%
📄
gold.yml
yml 56 lines
▶
gold-crate:
  inventory:
    name: 'ɢᴏʟᴅ ᴄʀᴀᴛᴇ'
    effect: CHOOSE #here you set it to choose or nowait (/dc seteffect  )
    rows: 3

  rewards:
    1:
      slot: 10
      icon:
        material: SPAWNER
        name: '&dZombie Spawner'
      commands:
        - 'ss give spawner %player% zombie'
    2:
      slot: 11
      icon:
        material: SPAWNER
        name: '&dCave Spider Spawner'
      commands:
        - 'ss give spawner %player% cave_spider'
    3:
      slot: 12
      icon:
        material: SPAWNER
        name: '&dSkeleton Spawner'
      commands:
        - 'ss give spawner %player% skeleton'
    4:
      slot: 13
      icon:
        material: SPAWNER
        name: '&dCreeper Spawner'
      commands:
        - 'ss give spawner %player% creeper'
    5:
      slot: 14
      icon:
        material: SPAWNER
        name: '&dEnderman Spawner'
      commands:
        - 'ss give spawner %player% enderman'
    6:
      slot: 15
      icon:
        material: SPAWNER
        name: '&dIron Golem Spawner'
      commands:
        - 'ss give spawner %player% iron_golem'
    7:
      slot: 16
      icon:
        material: SPAWNER
        name: '&dSpider Spawner'
      commands:
        - 'ss give spawner %player% spider'
📄
prime.yml
yml 100 lines
▶
prime-crate:
  inventory:
    name: ᴘʀɪᴍᴇ ᴄʀᴀᴛᴇ
    effect: CHOOSE # here you set it to choose or nowait (/dc seteffect  )
    rows: 3'
  rewards:
    '1':
      slot: 10
      icon:
        material: NETHERITE_HELMET
        name: §3ᴘʀɪᴍᴇ ʜᴇʟᴍᴇᴛ
        enchantments:
          mending: 1
          protection: 4
          respiration: 3
          unbreaking: 3
        trim:
          material: diamond
          pattern: host
      chance: 100.0%
    '2':
      slot: 11
      icon:
        material: NETHERITE_CHESTPLATE
        name: §3ᴘʀɪᴍᴇ ᴄʜᴇsᴛᴘʟᴀᴛᴇ
        enchantments:
          mending: 1
          protection: 4
          unbreaking: 3
        trim:
          material: diamond
          pattern: host
      chance: 100.0%
    '3':
      slot: 12
      icon:
        material: NETHERITE_LEGGINGS
        name: §3ᴘʀɪᴍᴇ ʟᴇɢɢɪɴɢs
        enchantments:
          blast_protection: 4
          mending: 1
          swift_sneak: 3
          unbreaking: 3
        trim:
          material: diamond
          pattern: host
      chance: 100.0%
    '4':
      slot: 13
      icon:
        material: NETHERITE_BOOTS
        name: §3ᴘʀɪᴍᴇ ʙᴏᴏᴛs
        enchantments:
          depth_strider: 3
          feather_falling: 4
          mending: 1
          protection: 4
          soul_speed: 3
          unbreaking: 3
        trim:
          material: diamond
          pattern: host
      chance: 100.0%
    '5':
      slot: 14
      icon:
        material: NETHERITE_SWORD
        name: §3ᴘʀɪᴍᴇ sᴡᴏʀᴅ
        enchantments:
          knockback: 1
          looting: 3
          mending: 1
          sharpness: 5
          unbreaking: 3
      chance: 100.0%
    '6':
      slot: 15
      icon:
        material: CROSSBOW
        name: §3ᴘʀɪᴍᴇ ᴄʀᴏssʙᴏᴡ
        enchantments:
          mending: 1
          multishot: 1
          quick_charge: 3
          unbreaking: 3
      chance: 100.0%
    '7':
      slot: 16
      icon:
        material: MACE
        name: §x§2§5§9§6§B§Eᴘʀɪᴍᴇ ᴍᴀᴄᴇ
        enchantments:
          density: 5
          fire_aspect: 2
          mending: 1
          quick_charge: 3
          unbreaking: 3
          wind_burst: 3
      chance: 100.0%
Kodari AI
KodariOct 2 at 4:01 am 7
  1. Fix crate preview/claim navigation, cooldown wording, sound duplication, and escape-cancel behavior.

  2. Add key-give feedback, /keys, and console/offline-capable /key clearall.

  3. Import the supplied reward sets and make crate/message/sound settings configurable with chat, action-bar, and sound toggles.

  1. Crate flow: Right-click previews crates without a key; left-click opens or claims. Choose-type claims return to the reward menu whether the player lacks a key or receives the reward. Preview cooldowns now have their own message, and closing a random roll skips the animation and grants the selected reward. Successful claims play one configured reward sound.

  2. Keys: Added /keys <crate> (also /key) with tab completion and chat/action-bar feedback. /keys clearall <player> clears virtual keys immediately and removes physical keys when an offline player next joins; online players are cleared immediately. /dc keyall now notifies each recipient.

  3. Rewards and settings: Expanded the six bundled crate files to include the supplied rewards, added armor-trim loading, and merge missing bundled rewards into existing crate files without overwriting their custom entries. Chat, action-bar, and sound notifications now have global toggles and per-message text/sound settings. Crate names, reward menus, and GUI sizes remain YAML-configurable.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
38 2,917
src/main/java/com/kodari/crates/CratesPlugin.java
package com.kodari.crates;

import com.cryptomorin.xseries.XSound;
import com.cryptomorin.xseries.particles.XParticle;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import java.util.logging.Level;

/** Main entry point and orchestration layer for crate menus and reward delivery. */
public final class CratesPlugin extends JavaPlugin {
    private record OpenSession(Crate crate, Crate.Reward reward, Location block, KeyManager.Consumption consumption) { }

    private File configFile;
    private File langFile;
    private YamlConfiguration config;
    private YamlConfiguration lang;
    private DataStore dataStore;
    private CrateManager crateManager;
    private KeyManager keyManager;
    private final Map<UUID, OpenSession> sessions = new HashMap<>();
    private final Map<UUID, Long> cooldowns = new HashMap<>();
    private final Map<UUID, Long> previewCooldowns = new HashMap<>();
    private final Map<UUID, BukkitTask> rollingTasks = new HashMap<>();

    @Override
    public void onEnable() {
        installDefaultsOnce();
        mergeDefaultCrates();
        loadSettings();
        dataStore = new DataStore(this);
        crateManager = new CrateManager(this);
        crateManager.load();
        keyManager = new KeyManager(this);
        CratesCommand command = new CratesCommand(this);
        getCommand("dc").setExecutor(command);
        getCommand("dc").setTabCompleter(command);
        KeysCommand keysCommand = new KeysCommand(this);
        getCommand("keys").setExecutor(keysCommand);
        getCommand("keys").setTabCompleter(keysCommand);
        Bukkit.getPluginManager().registerEvents(new CrateListener(this), this);
        getLogger().info("Loaded " + crateManager.all().size() + " crate definition(s).");
    }

    @Override
    public void onDisable() {
        for (BukkitTask task : rollingTasks.values()) task.cancel();
        rollingTasks.clear();
        for (Map.Entry<UUID, OpenSession> entry : new ArrayList<>(sessions.entrySet())) {
            OpenSession session = entry.getValue();
            if (session.consumption() != null) {
                Player player = Bukkit.getPlayer(entry.getKey());
                if (player != null) keyManager.refund(player, session.crate().id(), session.consumption());
            }
        }
        sessions.clear();
        if (dataStore != null) dataStore.save();
    }

    private void installDefaultsOnce() {
        File folder = getDataFolder();
        if (folder.exists()) return;
        folder.mkdirs();
        try (InputStream indexStream = getResource("defaults/index.txt")) {
            if (indexStream == null) throw new IOException("defaults/index.txt is missing from the plugin jar");
            List<String> resources = new String(indexStream.readAllBytes(), java.nio.charset.StandardCharsets.UTF_8).lines()
                    .map(String::trim).filter(line -> !line.isEmpty()).toList();
            for (String relative : resources) {
                File target = new File(folder, relative);
                File parent = target.getParentFile();
                if (!parent.exists() && !parent.mkdirs()) throw new IOException("Could not create " + parent);
                try (InputStream source = getResource("defaults/" + relative)) {
                    if (source == null) throw new IOException("Missing bundled default defaults/" + relative);
                    Files.copy(source, target.toPath(), StandardCopyOption.REPLACE_EXISTING);
                }
            }
        } catch (IOException exception) {
            getLogger().log(Level.SEVERE, "Could not install the initial Crates configuration files.", exception);
        }
    }

    private void mergeDefaultCrates() {
        try (InputStream indexStream = getResource("defaults/index.txt")) {
            if (indexStream == null) return;
            for (String relative : new String(indexStream.readAllBytes(), java.nio.charset.StandardCharsets.UTF_8).lines()
                    .map(String::trim).filter(path -> path.startsWith("crates/") && path.endsWith(".yml")).toList()) {
                File target = new File(getDataFolder(), relative);
                File parent = target.getParentFile();
                if (!parent.exists() && !parent.mkdirs()) continue;
                try (InputStream source = getResource("defaults/" + relative)) {
                    if (source == null) continue;
                    YamlConfiguration defaults = YamlConfiguration.loadConfiguration(
                            new java.io.InputStreamReader(source, java.nio.charset.StandardCharsets.UTF_8));
                    YamlConfiguration current = YamlConfiguration.loadConfiguration(target);
                    String crateId = defaults.getKeys(false).stream().findFirst().orElse(null);
                    if (crateId == null) continue;
                    ConfigurationSection defaultRoot = defaults.getConfigurationSection(crateId);
                    ConfigurationSection defaultRewards = defaultRoot == null ? null : defaultRoot.getConfigurationSection("rewards");
                    if (defaultRewards != null) {
                        YamlConfiguration detachedRewards = new YamlConfiguration();
                        ConfigurationSection detached = detachedRewards.createSection("rewards");
                        copySection(defaultRewards, detached);
                        defaultRewards = detached;
                    }
                    defaults.set(crateId + ".rewards", null);
                    boolean changed = mergeMissing(current, defaults, "");
                    ConfigurationSection currentRoot = current.getConfigurationSection(crateId);
                    if (currentRoot != null && defaultRewards != null) {
                        ConfigurationSection currentRewards = currentRoot.getConfigurationSection("rewards");
                        if (currentRewards == null) currentRewards = currentRoot.createSection("rewards");
                        for (String rewardId : defaultRewards.getKeys(false)) {
                            ConfigurationSection defaultReward = defaultRewards.getConfigurationSection(rewardId);
                            if (defaultReward == null) continue;
                            ConfigurationSection matchingReward = currentRewards.getKeys(false).stream()
                                    .map(currentRewards::getConfigurationSection)
                                    .filter(java.util.Objects::nonNull)
                                    .filter(candidate -> sameReward(candidate, defaultReward))
                                    .findFirst().orElse(null);
                            if (matchingReward != null) {
                                changed |= mergeMissing(matchingReward, defaultReward, "");
                                continue;
                            }
                            String destinationId = rewardId;
                            if (currentRewards.contains(destinationId)) {
                                int nextId = currentRewards.getKeys(false).stream().mapToInt(key -> {
                                    try { return Integer.parseInt(key); } catch (NumberFormatException ignored) { return 0; }
                                }).max().orElse(0) + 1;
                                while (currentRewards.contains(String.valueOf(nextId))) nextId++;
                                destinationId = String.valueOf(nextId);
                            }
                            copySection(defaultReward, currentRewards.createSection(destinationId));
                            changed = true;
                        }
                    }
                    if (changed) current.save(target);
                }
            }
        } catch (IOException exception) {
            getLogger().log(Level.WARNING, "Could not merge bundled crate reward defaults.", exception);
        }
    }

    private boolean sameReward(ConfigurationSection first, ConfigurationSection second) {
        ConfigurationSection firstIcon = first.getConfigurationSection("icon");
        ConfigurationSection secondIcon = second.getConfigurationSection("icon");
        String firstMaterial = firstIcon == null ? "" : firstIcon.getString("material", "");
        String secondMaterial = secondIcon == null ? "" : secondIcon.getString("material", "");
        String firstName = firstIcon == null ? "" : firstIcon.getString("name", firstIcon.getString("displayname", ""));
        String secondName = secondIcon == null ? "" : secondIcon.getString("name", secondIcon.getString("displayname", ""));
        return firstMaterial.equalsIgnoreCase(secondMaterial) && firstName.equals(secondName);
    }

    private void copySection(ConfigurationSection source, ConfigurationSection target) {
        for (String key : source.getKeys(false)) {
            if (source.isConfigurationSection(key)) copySection(source.getConfigurationSection(key), target.createSection(key));
            else target.set(key, source.get(key));
        }
    }

    public void reloadPlugin() {
        for (UUID id : new ArrayList<>(sessions.keySet())) {
            Player player = Bukkit.getPlayer(id);
            if (player != null) cancelOpen(player);
        }
        loadSettings();
        dataStore.load();
        mergeDefaultCrates();
        crateManager.load();
        getLogger().info("Reloaded configuration and " + crateManager.all().size() + " crate(s).");
    }

    private void loadSettings() {
        if (!getDataFolder().exists()) getDataFolder().mkdirs();
        configFile = new File(getDataFolder(), "config.yml");
        langFile = new File(getDataFolder(), "lang.yml");
        config = loadAndMerge(configFile, "defaults/config.yml");
        lang = loadAndMerge(langFile, "defaults/lang.yml");