# ============================================================
#                       PlayTime - config.yml
# ============================================================
# This file controls how playtime is formatted, how rewards work,
# MySQL syncing, update checks, and all the GUI layouts.
# ============================================================

settings:
  # ----------------------------------------------------------
  #                        PLAYTIME FORMAT
  # ----------------------------------------------------------
  # This controls how all playtime placeholders that use formatting
  # are displayed (ex: %playtime_playtime%, %playtime_session%, etc).
  #
  # ✅ Two popular styles:
  #
  #   (A) Compact:   "2d 8h 16m"
  #   (B) Long:      "2 days 8 hours 16 minutes"
  #
  # You can swap between them instantly using the presets below.
  # Just UNCOMMENT one preset block (remove the #) and restart/reload.
  #
  # Notes:
  # - Time-Format-Units controls which units are shown and in what order.
  # - Time-Format-Hide-Zeros hides units that are 0 (recommended).
  # - Time-Formats are the unit labels appended after the number.
  #   Example: Day: "d" -> "2d" | Day: " day" -> "2 day"
  # - Append-Formats-With-An-S controls plural "s" for long labels.
  # - Time-Format-Separator is the spacing BETWEEN units, NOT between the
  #   number and the label.
  #   Example: separator " " -> "2d 8h" | separator "" -> "2d8h"

  # ----------------------------------------------------------
  #                   QUICK PRESETS (pick ONE)
  # ----------------------------------------------------------

  # --- Preset A: Compact (recommended/default) -> "2d 8h 16m"
  #Time-Format-Units:
  #  - day
  #  - hour
  #  - minute
  #  # - second
  #Time-Formats:
  #  Day: "d"
  #  Hour: "h"
  #  Minute: "m"
  #  Second: "s"
  #Time-Format-Separator: " "     # space between units: "2d 8h 16m"
  #Time-Format-Hide-Zeros: true
  #Append-Formats-With-An-S: false # not needed for d/h/m/s

  # --- Preset B: Compact (no spaces) -> "2d8h16m"
  #Time-Format-Units:
  #  - day
  #  - hour
  #  - minute
  #Time-Formats:
  #  Day: "d"
  #  Hour: "h"
  #  Minute: "m"
  #  Second: "s"
  #Time-Format-Separator: ""      # no separator between units
  #Time-Format-Hide-Zeros: true
  #Append-Formats-With-An-S: false

  # --- Preset C: Long format -> "2 days 8 hours 16 minutes"
  #Time-Format-Units:
  #  - day
  #  - hour
  #  - minute
  #  # - second
  #Time-Formats:
  #  Day: " day"
  #  Hour: " hour"
  #  Minute: " minute"
  #  Second: " second"
  #Time-Format-Separator: " "     # space between units
  #Time-Format-Hide-Zeros: true
  #Append-Formats-With-An-S: true  # adds plural "s" automatically
  
  # Date format used for %date-joined%
  # Examples:
  #   "yyyy-MM-dd" -> 2025-12-18
  #   "dd-MM-yyyy" -> 18-12-2025
  Join-Date-Format: "dd-MM-yyyy"

  # ----------------------------------------------------------
  #               ACTIVE SETTINGS (default)
  # ----------------------------------------------------------
  # Choose your units + order here.
  Time-Format-Units:
    - day
    - hour
    - minute
    - second

  # Unit labels (what comes after the number).
  # Tip: Use "d/h/m/s" for compact, or " day/hour/minute/second" for long.
  Time-Formats:
    Day: "d"
    Hour: "h"
    Minute: "m"
    Second: "s"

  # Separator BETWEEN units (not between the number and the unit label).
  #
  # Examples:
  #   - Compact labels (d/h/m/s):
  #       Separator: " "  -> "2d 8h 16m"
  #       Separator: ""   -> "2d8h16m"
  #
  #   - Long labels (" day", " hour", ...):
  #       Separator: " "  -> "2 days 8 hours 16 minutes"
  #       Separator: ""   -> "2 days8 hours16 minutes"  (usually NOT desired)
  #
  # IMPORTANT:
  # - Spacing between the NUMBER and the LABEL comes from Time-Formats themselves.
  # - Spacing between EACH UNIT comes from Time-Format-Separator.
  Time-Format-Separator: " "

  # If enabled, hide units with value 0 (recommended).
  # Example: if seconds are enabled but 0, it won't show "0 seconds".
  Time-Format-Hide-Zeros: true

  # Whether to automatically add "s" for plurals (long labels only).
  # true  -> "2 days"
  # false -> "2 day"
  Append-Formats-With-An-S: false

  AFK:
    Enabled: true
    Threshold-Seconds: 300  # 5 minutes of inactivity before considered AFK

    # Worlds where ALL time counts as AFK time (even if players move/interact/chat/command)
    AFK-Worlds:
      - "spawn2"
      - "spawn"
      - "afk"
      - "afk_world"

  # ----------------------------------------------------------
  #                 REWARDS & CLEAR NOTIFICATIONS
  # ----------------------------------------------------------
  Rewards-Cleared:
    # When an admin clears a player’s rewards:
    # If true, the affected player will receive a chat message.
    # If false, only the admin sees the confirmation.
    Tell-Target-All-Their-PlayTime-Rewards-Were-Cleared: false

  Rewards:
    # Master toggle for all PlayTime rewards.
    # true  -> Rewards system enabled.
    # false -> No rewards are given or claimable.
    Enabled: false

    Auto-Claim:
      # If true, eligible rewards are automatically given.
      # If false, players must use the GUI to claim rewards manually.
      Enabled: false
    Types: # Enable or disable specific reward types.
      Constant: false
      Unique: false
      Daily: false
      Session: false
      Streaks: false

  # ----------------------------------------------------------
  # PLAYTIME SOURCE
  # ----------------------------------------------------------
  # If true:
  #   Use the existing playtime data from the world/playerdata
  #   where possible as the base.
  # If false:
  #   Use PlayTime's own tracking from the moment the plugin is installed.
  Use-existing-playtime: true

