star_og56

Create a premium, production-ready Maven-based Minecraft plugin named StarPlaytime, authored by StarOG__, with the main package me.starog.starstudio.playtime and clean modular subpackages such as commands, INVENTORY GUI, rewards, storage, listeners, placeholders, utils, and config. The plugin must support PaperMC, Folia, and Purpur for Minecraft 1.21 through 1.21.9, 1.21.10, and 1.21.11, with proper Folia-compatible scheduling and no unsafe Bukkit scheduler assumptions. StarPlaytime is a premium INVENTORY GUI-based playtime reward system where players earn configurable rewards by reaching specific playtime milestones. Players can open the INVENTORY GUI using /levels or /playtime. The INVENTORY GUI must support multiple pages and dynamically display all configured rewards. By default, use a 6-row INVENTORY GUI with the title &8ᴘʟᴀʏᴛɪᴍᴇ ʀᴇᴡᴀʀᴅs, and when fill-background is enabled, fill unused slots with DARK_GRAY_STAINED_GLASS_PANE. Slot 49 must contain a configurable PLAYER_HEAD with the default name &#1caff8%player_name%'s Stats and configurable lore including &#54fcfcInformation:, &7Playtime: &#1caff8%playtime%, &fNext Reward: &#54fcfc%next_reward%, and additional configurable statistics. Preserve the configuration options use-real-playtime: false and count-old-playtime: true exactly, allowing administrators to control how playtime is calculated and whether previous playtime is counted. All rewards must be loaded from Rewards.yml, with every reward supporting an ID, playtime requirement, money reward, commands, item reward, item amount, item display name, lore, and INVENTORY GUI slot. The default reward progression must be balanced so that a player can earn approximately $1 billion total across all rewards from 1 hour through 60 days, rather than flooding the server economy. Use this default progression: 1h = $15,000; 3h = $25,000; 6h = $40,000; 12h = $75,000; 1d = $4,000,000; 2d = $8,000,000; 3d = $12,000,000; 4d = $16,000,000; 5d = $20,000,000; 6d = $25,000,000; 7d = $30,000,000; 8d = $35,000,000; 9d = $40,000,000; 10d = $45,000,000; 11d = $50,000,000; 12d = $55,000,000; 13d = $60,000,000; 14d = $65,000,000; 15d = $70,000,000; 16d = $75,000,000; 17d = $80,000,000; 18d = $85,000,000; 19d = $90,000,000; 20d = $95,000,000; 21d = $100,000,000; 22d = $105,000,000; 30d = $120,000,000; 60d = $130,000,000. Treat these as defaults only, with every value fully editable in Rewards.yml. At selected higher milestones, optionally include valuable item rewards such as diamonds, emeralds, netherite ingots, nether stars, golden apples, enchanted golden apples, dragon eggs, or elytras, with item types and amounts fully configurable. Implement three configurable reward states: reward-lore-cant-claim, reward-lore-can-claim, and reward-lore-already-claimed, preserving these exact configuration keys and allowing separate materials, names, and lore. The default unavailable state should use MINECART_WITH_HOPPER, the available state DIAMOND, and the claimed state MINECART. Support dynamic placeholders including %reward_time_total_time%, %time_left%, %money_reward%, %item_amount%, %item_reward_name%, %player_name%, %playtime%, and %next_reward%. Every reward can only be claimed once per player. When a player clicks an available reward, perform a fresh server-side eligibility and claim-state verification before granting anything, then safely execute all configured commands, grant configured items/money, mark the reward as claimed, and persist the state. Protect against double-clicking, rapid INVENTORY GUI clicks, reconnect exploits, concurrent claims, duplicate command execution, inventory manipulation, and race conditions. If the player's inventory is full, follow a configurable inventory-full policy and never lose or duplicate rewards. Block shift-clicking, dragging, hotbar swapping, double-click item collection, and other unintended INVENTORY GUI item movement unless explicitly enabled. Add configurable admin utilities for reload and reward reset, with permission checks and messages such as messages.reloaded-config, messages.reset-success, and messages.no-permission. All messages, INVENTORY GUI titles, item names, lore, titles, subtitles, actionbars, sounds, permissions, formatting, and behavior must be configurable. The plugin must support legacy colors, hex colors, gradients, MiniMessage formatting, and mixed color formats throughout the entire system. Add PlaceholderAPI support with placeholders such as %starplaytime_playtime%, %starplaytime_playtime_formatted%, %starplaytime_next_reward%, %starplaytime_rewards_claimed%, %starplaytime_rewards_available%, and %starplaytime_reward_<id>_claimed%. Use UUID-based persistent player data so playtime and claimed rewards survive restarts, crashes, reconnects, and server updates. Perform heavy bookkeeping and persistence asynchronously where safe, while all Minecraft API operations are executed through the correct PaperMC/Folia/Purpur-compatible scheduler. Validate Config.yml and Rewards.yml during startup and reload, detecting duplicate IDs, invalid materials, invalid time formats, invalid commands, duplicate/conflicting slots, missing values, and malformed reward entries, with clear console logging instead of server crashes. Provide detailed audit logging for reward claims, successful grants, failed claims, resets, configuration errors, and suspicious duplicate attempts. The architecture must be modular and maintainable with me.starog.starstudio.playtime as the root package. The final StarPlaytime plugin must be highly optimized for large servers, secure against reward exploits, fully configurable without source-code modification, compatible with PaperMC/Folia/Purpur 1.21–1.21.11, and provide a polished premium playtime progression system where the complete 1-hour-to-60-day reward journey provides approximately $1 billion total economy value while remaining balanced for a server economy.

