Dominykas Sadauskas
📎 1 file 2,088 chars
📄
pasted-code-1792147637342.txt
txt 58 lines
▶
# Create a Complete Minecraft Plugin: KaimukoRewards

Develop a fully functional, professional Minecraft plugin called **KaimukoRewards** for my Minecraft survival server **KaimukoSMP**.

**Requirements:**
- Minecraft: Paper 1.21.11
- Java 21
- Build system: Maven
- Plugin name: KaimukoRewards
- Main package: `lt.kaimukosmp.rewards`

### Daily Rewards GUI
Create a beautiful, modern 27-slot inventory GUI opened with `/rewards`.

Features:
- Seven daily reward slots.
- Green, black, gold, and white design matching KaimukoSMP.
- Different icons for available, locked, and claimed rewards.
- Display the player's current streak, next reward, and cooldown.
- Configurable inventory title, item materials, names, lore, and slots.
- Prevent players from taking or moving GUI items.

### Seven-Day Reward System
Configure these example rewards:

- Day 1: 100 coins.
- Day 2: 250 coins.
- Day 3: 500 coins.
- Day 4: One crate key.
- Day 5: 750 coins.
- Day 6: 1,000 coins.
- Day 7: 2,500 coins and one crate key.

Players can claim one reward every 24 hours by default. Reset their streak after 48 hours without claiming a reward. After Day 7, the next cycle starts at Day 1.

Save all player data persistently using UUIDs. Prevent duplicate claims, cooldown bypasses, and GUI exploits.

### Commands
- `/rewards` — open the rewards GUI.
- `/daily` — alias for `/rewards`.
- `/dienosdovanos` — Lithuanian alias.
- `/rewardadmin reload` — reload the configuration.
- `/rewardadmin reset ` — reset a player's streak.
- `/rewardadmin setday  <1-7>` — set reward progression.
- `/rewardadmin give  ` — manually grant a configured reward.
- `/rewardadmin info ` — view reward statistics.

Include tab completion for administrative commands.

### Permissions
- `kaimukorewards.use` — default true.
- `kaimukorewards.admin` — default op.
- `kaimukorewards.bypass.cooldown` — default op.
- `kaimukorewards.give` — default op.

### Configuration
Create a complete `config.yml` with:
- All seven rewards and
Kodari AI
KodariOct 16 at 10:54 am 1
KaimukoRewards
A daily rewards plugin for KaimukoSMP survival server featuring a modern 27-slot GUI with seven configurable daily rewards. Players claim one reward every 24 hours via /rewards, /daily, or /dienosdovanos commands. The system tracks persistent player streaks by UUID, resets streaks after 48 hours of inactivity, and cycles back to Day 1 after Day 7. Admin commands include reload, reset, setday, give, and info with tab completion. Permissions control usage, admin access, cooldown bypass, and manual reward granting. All reward items, materials, names, lore, and GUI slots are fully configurable in config.yml. The GUI uses green, black, gold, and white design with distinct icons for available, locked, and claimed rewards, preventing item movement or exploitation.
  1. Set up a Java 21 Maven Paper plugin with the requested metadata and permissions.

  2. Implement UUID-based persistent reward progression, cooldowns, and streak resets.

  3. Add a configurable, protected 27-slot rewards GUI.

  4. Register player/admin commands, aliases, and tab completion.

Created KaimukoRewards with Java 21 Maven setup, Paper plugin metadata, a UUID-based player data store, and a configurable 27-slot rewards menu. It includes the seven-day reward cycle, 24-hour cooldown, 48-hour streak reset, protected GUI clicks/drags, the requested commands and aliases, permissions, and admin tab completion.

The example coin and crate rewards use configurable console commands in config.yml. Adjust those commands to match the economy and crate plugins installed on KaimukoSMP.

Dominykas Sadauskas

im doing on gravel host

Kodari AI
KodariOct 16 at 11:04 am 1

That’s fine—Gravel Host doesn’t require changes to the plugin. Make sure your server is running Paper 1.21.11 with Java 21, then compile the project in Kodari and upload the downloaded JAR to the server’s plugins folder using Gravel’s file manager. Restart the server to generate the config.

You’ll also need to set the coin and crate-key commands in config.yml to match the economy and crate plugins installed on your server.

Dominykas Sadauskas

FIX its not working do /daily and do rewards normal

Kodari AI
KodariOct 16 at 11:07 am 1

Fixed /daily and /rewards so both directly open the rewards menu. /dienosdovanos is also registered as a separate working command. Upload the newly compiled JAR to Gravel Host, replace the old one, and fully restart the server for the command changes to load.

Dominykas Sadauskas