# ============================================================
#                      UPDATE CHECK SETTINGS
# ============================================================
update-check:
  # Enable or disable automatic update checks.
  enabled: true

  # Permission node required to see update notifications.
  permission: playtime.update

  # Message when a new version is available.
  # Placeholders:
  #   %latest%  - Latest available version
  #   %current% - Your current version
  message: "&6ᴘʟᴀʏᴛɪᴍᴇ &e♦ &fA new version, &6%latest%&f, is available. You're running &e%current%&f."

  # Text for the clickable button that opens the download link.
  button-text: "&7[&a&lClick to Download&7]"

# ============================================================
#                      PLACEHOLDER SETTINGS
# ============================================================
placeholders:
  # Fallback text when a "top position" placeholder or similar
  # has no data (e.g., top_10 on a server with only 3 players).
  no-data: '---'

# ============================================================
#                         data.yml FILE
# ============================================================
storage:
  local-file:
    enabled: true
    # When enabled the data.yml file is created and also used.
    # When disabled the data.yml file is completely ignored.

# ============================================================
#                          REDIS SETUP
# ============================================================
# Used for near real-time cross-server cache updates (Pub/Sub).
# This powers placeholders being accurate across the network
# without waiting for MySQL refresh cycles.
# ============================================================
redis:
  enabled: false

  host: "127.0.0.1"
  port: 6379
  password: ""        # leave empty if none
  use-ssl: false

  # Pub/Sub channel name (all servers must match)
  channel: "playtime:updates"

  # Prefix used to ignore our own messages when desired
  server-id: "default"

  # Cache behavior:
  publish-period-ticks: 40   # 40 = every 2 seconds (20 ticks = 1s)
  cache-ttl-seconds: 600     # expire unseen entries (optional)

