patrik1103
📎 1 file 2,185 chars
📄
pasted-code-1776174788794.txt
txt 84 lines
▶
Create a complete Minecraft Paper plugin (version 1.21.x) in Java with the following features:

GENERAL:

* The plugin should implement a reward system with 3 reward types:

  1. Hourly rewards (claimable every 1 hour)
  2. Daily rewards (claimable every 24 hours)
  3. Weekly rewards (claimable every 7 days)

INVENTORY GUI:

* All rewards must be displayed in ONE inventory INVENTORY GUI
* The INVENTORY GUI should have 3 rows:

  * Row 1: Hourly rewards
  * Row 2: Daily rewards
  * Row 3: Weekly rewards
* Each reward should be represented as an item in the INVENTORY GUI
* Each item must display:

  * Reward name
  * Description
  * Cooldown timer (e.g. "Available in 01:23:45")
  * Status (Ready / Not Ready)

FUNCTIONALITY:

* Players can click items to claim rewards
* If the reward is not ready, prevent claiming and show remaining time
* If ready, give reward and reset cooldown

CONFIG:

* Include a config.yml where I can configure:

  * Reward types (items, XP, etc.)
  * Reward amounts
  * Cooldown durations
  * INVENTORY GUI item materials and names
  * Commands that will be executed when a reward is claimed

* Commands must support placeholders:

  * %player% → player name

* Example:
  commands:

  * "eco give %player% 1000"
  * "crate give %player% vote 1"

* Commands should be executed by console

DATA:

* Save player data (UUID-based)
* Store last claim times for hourly, daily, weekly rewards
* Data must persist after server restart (YAML or database)

TECHNICAL:

* Use Paper API
* Use clean OOP structure (separate classes like RewardManager, GUIManager, DataManager)
* Use listeners for inventory clicks
* Update INVENTORY GUI dynamically (refresh timers every second or few seconds)
* Prevent exploits (validate everything server-side)

COMMANDS:

* /rewards → opens the INVENTORY GUI

EXTRA:

* Use color codes in messages
* Make code clean, well-structured, and commented
* Ensure compatibility with Paper 1.21.x

OUTPUT:

* Provide full plugin source code
* Include main class, plugin.yml, and all required classes
* Include example config.yml with command rewards
Kodari AI
KodariApr 14 at 1:55 pm 14,826 (v2)
RewardsPlugin
A comprehensive reward system plugin for Paper 1.21.x featuring hourly, daily, and weekly claimable rewards. Displays all rewards in a single 3-row inventory GUI with live cooldown timers that refresh every second. Fully configurable via config.yml: reward items, names, lore, XP, and console commands with %player% placeholder support. UUID-based persistent player data survives restarts. Includes exploit prevention, clean OOP architecture, and a single /rewards command to open the GUI.
  • Main plugin + 5 managers: ConfigManager, DataManager, RewardManager, GUIManager, refresh task

  • Full GUI framework (InventoryHandler, InventoryButton, InventoryGUI, GUIListener) + RewardsGUI impl

  • Config-driven rewards: each type (hourly/daily/weekly) supports multiple rewards placed by slot in their row

Done. Here’s a summary of what was built:

  • RewardsPlugin — main class wiring all managers together and scheduling the refresh task

  • ConfigManager — parses config.yml into typed RewardEntry objects per RewardType

  • DataManager — UUID-keyed YAML persistence for last-claim timestamps, with in-memory caching

  • RewardManager — cooldown validation, claiming logic (commands + XP), and time formatting

  • GUI framework — reusable InventoryGUI/InventoryButton/GUIManager/GUIListener system

  • RewardsGUI — 27-slot inventory (3 rows × type), gray-glass filler background, per-reward buttons with live ✓/✗ status and countdown timer; refreshed every second via GUIRefreshTask

  • config.yml — example with 2 rewards per type, demonstrating eco give, crate give, kit give, and LuckPerms commands with %player% placeholder

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
18 864
src/main/java/com/example/rewardsplugin/RewardsPlugin.java
package com.example.rewardsplugin;

import com.example.rewardsplugin.command.RewardCommand;
import com.example.rewardsplugin.config.ConfigManager;
import com.example.rewardsplugin.data.DataManager;
import com.example.rewardsplugin.inventory.gui.GUIListener;
import com.example.rewardsplugin.inventory.gui.GUIManager;
import com.example.rewardsplugin.reward.RewardManager;
import com.example.rewardsplugin.task.GUIRefreshTask;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class RewardsPlugin extends JavaPlugin {

    private ConfigManager configManager;
    private DataManager dataManager;
    private RewardManager rewardManager;
    private GUIManager guiManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        this.configManager = new ConfigManager(this);
        this.dataManager = new DataManager(this);
        this.rewardManager = new RewardManager(this);
        this.guiManager = new GUIManager(this);

        getServer().getPluginManager().registerEvents(new GUIListener(guiManager), this);
        getCommand("rewards").setExecutor(new RewardCommand(this));

        new GUIRefreshTask(this).runTaskTimer(this, 20L, 20L);
    }

    @Override
    public void onDisable() {
        if (dataManager != null) {
            dataManager.saveAll();
        }
    }
}