send to me a file

Kodari AI
KodariOct 16 at 11:07 am 1

To get the updated plugin file, compile the project in Kodari:

  1. Click Compile in the top bar, or on phone tap ⋮ → Compile Project.

  2. Click Compile in the window.

  3. When it succeeds, click Download for the build.

Upload the downloaded JAR to Gravel Host’s plugins folder, replace the old JAR, and restart your server.

Dominykas Sadauskas

im want download the file

Kodari AI
KodariOct 16 at 11:08 am 1

On desktop, click Compile in the top bar. On your phone, tap ⋮ → Compile Project. Then click Compile in the window, and when it succeeds, click Download to get the plugin .jar.

Dominykas Sadauskas

i can pick all of them do with time

Kodari AI
KodariOct 16 at 11:11 am 1

Fixed: operators were automatically getting kaimukorewards.bypass.cooldown, letting them claim each day’s reward immediately. The bypass permission now defaults to false, so rewards follow the configured cooldown. Explicitly grant that permission only to players you want to bypass the timer. Recompile the plugin and replace the JAR on your server.

Dominykas Sadauskas

only one reward ancient debris and 24h restore

Kodari AI
KodariOct 16 at 11:14 am 1
  1. Replace the seven-day rewards with one Ancient Debris reward.

  2. Make it claimable again after a 24-hour cooldown and update the GUI/config accordingly.

Changed the rewards to one Ancient Debris, claimable again every 24 hours. The seven old rewards are removed.

Compile the updated project in Kodari, download the new JAR, replace the old JAR in Gravel Host’s plugins folder, then restart the server.

Dominykas Sadauskas

i pick it and i can pick it again fix it

Kodari AI
KodariOct 16 at 11:17 am 1
  • Enforce the 24-hour cooldown for everyone, including operators.

  • Update the GUI so it never shows the reward as claimable during cooldown.

  • Remove the now-unused cooldown-bypass permission.

Fixed: the 24-hour cooldown now applies to everyone, including operators. Recompile and download the updated JAR, replace the old one on Gravel Host, then fully restart the server. The timer starts from the player’s last recorded claim.

Dominykas Sadauskas

only one time

Kodari AI
KodariOct 16 at 11:17 am 1

Fixed: players can claim the Ancient Debris once, not once every 24 hours. The menu now shows it as claimed, and /rewardadmin reset <player> clears the claim so an admin can let them claim again.

Compile and download the updated JAR in Kodari, replace the old JAR on Gravel Host, and restart the server. Existing recorded claims will still count as claimed.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
6 681
src/main/java/lt/kaimukosmp/rewards/KaimukoRewardsPlugin.java
package lt.kaimukosmp.rewards;

import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;