# ============================================================
#                          MySQL SETUP
# ============================================================
# Used for storing and syncing playtime data across servers.
# If you're running a single server and don't need external
# storage or cross-syncing, keep this disabled.
# ============================================================
mysql:
  # Master toggle for MySQL.
  enabled: false
  
  # Data sync between multiple servers:
  # If true:
  #   All connected servers using this database share one unified
  #   up-to-date playtime value per player.
  sync-between-servers: true

  # Basic connection credentials.
  host: localhost
  port: 3306
  database: playtime
  username: root
  password: password
  table: playtime_data
  
  # Startup / Shutdown behavior
  startup:
    max-wait-ms: 0           # only used if you choose to wait a little for readiness
  shutdown:
    flush-enabled: true
    max-wait-ms: 500         # hard cap; never block shutdown longer than this

  # Schema management (tables/indexes)
  schema:
    auto-migrate: true       # true for most servers; false for huge fleets (pre-create schema)
    ensure-indexes: true     # if false, skips DatabaseMetaData index scans (big speed win)
    run-on-startup: true     # if false, schema is not touched at startup

  # Writer tuning
  writer:
    period-seconds: 2
    batch-max: 2000

  # SSL & security.
  use-ssl: false                   # Enable only if your MySQL server requires SSL.
  allow-public-key-retrieval: true # Some hosts require this for authentication.

  # Connection behavior / reliability.
  auto-reconnect: true             # Reconnect automatically on connection loss.
  connect-timeout-ms: 2000         # How long to wait when opening a new connection.
  socket-timeout-ms: 0             # 0 = no limit (be careful with this on unstable networks).

  # Keepalive / dead-connection detection.
  tcp-keepalive: true
  keepalive-minutes: 5

  # Reconnect strategy.
  reconnect-attempts: 3
  reconnect-interval-ms: 2000
  
  # For PlayTimes to accurately be updated across your entire
  # Network, a task has be ran in the background that every so
  # often pings the MySQL table to update all of the playtimes.
  network-refresh-seconds: 60
  
  # How often each server flushes its "delta seconds"
  # to MySQL for network daily/session.
  network-flush-seconds: 15
  
  # -----------------------------------------------------------------
  # MULTI-SERVER / BACKEND SETTINGS
  # -----------------------------------------------------------------

  # Unique identifier for THIS backend server in your network.
  # Example values:
  #   "survival", "prison", "skyblock", "hub"
  #
  # This is used for per-server playtime tracking.
  server-id: "default"

  # If true:
  #   - This backend will NOT read/write the global MySQL playtime table.
  #   - Global network playtime will ignore this server completely.
  #   - This server will still track playtime locally in data.yml
  #     (and can still use per-server tracking if enabled below).
  blacklist-this-server-from-global: false

  # Per-server playtime tracking:
  # If enabled:
  #   - Playtime for this backend (identified by server-id)
  #     is stored in a separate MySQL table.
  #   - Does NOT affect rewards/top logic by default; it's extra data
  #     you can expose via placeholders, commands, etc.
  per-server:
    enabled: false
    table: playtime_per_server

