killer_.95

Create a plugin for a Minecraft server where players receive rewards for being afk or playing for 8 hours on the server; they will receive specific rewards. only 1 time in a day

Kodari AI
KodariApr 12 at 3:07 pm 9,729 (v2)

I’ll create a plugin that rewards players for reaching 8 hours of playtime each day.

DailyPlaytimeRewards
A playtime tracking plugin that rewards players once daily for accumulating 8 hours of activity on the server. Features configurable item and command rewards, automatic daily resets, persistent time tracking with auto-save, and admin commands for management. Tracks all online time including AFK periods, ensuring fair daily rewards for dedicated players.

All files created successfully! The plugin tracks player playtime and rewards them once daily for reaching 8 hours. Features include configurable rewards (items, commands, sounds, titles), automatic data saving, admin commands for management, and daily reset system using date-based tracking.

killer_.95

how to use it

Kodari AI
KodariApr 12 at 3:08 pm 5,472 (v2)

I’ll read the project files to understand the plugin’s functionality and then provide usage instructions.

Daily Playtime Rewards - Usage Guide

📦 What This Plugin Does

Tracks player playtime and automatically gives rewards when they reach the required daily playtime (default: 8 hours). Rewards reset daily so players can earn them again the next day.


🚀 Installation

  1. Drop the compiled .jar file into your server’s plugins/ folder

  2. Restart or reload your server

  3. Configure plugins/DailyPlaytimeRewards/config.yml


⚙️ Configuration (config.yml)

YAML
prefix: "&7[&aPlaytime&7] "
required-seconds: 28800          # 28800 seconds = 8 hours
auto-save-interval: 5            # Auto-save every 5 minutes
debug: false                     # Enable debug logging

rewards:
  - "give {player} diamond 1"    # Give 1 diamond
  - "eco give {player} 100"      # Give $100 (requires Vault)
  - "lp user {player} permission set vip.rank true"  # Example permission

messages:
  time-remaining: "&aPlaytime: {hours}h {minutes}m. Time remaining: {remaining}"
  reward-claimed: "&aYou have received your daily reward!"
  already-claimed: "&cYou have already claimed your reward today."

Key Settings:

  • required-seconds: Playtime needed for rewards (in seconds)

    • 3600 = 1 hour

    • 7200 = 2 hours

    • 14400 = 4 hours

    • 28800 = 8 hours

  • rewards: Console commands executed when player earns reward

    • Use {player} placeholder for player name


🎮 Commands

Command
Permission
Description
/playtime
None
Check your daily playtime progress
/playtime check <player>
dailyplaytimerewards.admin
Check another player’s playtime
/playtime reset <player>
dailyplaytimerewards.admin
Reset a player’s playtime data
/playtime reload
dailyplaytimerewards.admin
Reload configuration

🔒 Permissions

YAML
dailyplaytimerewards.admin:
  description: Access to admin commands (check, reset, reload)
  default: op

💡 How It Works

  1. Player joins → Plugin starts tracking playtime

  2. Every minute → Plugin checks if player reached required time

  3. Reward earned → Automatically executes reward commands

  4. Next day → Player can earn rewards again (resets at midnight)

  5. Auto-save → Data saved every 5 minutes (configurable)


📌 Example Reward Setups

Starter Kit:

YAML
rewards:
  - "give {player} diamond 5"
  - "give {player} golden_apple 3"
  - "eco give {player} 500"

VIP Perks:

YAML
rewards:
  - "lp user {player} permission set vip.kit true"
  - "lp user {player} permission set vip.fly true"
  - "crates give physical daily 1 {player}"

Experience Boost:

YAML
rewards:
  - "xp add {player} 1000"
  - "give {player} experience_bottle 10"

🛠️ Troubleshooting

Rewards not working?

  • Check console for errors when reward triggers

  • Verify you have plugins installed for reward commands (Vault for economy, etc.)

  • Test commands manually from console: /give PlayerName diamond 1

Playtime not tracking?

  • Enable debug mode: debug: true in config

  • Check console for “Auto-saved playtime data” messages

  • Verify players have online time

Rewards given multiple times?

  • Data is reset daily at midnight (server time)

  • This is intentional - players earn rewards fresh each day


🎯 Quick Start Example

  1. Set 2-hour requirement:

    YAML
    required-seconds: 7200
    
  2. Add simple rewards:

    YAML
    rewards:
      - "give {player} diamond 3"
      - "say &a{player} earned their daily reward!"
    
  3. Give admin permission:

    Plain Text
    /lp user YourName permission set dailyplaytimerewards.admin true
    
  4. Reload config:

    Plain Text
    /playtime reload
    
  5. Test it:

    • Play for 2 hours OR

    • Use /playtime check <player> to see progress


The plugin is now ready to use! Players will automatically receive rewards after reaching the daily playtime requirement.

killer_.95

i want to add custom item as a rewards

Kodari AI
KodariApr 12 at 3:29 pm 17,148 (v2)

I’ll read the existing files to understand the current reward system, then add support for custom item rewards.

I’ll add support for custom item rewards with full customization (display name, lore, enchantments, etc.) using XSeries for cross-version compatibility.

Custom item rewards added with full support for material, amount, name, lore, enchantments, flags, and unbreakable properties using XSeries for cross-version compatibility.

killer_.95

how to use it

Kodari AI
KodariApr 12 at 3:34 pm 4,928 (v2)

I’ll read the project files to understand how this plugin works and provide you with usage instructions.

DailyPlaytimeRewards - Usage Guide

🎮 Overview

This plugin rewards players for reaching a daily playtime goal. Players must play for a configured amount of time (default: 8 hours) to receive daily rewards.