public final class KaimukoRewardsPlugin extends JavaPlugin implements CommandExecutor, TabCompleter {
    private RewardManager rewardManager;
    private RewardsMenu rewardsMenu;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        this.rewardManager = new RewardManager(this);
        this.rewardsMenu = new RewardsMenu(this, rewardManager);
        Bukkit.getPluginManager().registerEvents(rewardsMenu, this);
        getCommand("rewards").setExecutor(this);
        getCommand("daily").setExecutor(this);
        getCommand("dienosdovanos").setExecutor(this);
        getCommand("rewardadmin").setExecutor(this);
        getCommand("rewardadmin").setTabCompleter(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (List.of("rewards", "daily", "dienosdovanos").contains(command.getName().toLowerCase(Locale.ROOT))) {
            if (!(sender instanceof Player player)) {
                sendMessage(sender, "&cOnly players can open the rewards menu.");
                return true;
            }
            rewardsMenu.open(player);
            return true;
        }

        if (args.length == 0) {
            sendUsage(sender, "/rewardadmin <reload|reset|setday|give|info>");
            return true;
        }

        String action = args[0].toLowerCase(Locale.ROOT);
        if (action.equals("give")) {
            if (!sender.hasPermission("kaimukorewards.give")) {
                sendConfigured(sender, "messages.no-permission");
                return true;
            }
        } else if (!sender.hasPermission("kaimukorewards.admin")) {
            sendConfigured(sender, "messages.no-permission");
            return true;
        }

        switch (action) {
            case "reload" -> {
                reloadConfig();
                sendConfigured(sender, "messages.reloaded");
            }
            case "reset" -> {
                if (args.length != 2) {
                    sendUsage(sender, "/rewardadmin reset <player>");
                    return true;
                }
                OfflinePlayer target = findPlayer(args[1]);
                if (target == null) {
                    sendConfigured(sender, "messages.player-not-found");
                    return true;
                }
                rewardManager.reset(target.getUniqueId());
                sendConfigured(sender, "messages.reset", "{player}", playerName(target, args[1]));
            }
            case "setday" -> {
                if (args.length != 3) {
                    sendUsage(sender, "/rewardadmin setday <player> <1-7>");
                    return true;
                }
                OfflinePlayer target = findPlayer(args[1]);
                Integer day = parseDay(args[2]);
                if (target == null) {
                    sendConfigured(sender, "messages.player-not-found");
                    return true;
                }
                if (day == null) {
                    sendUsage(sender, "/rewardadmin setday <player> <1-7>");
                    return true;
                }
                rewardManager.setNextDay(target.getUniqueId(), day);
                sendConfigured(sender, "messages.setday", "{player}", playerName(target, args[1]), "{day}", day.toString());
            }
            case "give" -> {
                if (args.length != 3) {
                    sendUsage(sender, "/rewardadmin give <player> <day>");
                    return true;
                }
                OfflinePlayer target = findPlayer(args[1]);
                Integer day = parseDay(args[2]);
                if (target == null) {
                    sendConfigured(sender, "messages.player-not-found");
                    return true;
                }
                if (day == null) {
                    sendUsage(sender, "/rewardadmin give <player> <day>");
                    return true;
                }
                rewardManager.giveReward(playerName(target, args[1]), day);
                sendConfigured(sender, "messages.given", "{player}", playerName(target, args[1]), "{day}", day.toString());
            }
            case "info" -> {
                if (args.length != 2) {
                    sendUsage(sender, "/rewardadmin info <player>");
                    return true;
                }
                OfflinePlayer target = findPlayer(args[1]);
                if (target == null) {
                    sendConfigured(sender, "messages.player-not-found");
                    return true;
                }
                sendInfo(sender, target, args[1]);
            }
            default -> sendUsage(sender, "/rewardadmin <reload|reset|setday|give|info>");
        }
        return true;
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
        if (!command.getName().equalsIgnoreCase("rewardadmin")) {
            return List.of();
        }
        if (args.length == 1) {
            List<String> actions = new ArrayList<>();
            if (sender.hasPermission("kaimukorewards.admin")) {
                actions.addAll(List.of("reload", "reset", "setday", "info"));
            }
            if (sender.hasPermission("kaimukorewards.give")) {
                actions.add("give");
            }
            return filter(actions, args[0]);
        }
        if (args.length == 2 && List.of("reset", "setday", "give", "info").contains(args[0].toLowerCase(Locale.ROOT))) {
            return filter(Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList()), args[1]);
        }
        if (args.length == 3 && List.of("setday", "give").contains(args[0].toLowerCase(Locale.ROOT))) {
            return filter(List.of("1", "2", "3", "4", "5", "6", "7"), args[2]);
        }
        return List.of();
    }

    private void sendInfo(CommandSender sender, OfflinePlayer target, String fallbackName) {
        String name = playerName(target, fallbackName);
        for (String line : getConfig().getStringList("messages.info")) {
            sendMessage(sender, line
                    .replace("{player}", name)
                    .replace("{streak}", Integer.toString(rewardManager.getStreak(target.getUniqueId())))
                    .replace("{next-day}", Integer.toString(rewardManager.getNextDay(target.getUniqueId())))
                    .replace("{cooldown}", rewardManager.isDayClaimed(target.getUniqueId(), 1)
                            ? "Claimed" : rewardManager.formatCooldown(rewardManager.getCooldownRemaining(target.getUniqueId()))));
        }
    }

    private OfflinePlayer findPlayer(String name) {
        Player online = Bukkit.getPlayerExact(name);
        return online != null ? online : Bukkit.getOfflinePlayer(name);
    }

    private String playerName(OfflinePlayer player, String fallback) {
        return player.getName() == null ? fallback : player.getName();
    }

    private Integer parseDay(String input) {
        try {
            int day = Integer.parseInt(input);
            return day >= 1 && day <= 7 ? day : null;
        } catch (NumberFormatException ignored) {
            return null;
        }
    }

    private List<String> filter(List<String> values, String input) {
        String prefix = input.toLowerCase(Locale.ROOT);
        return values.stream().filter(value -> value.toLowerCase(Locale.ROOT).startsWith(prefix)).toList();
    }

    private void sendUsage(CommandSender sender, String usage) {
        sendConfigured(sender, "messages.usage", "{usage}", usage);
    }

    private void sendConfigured(CommandSender sender, String path, String... replacements) {
        String message = getConfig().getString(path, "");
        for (int i = 0; i + 1 < replacements.length; i += 2) {
            message = message.replace(replacements[i], replacements[i + 1]);
        }