gol377_

write me a plugin that allows the chests to be opened every 4 hours and the chest will contain individual items for each player, which can be changed in the config

Kodari AI
KodariDec 29 at 10:43 pm 6,537 (v2)

I’ll create a timed chest rewards plugin where players can open chests every 4 hours to receive individual configurable items.

TimedChestRewards
A reward chest system that restricts chest access to once every 4 hours per player. Each player receives their own customized items from configured reward chests. Features include configurable cooldown periods, individual item distributions, persistent cooldown tracking, and customizable reward items with support for custom names, lore, and enchantments.

Plugin created! Features:

  • Timed access: Players can only open chests every 4 hours (configurable)

  • Individual rewards: Each player gets their own items from the config

  • Sneak to activate: Players must sneak + right-click chests to receive rewards

  • Persistent cooldowns: Saved across server restarts

  • Commands: /timedchest reload, /timedchest check, /timedchest reset <player>

  • Customizable items: Configure material, amount, name, lore, and enchantments

  • Cross-version compatible: Uses XSeries for 1.8-1.21+ support

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
8 520
src/main/java/com/timedchestrewards/TimedChestRewards.java
package com.timedchestrewards;

import com.timedchestrewards.command.ChestCommand;
import com.timedchestrewards.listener.ChestListener;
import com.timedchestrewards.manager.CooldownManager;
import com.timedchestrewards.manager.RewardManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class TimedChestRewards extends JavaPlugin {
    
    private CooldownManager cooldownManager;
    private RewardManager rewardManager;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.cooldownManager = new CooldownManager(this);
        this.rewardManager = new RewardManager(this);
        
        getServer().getPluginManager().registerEvents(new ChestListener(this), this);
        getCommand("timedchest").setExecutor(new ChestCommand(this));
        
        getLogger().info("TimedChestRewards has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (cooldownManager != null) {
            cooldownManager.saveData();
        }
        getLogger().info("TimedChestRewards has been disabled!");
    }
    
    public void reload() {
        reloadConfig();
        cooldownManager.loadData();
        rewardManager.loadRewards();
    }
}