📋 Commands

Command
Permission
Description
/playtime
playtime.checkown
Check your own playtime progress
/playtime reload
playtime.reload
Reload the config
/playtime check <player>
playtime.check
Check another player’s playtime
/playtime reset <player>
playtime.reset
Reset a player’s data
/playtime checkall
playtime.checkall
View all online players’ playtime

🔧 Configuration (config.yml)

Basic Settings

YAML
prefix: "&7[&aPlaytime&7] "           # Chat prefix
required-seconds: 28800                # Time needed for reward (8 hours)
auto-save-interval: 5                  # Auto-save interval (minutes)
debug: false                           # Debug mode

Messages

All messages support color codes (&a, &c, etc.) and placeholders:

  • {player} - Player name

  • {hours} - Hours played

  • {minutes} - Minutes played

  • {remaining} - Time remaining

  • {claimed} - Whether they claimed today

Rewards System

Two reward types are supported:

1. Command Rewards

Executes console commands when player earns reward:

YAML
rewards:
  economy_reward:
    type: command
    command: "eco give {player} 1000"  # Gives $1000
  
  rank_upgrade:
    type: command
    command: "lp user {player} parent add VIP"

2. Item Rewards

Gives custom items with enchantments, lore, etc:

YAML
rewards:
  legendary_sword:
    type: item
    material: DIAMOND_SWORD    # Item type (XSeries compatible)
    amount: 1                   # Stack size
    name: "&b&lLegendary Sword" # Display name
    lore:                       # Item description
      - "&7A powerful weapon"
      - "&eDaily Reward"
    enchantments:               # Enchantments
      SHARPNESS: 5
      UNBREAKING: 3
    flags:                      # Hide item attributes
      - HIDE_ATTRIBUTES
    unbreakable: true           # Make item unbreakable

🎁 How It Works

  1. Players join → Playtime tracking starts automatically

  2. Every second online → Playtime counter increases

  3. Daily goal reached → Rewards are automatically given

  4. Next day → Progress resets, can earn rewards again

Important Notes:

  • ✅ Rewards are once per day (resets at midnight)

  • ✅ Progress is tracked while online only

  • ✅ If inventory is full, items drop at player’s feet

  • ✅ Data auto-saves every 5 minutes (configurable)


💡 Example Configurations

Example 1: 4-Hour Requirement

YAML
required-seconds: 14400  # 4 hours
rewards:
  daily_cash:
    type: command
    command: "eco give {player} 500"
  daily_kit:
    type: command
    command: "give {player} diamond 3"

Example 2: VIP Reward Package

YAML
required-seconds: 21600  # 6 hours
rewards:
  vip_money:
    type: command
    command: "eco give {player} 2500"
  
  vip_sword:
    type: item
    material: NETHERITE_SWORD
    amount: 1
    name: "&d&lVIP Sword"
    enchantments:
      SHARPNESS: 7
      LOOTING: 3
    unbreakable: true
  
  golden_apples:
    type: item
    material: GOLDEN_APPLE
    amount: 32

🛠️ Admin Usage

Check Progress

Plain Text
/playtime check Steve
→ Shows Steve's total playtime and if they claimed today

Reset Player

Plain Text
/playtime reset Steve
→ Resets Steve's data (clears playtime & claim status)

View All Players

Plain Text
/playtime checkall
→ Lists all online players with their playtime

Reload Config

Plain Text
/playtime reload
→ Reloads config.yml without restarting

⚙️ Permissions

YAML
permissions:
  playtime.checkown: true      # Check own playtime (default: true)
  playtime.check: op           # Check others' playtime
  playtime.reset: op           # Reset player data
  playtime.reload: op          # Reload config
  playtime.checkall: op        # View all players
  dailyplaytimerewards.admin: op  # All admin permissions

📝 Tips

  1. Test rewards first - Use low required-seconds value to test (e.g., 60 seconds)

  2. Balance rewards - Don’t make them too OP or players won’t play after claiming

  3. Use Vault - For economy rewards, install Vault + economy plugin

  4. Item compatibility - Uses XSeries for cross-version support (1.8-1.21+)

  5. Monitor performance - Default 5-minute auto-save is balanced for most servers


🐛 Troubleshooting

Issue
Solution
Rewards not giving
Check console for errors, verify command syntax
Items not working
Ensure material name is valid (check
)
Economy not working
Install Vault + economy plugin (like EssentialsX)
Progress not saving
Check file permissions in
plugins/DailyPlaytimeRewards/playerdata/

Need more help? Enable debug mode (debug: true) and check console for detailed tracking info!

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
13 798
src/main/java/com/dailyplaytimerewards/DailyPlaytimeRewards.java
package com.dailyplaytimerewards;

import com.dailyplaytimerewards.commands.MainCommand;
import com.dailyplaytimerewards.rewards.RewardManager;
import com.dailyplaytimerewards.tasks.PlaytimeTask;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class DailyPlaytimeRewards extends JavaPlugin {

    private ConfigManager cfg;
    private PlaytimeManager playtimeManager;
    private PlaytimeTask playtimeTask;
    private RewardManager rewardManager;

    @Override
    public void onEnable() {
        cfg = new ConfigManager(this);
        playtimeManager = new PlaytimeManager(this);
        playtimeTask = new PlaytimeTask(this);
        rewardManager = new RewardManager(this);

        getCommand("playtime").setExecutor(new MainCommand(this));

        playtimeTask.start();
    }

    @Override
    public void onDisable() {
        if (playtimeTask != null) {
            playtimeTask.stop();
        }
        playtimeManager.saveData();
    }
}