Kodari AI
KodariAug 16 at 1:33 am 4
StarPlaytime
A premium Folia-compatible playtime reward system with a multi-page inventory GUI. Players earn configurable rewards at playtime milestones from 1 hour to 60 days, with a balanced $1 billion total economy value. Features UUID-based persistent data, async storage, three reward states (unavailable, available, claimed), dynamic placeholders, hex/gradient/MiniMessage color support, PlaceholderAPI integration, config validation, audit logging, and exploit protection against double-claims and race conditions. Includes admin reload/reset commands, configurable player stats head, fill-background option, and full customization of rewards, messages, sounds, and GUI layout.
  1. Create the Maven/Paper project foundation and production configuration files.

  2. Add modular configuration, reward, storage, scheduling, GUI, command, listener, and PlaceholderAPI components.

  3. Wire secure one-time claims, Folia-safe execution, validation, persistence, audit logging, and the default reward progression.

Created StarPlaytime as a modular Maven plugin with:

  • Paper/Folia/Purpur 1.21-compatible setup and Folia-safe player, global, and async scheduling.

  • /levels, /playtime, and administrative /starplaytime reload|reset commands.

  • Configurable multi-page playtime reward GUI with stats slot 49, background filling, navigation, reward states, colors, MiniMessage, and PlaceholderAPI support.

  • UUID-based persistent player data with claimed/pending reward protection, autosaving, versioned async persistence, and crash-safe pending claims.

  • Reward validation for IDs, slots, materials, durations, commands, amounts, and malformed entries.

  • Secure claim flow with inventory-full handling, duplicate-click protection, audit logging, Vault economy integration, commands, item rewards, and configurable messages/sounds.

  • Default Rewards.yml progression from 1 hour through 60 days with configurable money and milestone item rewards.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
26 1,493
src/main/java/me/starog/starstudio/playtime/StarPlaytimePlugin.java
package me.starog.starstudio.playtime;

import me.starog.starstudio.playtime.commands.PlaytimeCommand;
import me.starog.starstudio.playtime.config.ConfigManager;
import me.starog.starstudio.playtime.inventory.GUIManager;
import me.starog.starstudio.playtime.inventory.InventoryListener;
import me.starog.starstudio.playtime.listeners.PlayerListener;
import me.starog.starstudio.playtime.placeholders.StarPlaytimeExpansion;
import me.starog.starstudio.playtime.rewards.RewardLoader;
import me.starog.starstudio.playtime.rewards.RewardService;
import me.starog.starstudio.playtime.storage.PlayerDataStorage;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class StarPlaytimePlugin extends JavaPlugin {
    private ConfigManager configManager;
    private PlayerDataStorage storage;
    private RewardLoader rewardLoader;
    private RewardService rewardService;
    private GUIManager guiManager;
    private me.starog.starstudio.playtime.utils.PlaytimeService playtimeService;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResource("Rewards.yml", false);
        configManager = new ConfigManager(this);
        configManager.reload();
        storage = new PlayerDataStorage(this);
        rewardLoader = new RewardLoader(this);
        rewardService = new RewardService(this, configManager, storage, rewardLoader);
        rewardService.reload();
        guiManager = new GUIManager(this, configManager, rewardService);
        playtimeService = new me.starog.starstudio.playtime.utils.PlaytimeService(this, configManager, storage, rewardService);

        Bukkit.getPluginManager().registerEvents(new InventoryListener(guiManager), this);
        Bukkit.getPluginManager().registerEvents(new PlayerListener(this, storage, playtimeService), this);
        PlaytimeCommand command = new PlaytimeCommand(this, configManager, storage, rewardService, guiManager);
        getCommand("levels").setExecutor(command);
        getCommand("playtime").setExecutor(command);
        getCommand("starplaytime").setExecutor(command);

        if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
            new StarPlaytimeExpansion(this).register();
            getLogger().info("PlaceholderAPI expansion registered.");
        }
        getLogger().info("StarPlaytime enabled with " + rewardService.getRewards().size() + " valid rewards.");
    }

    @Override
    public void onDisable() {
        if (playtimeService != null) {
            playtimeService.stopAll();
        }
        if (storage != null) {
            storage.saveAllAsync();
        }
    }

    public void reloadPlugin() {
        configManager.reload();
        rewardService.reload();
        getLogger().info("Configuration reload completed with " + rewardService.getRewards().size() + " valid rewards.");
    }

    public ConfigManager getConfigManager() { return configManager; }
    public PlayerDataStorage getStorage() { return storage; }
    public RewardService getRewardService() { return rewardService; }
    public GUIManager getGuiManager() { return guiManager; }
}