# ============================================================
#                           GUI SETTINGS
# ============================================================
# Customize the appearance and behavior of PlayTime GUIs:
# - Top playtimes leaderboard
# - Rewards menu & type menus
# ============================================================
guis:

  # ----------------------------------------------------------
  # TOP PLAYTIMES GUI
  # ----------------------------------------------------------
  Top:
    
    # Title of the Top Playtimes GUI.
    Title: '&fᴛᴏᴘ &6ᴘʟᴀʏᴛɪᴍᴇꜱ'

    # Title of the Top PlayTimes GUI with a specific time frame range.
    Title-Range: '&fᴛᴏᴘ &6ᴘʟᴀʏᴛɪᴍᴇꜱ &7(%from% - %to%)'

    # How many players to show.
    How-Many-Players-To-Display-In-The-GUI: 10

    # Format of the player's line (left-display) in the GUI.
    # Placeholders:
    #   %position% - Rank position (1, 2, 3, ...)
    #   %player%   - Player name
    Players-Name: '&6#%position% &7» &6%player%'

    # Format of the playtime under/alongside the player's entry.
    # Placeholder:
    #   %playtime% - Formatted playtime string
    Players-Playtime: '&7%playtime%'
    
    # Optional decorative border around the GUI.
    Border:
    # IMPORTANT: If Border.Enabled is true, do NOT set Size below 27 or the leaderboard heads don't have space in the GUI.
      Enabled: true
      Item:
        material: BLACK_STAINED_GLASS_PANE
        name: '&r'
        lore: []

    # Each entry:
    #   slot: inventory slot (0-26 for size 27)
    #   action: open-type | run-command | open-url | none
    #   type: constant | unique | session | daily | streaks (for open-type)
    #   material / itemsadder-id / texturepackmanager-id / skull / etc.
    #   name: display name
    #   lore: list of lore lines
    Items:
      close:
        slot: 26
        action: close
        material: BARRIER
        name: '&cClose'
        lore:
          - '&7Click to close this menu'

    # ------------------------------------------------------
    # EXTRA / CUSTOM BUTTONS & DECORATION
    # ------------------------------------------------------
    # Use this to add:
    # - Links (Discord, Store, Website)
    # - Decorative items
    # - Command buttons, etc.
    #
    # Each entry supports:
    #   slot: inventory slot
    #   action:
    #     - open-type      → open a reward category (constant/unique/session/daily/streaks)
    #     - run-command    → run a command AS CONSOLE
    #     - player-command → run a command AS THE PLAYER
    #     - open-url       → send a clickable chat link
    #     - none           → purely decorative
    #
    #   command/url: the command or URL to use
    #   material: Bukkit material name (or use itemsadder-id / texturepackmanager-id / skull)
    #   name: display name
    #   lore: list of lore lines
    #   optional:
    #     custom-model-data: integer
    #     glow: true/false
    #     flags: [HIDE_ENCHANTS, HIDE_ATTRIBUTES, ...]
    #     skull.owner: player name or UUID
    #     skull.texture-base64: custom head texture
    #     itemsadder-id: "packname:item_id"
    #     texturepackmanager-id: "your_item_id"
    #
    # IMPORTANT (commands):
    #   - For run-command (console):
    #       The command is run by CONSOLE.
    #       Example: "say %player% clicked the head!"
    #       (Don't use "/")
    #
    #   - For player-command (player):
    #       The command is run by the PLAYER who clicked.
    #       You SHOULD use the leading "/" like a normal chat command.
    #       Example:
    #         action: player-command
    #         command: "/spawn"
    #
    Extras:
      - slot: 0
        action: open-url
        url: "https://yourstore.example"
        url-label: "&6Store"
        material: EMERALD
        name: "&6Store"
        lore:
          - "&7Click to open the store"

  # ----------------------------------------------------------
  # REWARDS MAIN MENU GUI
  # ----------------------------------------------------------
  Rewards:
    Main:
      # Title and size of the main rewards GUI.
      Title: '&6ᴘʟᴀʏᴛɪᴍᴇ &fʀᴇᴡᴀʀᴅꜱ'
      Size: 27  # Must be a valid inventory size (multiple of 9)

      # Optional decorative border around the GUI.
      Border:
        Enabled: true
        Item:
          material: BLACK_STAINED_GLASS_PANE
          name: '&r'
          lore: []

      # ------------------------------------------------------
      # CORE REWARD CATEGORY BUTTONS
      # ------------------------------------------------------
      # Each entry:
      #   slot: inventory slot (0-26 for size 27)
      #   action: open-type | run-command | open-url | none
      #   type: constant | unique | session | daily | streaks (for open-type)
      #   material / itemsadder-id / texturepackmanager-id / skull / etc.
      #   name: display name
      #   lore: list of lore lines
      Items:
        constant:
          slot: 10
          action: open-type
          type: constant
          material: DIAMOND
          name: '&6Constant'
          lore:
            - '&7Repeatable rewards'
            - '&7based on total playtime'

        unique:
          slot: 12
          action: open-type
          type: unique
          material: EMERALD
          name: '&aUnique'
          lore:
            - '&7One-time milestones'

        session:
          slot: 14
          action: open-type
          type: session
          material: IRON_INGOT
          name: '&6Session'
          lore:
            - '&7Stay online for a duration'

        daily:
          slot: 16
          action: open-type
          type: daily
          material: GOLD_INGOT
          name: '&eDaily'
          lore:
            - '&7Once per day'

        streaks:
          slot: 22
          action: open-type
          type: streaks
          material: TRIPWIRE_HOOK
          name: '&cStreaks'
          lore:
            - '&7Play X minutes per day'
            - '&7for Y days'

      # ------------------------------------------------------
      # EXTRA / CUSTOM BUTTONS & DECORATION
      # ------------------------------------------------------
      # Use this to add:
      # - Links (Discord, Store, Website)
      # - Decorative items
      # - Command buttons, etc.
      #
      # Each entry supports:
      #   slot: inventory slot
      #   action:
      #     - open-type      → open a reward category (constant/unique/session/daily/streaks)
      #     - run-command    → run a command AS CONSOLE
      #     - player-command → run a command AS THE PLAYER
      #     - open-url       → send a clickable chat link
      #     - none           → purely decorative
      #
      #   command/url: the command or URL to use
      #   material: Bukkit material name (or use itemsadder-id / texturepackmanager-id / skull)
      #   name: display name
      #   lore: list of lore lines
      #   optional:
      #     custom-model-data: integer
      #     glow: true/false
      #     flags: [HIDE_ENCHANTS, HIDE_ATTRIBUTES, ...]
      #     skull.owner: player name or UUID
      #     skull.texture-base64: custom head texture
      #     itemsadder-id: "packname:item_id"
      #     texturepackmanager-id: "your_item_id"
      #
      # IMPORTANT (commands):
      #   - For run-command (console):
      #       The command is run by CONSOLE.
      #       Example: "say %player% clicked the head!"
      #       (Don't use "/")
      #
      #   - For player-command (player):
      #       The command is run by the PLAYER who clicked.
      #       You SHOULD use the leading "/" like a normal chat command.
      #       Example:
      #         action: player-command
      #         command: "/spawn"
      #
      Extras:
        # Example: Discord button
        - slot: 4
          action: open-url
          url: "https://discord.gg/yourserver"
          url-label: "&6Join our Discord"
          material: BOOK
          name: "&6Discord"
          lore:
            - "&7Click to open a link"

        # Example: clickable player head (runs a CONSOLE command)
        - slot: 0
          action: run-command
          command: "say %player% clicked the head!"
          material: PLAYER_HEAD
          skull:
            owner: "Notch"          # Or a UUID
            # texture-base64: ""    # Or use a custom base64 texture
          name: "&aFamous Head"
          lore:
            - "&7Runs a console command"
          glow: true

        # Example (commented) of a PLAYER command button:
        # - slot: 8
        #   action: player-command
        #   command: "/spawn"       # NOTE: leading "/" so it runs exactly as the player types it
        #   material: ENDER_PEARL
        #   name: "&aGo to Spawn"
        #   lore:
        #     - "&7Click to run &f/spawn &7as the player"

        # Examples for ItemsAdder / TexturepackManager are left commented out:
        # - slot: 8
        #   action: none
        #   itemsadder-id: "packname:cool_button"
        #   name: "&dA cool button from ItemsAdder"
        #   lore: ["&7Button go click"]
        #
        # - slot: 18
        #   action: none
        #   texturepackmanager-id: "sky_pick"
        #   name: "&dTPM default sky_pick item"

    # --------------------------------------------------------
    # REWARD TYPE BROWSING MENU (PER CATEGORY)
    # --------------------------------------------------------
    TypeMenu:
      Size: 54
      # Title format when viewing a specific reward type.
      # Placeholder:
      #   %type% - The current type (Constant, Unique, etc.)
      Title-Format: '&6%type% &fʀᴇᴡᴀʀᴅꜱ'
      
      Auto-Refresh: 
        Enabled: true
        # With this disabled it will require the players to click the "Refresh" item for these timers to update.
        # With this enabled the timers will visually automatically update in lores.
        Interval-Ticks: 20 # 20 = 1 second
      
      Type-Names:
        constant: 'Constant'
        unique: 'Unique'
        session: 'Session'
        daily: 'Daily'
        streaks: 'Streaks'

      # Navigation / control buttons within the type menu.
      Controls:
        Prev:
          slot: 45
          material: ARROW
          name: '&c« &fPrevious'

        Next:
          slot: 53
          material: ARROW
          name: '&fNext &a»'

        Back:
          slot: 49
          material: BARRIER
          name: '&cBack'

        # Optional: refresh button to re-open or reload the page.
        Refresh:
          slot: 46
          material: SUNFLOWER
          name: '&6Refresh'
          lore:
            - '&7Click to refresh this page'

      # Status labels for rewards shown in the GUI.
      Status:
        # Players already claimed this reward.
        Claimed: '&a✔ &7Claimed'

        # Eligible and auto-claim is active.
        Eligible-Auto: '&6⏵ &7Auto-claim enabled'

        # Eligible but requires manual click.
        Eligible-Click: '&e⏵ Click to claim'

        # Not enough playtime yet.
        Not-Eligible: '&7Not yet eligible'