.itsmespark
๐Ÿ“Ž 1 file 41,292 chars
๐Ÿ“„
pasted-code-1791099379521.txt
txt 2306 lines
โ–ถ
You are an expert Minecraft Paper plugin developer.

Build a production-ready, polished, highly configurable Minecraft giveaway plugin named:

LxGiveaways

Author:
Spark OP

The plugin must be designed as a professional player-hosted giveaway system with modern GUI menus, persistent storage, safe item handling, configurable broadcasts, sounds, HEX colors, placeholders, permissions, and complete restart/crash recovery.

IMPORTANT:
This is an ORIGINAL implementation.

You may use the provided screenshots and configuration examples as UI/configuration references and recreate their functionality and design philosophy, but DO NOT copy, decompile, extract, reproduce, or reuse proprietary source code, assets, or implementation from another plugin.

==================================================
1. PLATFORM / COMPATIBILITY
==================================================

Plugin:
LxGiveaways

Target:
Paper

Minecraft compatibility:
1.21.11 through 1.26.2

Java:
Java 25+

The plugin must run correctly on every supported server version within the specified range.

Compatibility requirements:

- Compile against the lowest supported compatible Paper API where practical.
- Use stable Bukkit/Paper APIs.
- Avoid unnecessary NMS.
- Avoid version-specific internal server classes.
- Do not hardcode Minecraft version parsing such as assuming versions always start with "1.".
- Support modern Paper versioning where Minecraft versions may use formats such as 26.x.
- Java 25 is the minimum runtime.
- Do not use APIs unavailable on the supported minimum version.
- Use graceful compatibility abstractions if a feature differs between supported versions.
- Plugin startup must fail gracefully with a clear message if the Java runtime is below Java 25.

==================================================
2. PLUGIN IDENTITY
==================================================

plugin name:
LxGiveaways

author:
Spark OP

Main command aliases:

/gwy
/giveaway
/giveaways
/lxgiveaways

The commands and aliases must be configurable where practical.

==================================================
3. CORE PURPOSE
==================================================

LxGiveaways is a player-hosted giveaway plugin.

Players with permission can:

- Create giveaways.
- Add item prizes.
- Configure duration.
- Configure number of winners.
- Configure entry requirements.
- Preview giveaways.
- Start giveaways.
- View public giveaways.
- Enter giveaways.
- View their pending rewards.
- Claim individual rewards.
- Collect all available rewards.
- View giveaway status.
- View giveaway winners.

Administrators can:

- Manage active giveaways.
- End giveaways.
- Cancel giveaways.
- Reroll winners.
- Inspect giveaway information.
- Manage giveaway limits.
- Manage storage.
- Reload configuration.
- Debug GUI/configuration problems.

==================================================
4. COMMANDS
==================================================

Implement:

/gwy
/gwy help
/gwy list
/gwy create
/gwy reload
/gwy admin

Aliases:

/giveaway
/giveaways
/lxgiveaways

Permissions:

lxgiveaways.use
lxgiveaways.create
lxgiveaways.enter
lxgiveaways.admin
lxgiveaways.reload
lxgiveaways.reroll
lxgiveaways.cancel
lxgiveaways.end
lxgiveaways.bypass

All permissions must be configurable.

Do not hardcode permission messages.

==================================================
5. GUI ARCHITECTURE
==================================================

IMPORTANT:

Do NOT use one combined gui.yml.

Use separate GUI files:

gui/
โ”œโ”€โ”€ main-menu.yml
โ”œโ”€โ”€ giveaway-items.yml
โ””โ”€โ”€ giveaway-create.yml

Future GUI files may be added without rewriting the GUI engine.

Each GUI file is independently configurable.

The GUI architecture must follow this general philosophy:

menu:
  ...
filler:
  ...
items:
  ...

This follows the configuration organization demonstrated in the provided reference configuration, while the implementation itself must be original.

==================================================
6. GUI DESIGN PHILOSOPHY
==================================================

The GUI should visually follow the uploaded screenshot:

- 54-slot chest GUI.
- Clean centered layout.
- Border-style glass.
- Empty interior.
- Functional buttons placed around the bottom area.
- Giveaway entries displayed in the central area.
- No glass filling every empty slot.
- No unnecessary decorative clutter.
- No automatic full-inventory filler.

The default GUI must resemble the screenshot's layout.

IMPORTANT:

Glass filler must only occupy the configured border/decorative slots.

Empty slots must remain genuinely empty.

The server owner must be able to completely customize the filler slots.

==================================================
7. DEFAULT MAIN MENU LAYOUT
==================================================

main-menu.yml

Default size:

54

Default conceptual layout:

ROW 1:
glass border

ROW 2:
glass border + giveaway content

ROW 3:
glass border + giveaway content

ROW 4:
glass border + giveaway content

ROW 5:
glass border + giveaway content

ROW 6:
navigation/action buttons

Default filler slots:

0,1,2,3,4,5,6,7,8
9,17
18,26
27,35
36,44

Bottom decorative/filler slots may be configured individually.

Example:

filler:
  enabled: true
  material: GRAY_STAINED_GLASS_PANE
  name: ' '
  lore: []
  slots:
    - 0
    - 1
    - 2
    - 3
    - 4
    - 5
    - 6
    - 7
    - 8
    - 9
    - 17
    - 18
    - 26
    - 27
    - 35
    - 36
    - 44

IMPORTANT:

Do NOT fill the entire inventory with glass.

==================================================
8. MAIN MENU
==================================================

File:

gui/main-menu.yml

Purpose:

Public giveaway browser.

Default functional items:

- Help/info
- Your Items
- Previous Page
- Refresh
- Next Page
- Create Giveaway

There MUST NOT be a Collect All button in this menu.

Collect All belongs ONLY in:

gui/giveaway-items.yml

Main menu example:

menu:
  title: 'PFF00&lPublic Giveaways'
  size: 54

items:

  help:
    slot: 10
    material: BOOK
    amount: 1
    name: 'PFF00&lGIVEAWAYS'
    lore:
      - '&8Information'
      - ''
      - '&7Browse all active giveaways.'
      - '&7Click a giveaway to view'
      - '&7its details.'
      - ''
      - '&eClick to view.'
    action:
      type: none

  your_items:
    slot: 46
    material: CHEST
    name: '&#FFD75A&lYOUR ITEMS'
    lore:
      - '&7Pending rewards: &f%pending_rewards%'
      - ''
      - '&eClick to open.'
    action:
      type: open_menu
      menu: giveaway-items

  previous_page:
    slot: 49
    material: ARROW
    name: '&f&lPREVIOUS PAGE'
    action:
      type: previous_page

  refresh:
    slot: 50
    material: CLOCK
    name: '7FFFF&lREFRESH'
    action:
      type: refresh

  next_page:
    slot: 51
    material: ARROW
    name: '&f&lNEXT PAGE'
    action:
      type: next_page

  create_giveaway:
    slot: 53
    material: BELL
    name: '7FF55&lCREATE GIVEAWAY'
    permission: 'lxgiveaways.create'
    action:
      type: open_menu
      menu: giveaway-create

==================================================
9. DYNAMIC GIVEAWAY SLOTS
==================================================

Giveaway entries must be dynamically rendered.

Example:

giveaways:
  slots:
    - 10
    - 11
    - 12
    - 13
    - 14
    - 15
    - 16

    - 19
    - 20
    - 21
    - 22
    - 23
    - 24
    - 25

    - 28
    - 29
    - 30
    - 31
    - 32
    - 33
    - 34

    - 37
    - 38
    - 39
    - 40
    - 41
    - 42
    - 43

  item:
    material: PLAYER_HEAD
    amount: 1

    name: '%giveaway_name%'

    lore:
      - '&8Hosted by &f%host%'
      - ''
      - '&7Prize: &f%prize%'
      - '&7Winners: &f%winner_count%'
      - '&7Entries: &f%entries%'
      - '&7Time Left: &f%time_left%'
      - ''
      - '%status%'
      - ''
      - '&eClick to view.'

    action:
      type: preview

Dynamic slots must be completely configurable.

If there are fewer giveaways than available slots, unused slots remain empty unless an explicit empty-state item is configured.

==================================================
10. GIVEAWAY ITEMS MENU
==================================================

File:

gui/giveaway-items.yml

Purpose:

Display pending giveaway rewards.

Default layout:

- Center area = pending rewards.
- Bottom-left = Collect All.
- Bottom navigation = Previous / Refresh / Next.
- Bottom-right = Back.

Collect All exists ONLY here.

Example:

items:

  collect_all:
    slot: 46
    material: HOPPER
    name: '7FF55&lCOLLECT ALL'
    lore:
      - '&8Pending Rewards'
      - ''
      - '&7Pending: &f%pending_rewards%'
      - ''
      - '&eClick to collect all.'
    action:
      type: collect_all

  previous_page:
    slot: 49
    material: ARROW
    action:
      type: previous_page

  refresh:
    slot: 50
    material: CLOCK
    action:
      type: refresh

  next_page:
    slot: 51
    material: ARROW
    action:
      type: next_page

  back:
    slot: 53
    material: BARRIER
    name: '&c&lBACK'
    action:
      type: open_menu
      menu: main-menu

Dynamic rewards:

rewards:
  slots:
    - 20
    - 21
    - 22
    - 23
    - 24
    - 25
    - 29
    - 30
    - 31
    - 32
    - 33
    - 34

  item:
    material: CHEST
    name: '&#FFD75A&l%reward_name%'
    lore:
      - '&8Giveaway Reward'
      - ''
      - '&7Giveaway: &f%giveaway_name%'
      - '&7Won: &f%won_time%'
      - ''
      - '&eClick to claim.'

    action:
      type: claim_reward

==================================================
11. GIVEAWAY CREATE MENU
==================================================

File:

gui/giveaway-create.yml

Purpose:

Create and configure player-hosted giveaways.

Default configurable items:

- Prizes
- Duration
- Winners
- Entry Settings
- Preview
- Cancel
- Start Giveaway

Example:

menu:
  title: '7FF55&lCreate Giveaway'
  size: 54

items:

  prizes:
    slot: 20
    material: CHEST
    name: '&#FFD75A&lPRIZES'
    lore:
      - '&8Giveaway Setup'
      - ''
      - '&7Items: &f%prize_item_count%'
      - ''
      - '&eClick to configure.'
    action:
      type: set_prizes

  duration:
    slot: 22
    material: CLOCK
    name: '7FFFF&lDURATION'
    lore:
      - '&7Duration: &f%duration%'
      - ''
      - '&eClick to change.'
    action:
      type: set_duration

  winners:
    slot: 24
    material: PLAYER_HEAD
    name: '&#FFAA00&lWINNERS'
    lore:
      - '&7Winners: &f%winner_count%'
      - ''
      - '&eClick to change.'
    action:
      type: set_winners

  entry_settings:
    slot: 31
    material: PAPER
    name: '&#AA55FF&lENTRY SETTINGS'
    lore:
      - '&7Configure who can enter.'
      - ''
      - '&eClick to configure.'
    action:
      type: entry_settings

  cancel:
    slot: 46
    material: BARRIER
    name: '&c&lCANCEL'
    action:
      type: cancel

  preview:
    slot: 50
    material: CLOCK
    name: '7FFFF&lPREVIEW'
    action:
      type: preview

  start_giveaway:
    slot: 54
    material: LIME_DYE
    name: '7FF55&lSTART GIVEAWAY'
    action:
      type: start_giveaway

==================================================
12. COMPLETE GUI ACTION SYSTEM
==================================================

Implement one centralized action dispatcher.

Supported actions:

open_menu
preview
collect_all
claim_reward
previous_page
next_page
refresh
set_prizes
set_duration
set_winners
entry_settings
cancel
start_giveaway
close
none

Example:

action:
  type: open_menu
  menu: giveaway-items

Java must resolve the action through the GUI action handler.

Conceptually:

GuiActionHandler.execute(
    Player player,
    GuiAction action,
    GuiContext context
)

Use a centralized switch/registry.

Do not duplicate action logic across GUI classes.

==================================================
13. ACTION RULES
==================================================

open_menu:

- Open configured menu.
- Validate menu exists.
- Never hardcode menu layout.
- Preserve relevant context.

preview:

- Resolve giveaway using secure giveaway ID/context.
- Open giveaway preview.
- Never identify giveaway solely from display name/material/lore.

collect_all:

- Only intended for giveaway-items.yml.
- Find all claimable rewards.
- Verify ownership.
- Verify inventory capacity.
- Prevent duplication.
- Claim atomically.
- Refresh GUI.
- Handle partial capacity according to overflow policy.

claim_reward:

- Resolve reward UUID from secure context.
- Verify reward belongs to player.
- Verify reward is unclaimed.
- Claim atomically.
- Prevent double-click duplication.
- Refresh GUI.

previous_page:

- Never go below page 1.
- Preserve filters/context.
- Refresh current GUI.

next_page:

- Never exceed final page.
- Correctly handle partial final pages.
- Refresh current GUI.

refresh:

- Re-query current dynamic data.
- Recalculate placeholders.
- Recalculate conditions.
- Recalculate dynamic slots.
- Preserve page/menu context.

set_prizes:

- Open prize editor.
- Use a temporary creation session.
- Prevent item loss.
- Prevent item duplication.

set_duration:

- Open configurable duration selection/input.
- Validate minimum and maximum duration.

set_winners:

- Open configurable winner selection/input.
- Validate minimum and maximum winner count.

entry_settings:

- Open entry settings.
- Store settings in the current creation session.

cancel:

- Cancel creation.
- Safely clean temporary session.
- Restore temporary items if applicable.
- Never start/create the giveaway.

start_giveaway:

- Validate every creation setting.
- Validate prizes.
- Validate permissions.
- Validate limits.
- Atomically save giveaway.
- Start timer.
- Register active giveaway.
- Broadcast configured messages.
- Handle failures safely.

close:

- Close inventory.

none:

- Do nothing.
- Consume the GUI click safely.

==================================================
14. GUI CONTEXT SYSTEM
==================================================

Every GUI must have a secure context.

Context may contain:

menu ID
page
giveaway UUID
pending reward UUID
dynamic item ID
creation session ID
player UUID

Never trust:

- item display name
- lore
- material
- custom model data
- slot alone

as authoritative game data.

For example:

GuiContext:

    menuId
    page
    giveawayId
    rewardId
    dynamicEntryId

Dynamic giveaway items must carry their actual giveaway UUID internally.

==================================================
15. GUI CONDITIONS / VISIBILITY ENGINE
==================================================

Implement a centralized condition engine.

Conditions must support:

- visible
- permissions
- PlaceholderAPI
- player state
- giveaway state
- player/giveaway relationship
- dynamic item visibility
- conditional lore
- conditional visual states
- conditional actions
- nested AND/OR groups
- hide mode
- disabled mode
- empty-state items

==================================================
16. BASIC VISIBILITY
==================================================

Example:

visible: true

or:

visible: false

If false, item is not rendered.

==================================================
17. PERMISSION CONDITIONS
==================================================

Example:

conditions:
  permission:
    value: 'lxgiveaways.create'
    mode: has

Support:

has
lacks

Multiple permissions:

conditions:
  permissions:
    mode: all
    values:
      - 'lxgiveaways.create'
      - 'lxgiveaways.vip'

OR:

conditions:
  permissions:
    mode: any
    values:
      - 'lxgiveaways.admin'
      - 'lxgiveaways.moderator'

==================================================
18. PLACEHOLDER CONDITIONS
==================================================

Integrate PlaceholderAPI optionally.

Example:

conditions:
  placeholder:
    placeholder: '%luckperms_primary_group_name%'
    operator: equals
    value: 'vip'

Operators:

equals
not_equals
contains
not_contains
starts_with
ends_with
greater_than
greater_or_equal
less_than
less_or_equal
is_true
is_false
exists
not_exists

Placeholder errors must never crash the plugin.

==================================================
19. PLAYER STATE CONDITIONS
==================================================

Support built-in player conditions:

online
op
sneaking
flying
gliding
swimming
in_water
in_lava
gamemode
health
food_level
level
experience
world
permission

Example:

conditions:
  player:
    gamemode:
      equals: SURVIVAL

    world:
      equals: spawn

    level:
      greater_or_equal: 10

==================================================
20. GIVEAWAY STATE CONDITIONS
==================================================

Support:

active
ended
cancelled
pending
full
available
entered
not_entered
host
winner
not_winner

Example:

conditions:
  giveaway:
    state:
      equals: active

==================================================
21. PLAYER/GIVEAWAY RELATIONSHIP
==================================================

Support:

host
entered
not_entered
winner
not_winner

Example:

conditions:
  giveaway:
    player:
      state: not_entered

This must be based on authoritative giveaway data.

==================================================
22. CONDITIONAL VISUAL STATES
==================================================

Support:

default:
  material: LIME_DYE
  name: '&aENTER'

states:

  entered:
    material: GREEN_DYE
    name: '&aENTERED'
    glow: true

  ended:
    material: GRAY_DYE
    name: '&7ENDED'

  host:
    material: GOLD_BLOCK
    name: '&6YOUR GIVEAWAY'

Java selects the current visual state during rendering.

==================================================
23. CONDITIONAL LORE
==================================================

Allow different lore depending on conditions.

Example:

lore:
  - '&7Prize: &f%prize%'

  - condition:
      giveaway:
        player:
          state: not_entered
    lines:
      - '&eClick to enter.'

  - condition:
      giveaway:
        player:
          state: entered
    lines:
      - '&aโœ“ You are entered.'

  - condition:
      giveaway:
        state: ended
    lines:
      - '&7This giveaway has ended.'

==================================================
24. CONDITIONAL ACTIONS
==================================================

Allow:

action:
  default:
    type: preview

  states:

    ended:
      type: none

    entered:
      type: preview

    host:
      type: preview

==================================================
25. HIDE VS DISABLED
==================================================

Support:

visibility:
  mode: hide

or:

visibility:
  mode: disabled

Hide:

- Item completely disappears.

Disabled:

- Item remains visible.
- Click does nothing or uses configured disabled behavior.
- Visual appearance may change.

Example:

visibility:
  mode: disabled

disabled:
  material: GRAY_DYE
  name: '&8NO NEXT PAGE'
  lore:
    - '&7There are no more pages.'

==================================================
26. EMPTY STATE
==================================================

Dynamic giveaway/reward slots must remain empty when no data exists unless explicitly configured otherwise.

Optional:

empty-state:
  enabled: true
  slot: 22
  material: BARRIER
  name: '&c&lNO GIVEAWAYS'
  lore:
    - '&7There are currently no active giveaways.'

==================================================
27. CONDITION ENGINE JAVA ARCHITECTURE
==================================================

Use reusable interfaces/classes.

Example:

GuiCondition

PermissionCondition
PlaceholderCondition
PlayerStateCondition
GiveawayStateCondition
CompositeCondition

Conceptually:

boolean evaluate(
    Player player,
    GuiContext context
)

Support:

ALL
ANY
NOT

groups.

Example:

conditions:

  mode: all

  groups:

    - mode: all
      permissions:
        - lxgiveaways.create

    - mode: any
      placeholders:
        - ...
        - ...

==================================================
28. CONDITION EVALUATION ORDER
==================================================

Evaluate:

1. Item enabled/disabled
2. Permissions
3. Player state
4. Placeholder conditions
5. Giveaway state
6. Composite conditions
7. Visibility
8. Visual state
9. Placeholder rendering
10. Final ItemStack creation

This occurs when:

- GUI opens
- GUI refreshes
- Page changes
- Returning to a GUI
- Relevant state changes

==================================================
29. SECURITY
==================================================

GUI visibility is NOT security.

Every action must independently validate:

- player permission
- player ownership
- giveaway state
- reward ownership
- giveaway existence
- reward existence
- current server state
- current database state

Never trust GUI appearance.

A hidden item must not be considered protection.

==================================================
30. GUI FILLER SYSTEM
==================================================

Each GUI file has its own filler.

Example:

filler:
  enabled: true
  material: GRAY_STAINED_GLASS_PANE
  name: ' '
  lore: []

  slots:
    - 0
    - 1
    - 2
    - 3
    - 4
    - 5
    - 6
    - 7
    - 8
    - 9
    - 17
    - 18
    - 26
    - 27
    - 35
    - 36
    - 44

Filler must never cover configured functional items.

Priority:

1. Functional item
2. Dynamic item
3. Decoration
4. Filler
5. Empty

If an item occupies a filler slot, the functional item wins.

Server owners can change:

- material
- slots
- name
- lore
- amount
- glow
- custom model data
- item flags
- visibility

==================================================
31. ITEM CONFIGURATION
==================================================

Every GUI item must support:

slot
material
amount
name
lore
glow
custom-model-data
item-flags
permission
visible
conditions
visibility
action
sound

Example:

item:
  slot: 20
  material: CHEST
  amount: 1

  name: '&#FFD75A&lPRIZES'

  lore:
    - '&7Configure your giveaway prizes.'

  glow: false

  custom-model-data: 0

  item-flags: []

  permission: ''

  visible: true

  action:
    type: set_prizes

==================================================
32. HEX COLORS
==================================================

Support:

PFF00

and:

#80FF00

Also support normal Minecraft legacy colors:

&0 through &f

Use Adventure components where appropriate.

Do not hardcode colors in Java.

==================================================
33. PLACEHOLDERS
==================================================

Support internal placeholders such as:

%player%
%player_uuid%
%giveaway_id%
%giveaway_name%
%host%
%prize%
%winner_count%
%entries%
%time_left%
%status%
%pending_rewards%
%reward_name%
%won_time%
%page%
%total_pages%
%duration%
%prize_item_count%

PlaceholderAPI integration should be optional.

If PlaceholderAPI is unavailable, internal LxGiveaways placeholders must continue working.

==================================================
34. GIVEAWAY CREATION
==================================================

Players create giveaways through giveaway-create.yml.

Creation session must contain:

- creator UUID
- prizes
- duration
- winner count
- entry settings
- creation timestamp
- current state

Do not immediately create a permanent giveaway until START_GIVEAWAY succeeds.

==================================================
35. PRIZE SAFETY
==================================================

This is critical.

Never duplicate or destroy items.

When creating a giveaway:

1. Validate items.
2. Create a temporary creation session.
3. Do not irreversibly remove items before final confirmation.
4. At finalization, perform an atomic operation.
5. Save the prize snapshot.
6. Ensure the transaction cannot execute twice.
7. Handle disconnect/restart safely.

Claiming rewards must also be atomic.

==================================================
36. GIVEAWAY ENTRY
==================================================

Players can enter active giveaways.

Rules:

- Cannot enter ended giveaway.
- Cannot enter cancelled giveaway.
- Cannot enter own giveaway unless explicitly configured.
- Cannot enter twice.
- Check all configured entry conditions.
- Save entry persistently.
- Prevent duplicate entries.
- Refresh GUI after successful entry.
- Send configurable message.
- Play configurable sound.

==================================================
37. WINNER SELECTION
==================================================

When giveaway ends:

1. Lock giveaway.
2. Load valid entries.
3. Validate entries.
4. Randomly select configured number of winners.
5. Prevent duplicate winner selection unless explicitly configured.
6. Persist winners.
7. Generate pending rewards.
8. Broadcast results.
9. Handle offline winners.
10. Mark giveaway completed.

Use a secure and fair random selection implementation.

Do not use predictable randomness.

==================================================
38. OFFLINE WINNERS
==================================================

Offline winners must still receive persistent pending rewards.

Do not require the winner to be online when the giveaway ends.

When the winner logs in:

- pending rewards remain available.
- They can open giveaway-items.yml.
- They can claim rewards.
- They can collect all rewards.

==================================================
39. REWARD STORAGE
==================================================

Rewards must survive:

- restart
- crash
- server shutdown
- player disconnect
- player death
- GUI close

Recommended:

SQLite by default.

Optional:

MySQL/MariaDB.

Storage abstraction:

RewardRepository
GiveawayRepository
EntryRepository
CreationRepository

Do not couple GUI code directly to SQL.

==================================================
40. DUPLICATION PROTECTION
==================================================

All reward operations must be transactional/idempotent.

Protect against:

- double-clicks
- shift-click
- number-key swaps
- drag events
- double claim
- reconnect during claim
- crash during claim
- simultaneous GUI actions
- multiple server threads

Only one successful claim operation may consume a reward.

==================================================
41. INVENTORY EVENT SAFETY
==================================================

GUI inventories must safely handle:

- click
- shift-click
- number-key
- double-click
- drag
- hotbar swap
- drop
- pickup
- inventory close

Do not allow players to steal GUI items.

Do not allow GUI action items to enter player inventory.

==================================================
42. PAGINATION
==================================================

Reusable pagination engine.

Support:

- previous page
- next page
- current page
- total pages
- configurable slots
- dynamic entries
- empty pages
- page placeholders

Pagination must work for:

- giveaways
- pending rewards
- future admin menus

==================================================
43. GUI REFRESH
==================================================

Refreshing must:

- re-query current data
- recalculate placeholders
- reevaluate conditions
- reevaluate visibility
- update dynamic items
- preserve current page
- preserve menu context

Avoid unnecessary inventory flickering.

==================================================
44. GUI CACHING
==================================================

Use short-lived per-render/per-GUI context caching where appropriate.

Do not repeatedly perform expensive queries for every item.

However:

State-changing actions MUST always revalidate authoritative data.

Never trust stale cached giveaway/reward state for mutations.

==================================================
45. SOUNDS
==================================================

Every GUI may have:

open sound
close sound
click sound
refresh sound
page sound
success sound
error sound

Example:

sounds:
  click:
    enabled: true
    sound: UI_BUTTON_CLICK
    volume: 1.0
    pitch: 1.0

Individual items may override global sounds.

All sounds configurable.

==================================================
46. BROADCAST SYSTEM
==================================================

Configurable broadcasts for:

- giveaway created
- giveaway started
- player entered
- giveaway ending
- giveaway ended
- winners selected
- reward available
- giveaway cancelled
- giveaway rerolled

Support:

chat
title
subtitle
actionbar
sound

Everything configurable.

==================================================
47. MESSAGES
==================================================

Create:

messages.yml

All messages configurable.

Support:

- HEX colors
- placeholders
- prefix
- multiline messages
- sounds
- title/subtitle
- actionbar

Never hardcode user-facing messages.

==================================================
48. BROADCASTS.YML
==================================================

Create:

broadcasts.yml

Example:

giveaway-created:
  enabled: true
  chat:
    enabled: true
    message:
      - ''
      - 'PFF00&lGIVEAWAY'
      - '&7%host% created &f%giveaway_name%'
      - ''
  sound:
    enabled: true
    sound: UI_TOAST_CHALLENGE_COMPLETE
    volume: 1.0
    pitch: 1.0

==================================================
49. CONFIGURATION FILES
==================================================

Create:

config.yml
messages.yml
broadcasts.yml
storage.yml
permissions.yml

GUI:

gui/main-menu.yml
gui/giveaway-items.yml
gui/giveaway-create.yml

Optional future:

gui/giveaway-preview.yml
gui/admin-menu.yml

Do not require recompilation to customize GUI.

==================================================
50. CONFIG RELOAD
==================================================

Implement:

/gwy reload

Reload:

- config
- messages
- broadcasts
- permissions
- GUI files

Do not reload persistent giveaway data destructively.

Validate configurations after reload.

If a GUI has invalid YAML:

- log exact file
- log exact section/item
- explain error
- retain previous valid configuration when possible
- do not crash the server

==================================================
51. CONFIG VALIDATION
==================================================

Validate:

- invalid material
- invalid sound
- invalid slot
- invalid menu size
- invalid action
- invalid permission
- invalid placeholder condition
- invalid condition operator
- invalid menu reference
- duplicate slots
- invalid duration
- invalid winner count

Provide readable startup/reload warnings.

==================================================
52. GUI SLOT RULES
==================================================

Inventory size must be valid Bukkit chest size.

Slots are zero-based internally.

YAML should use standard Bukkit slot numbering.

Example:

54-slot GUI:

0-53

Do not allow invalid slots to crash the plugin.

==================================================
53. ADMIN MANAGEMENT
==================================================

Provide admin functionality for:

- view active giveaways
- inspect giveaway
- end giveaway
- cancel giveaway
- reroll winners
- view entries
- view winners
- view prize information

Admin GUI should use the same centralized GUI/action/condition engine.

==================================================
54. GIVEAWAY LIMITS
==================================================

Configurable:

max active giveaways per player
max duration
min duration
max winners
max prize items
max prize stack sizes
entry limits
creation cooldown
global active giveaway limit

Permissions may override limits.

==================================================
55. STORAGE
==================================================

Default:

SQLite.

Optional:

MySQL/MariaDB.

Persist:

giveaway ID
creator UUID
creator name
name
status
created time
start time
end time
duration
winner count
entry settings
prizes
entries
winners
pending rewards
claim status

Use migrations/versioning.

==================================================
56. RESTART / CRASH RECOVERY
==================================================

After restart:

- active giveaways must continue.
- timers must be reconstructed from end timestamps.
- completed giveaways must not run twice.
- pending rewards must remain.
- winners must remain.
- entries must remain.
- creation sessions must be handled safely.

Do not rely solely on in-memory timers.

Database timestamps are authoritative.

==================================================
57. THREADING
==================================================

Follow Bukkit/Paper thread-safety rules.

Do not access Bukkit API unsafely from asynchronous threads.

Database operations may be asynchronous.

Inventory operations must occur safely on the appropriate server thread.

Avoid blocking the main thread with expensive SQL operations.

==================================================
58. API / EVENTS
==================================================

Provide a public API where practical.

Events:

GiveawayCreateEvent
GiveawayStartEvent
GiveawayEntryEvent
GiveawayEndEvent
GiveawayWinnerEvent
GiveawayRewardClaimEvent
GiveawayCancelEvent
GiveawayRerollEvent

Allow other plugins to listen and optionally cancel appropriate events.

==================================================
59. OPTIONAL INTEGRATIONS
==================================================

Optional integrations:

PlaceholderAPI
Vault
LuckPerms

They must be soft dependencies.

Plugin must work without them.

Do not make core giveaway functionality depend on them.

==================================================
60. PERMISSION INTEGRATION
==================================================

LuckPerms may be used for permission/group checks, but Bukkit/Paper permissions remain authoritative.

Do not hardcode groups such as VIP/MVP.

==================================================
61. GUI DESIGN PRINCIPLE
==================================================

MOST IMPORTANT GUI RULE:

Java = functionality.

YAML = presentation.

Never hardcode:

- GUI title
- slot
- material
- name
- lore
- filler
- sound
- decoration
- visibility
- action placement

in Java.

Server owners must be able to completely redesign the GUI without recompiling.

==================================================
62. GUI ITEM PRIORITY
==================================================

When rendering:

1. Functional configured item
2. Dynamic giveaway/reward item
3. Conditional item
4. Decoration
5. Filler
6. Empty

Configured functional items override filler.

==================================================
63. ORIGINAL IMPLEMENTATION REQUIREMENT
==================================================

Do not copy source code from any existing plugin.

Do not decompile another plugin.

Do not reproduce proprietary implementation.

The uploaded screenshot/configuration is only a visual/configuration reference.

Implement the entire system independently with clean architecture.

==================================================
64. PROJECT ARCHITECTURE
==================================================

Use a clean package structure such as:

com.sparkop.lxgiveaways

    LxGiveawaysPlugin

    command/
    config/
    gui/
        GuiManager
        GuiMenu
        GuiContext
        GuiAction
        GuiActionHandler
        GuiCondition
        conditions/
        pagination/

    giveaway/
        Giveaway
        GiveawayManager
        GiveawayService
        GiveawayState
        GiveawayEntry

    reward/
        PendingReward
        RewardService
        RewardRepository

    storage/
        StorageProvider
        SQLiteStorage
        MySQLStorage

    listener/
    placeholder/
    integration/
    broadcast/
    sound/
    utility/
    api/
    event/

Keep responsibilities separated.

==================================================
65. GUI ACTION ENUM
==================================================

Create an action type system equivalent to:

OPEN_MENU
PREVIEW
COLLECT_ALL
CLAIM_REWARD
PREVIOUS_PAGE
NEXT_PAGE
REFRESH
SET_PRIZES
SET_DURATION
SET_WINNERS
ENTRY_SETTINGS
CANCEL
START_GIVEAWAY
CLOSE
NONE

Future actions must be addable without rewriting the GUI framework.

==================================================
66. CONDITION ENUM / TYPES
==================================================

Support:

PERMISSION
PLACEHOLDER
PLAYER_STATE
GIVEAWAY_STATE
RELATIONSHIP
COMPOSITE

Operators:

EQUALS
NOT_EQUALS
CONTAINS
NOT_CONTAINS
STARTS_WITH
ENDS_WITH
GREATER_THAN
GREATER_OR_EQUAL
LESS_THAN
LESS_OR_EQUAL
TRUE
FALSE
EXISTS
NOT_EXISTS

Composite:

ALL
ANY
NOT

==================================================
67. ERROR HANDLING
==================================================

Never allow malformed GUI configuration to crash the server.

Use clear logs:

[LxGiveaways] GUI configuration error
File: gui/main-menu.yml
Item: create_giveaway
Problem: Invalid material "XYZ"

Likewise for:

invalid action
invalid condition
invalid slot
invalid menu
invalid sound
invalid placeholder

==================================================
68. PERFORMANCE
==================================================

The plugin must be optimized.

Avoid:

- unnecessary database queries
- synchronous expensive operations
- rebuilding unrelated GUIs
- excessive placeholder resolution
- excessive scheduler tasks

Use:

- cached active giveaways
- efficient repositories
- asynchronous storage operations
- lightweight GUI contexts
- efficient pagination

Do not sacrifice correctness for micro-optimizations.

==================================================
69. SECURITY
==================================================

Protect against:

- reward duplication
- fake GUI clicks
- unauthorized commands
- unauthorized admin actions
- stale GUI state
- reward ownership manipulation
- giveaway ownership manipulation
- double claiming
- double winner selection
- duplicate entries
- invalid configuration exploitation

All important operations must be server-authoritative.

==================================================
70. DOCUMENTATION
==================================================

Include README.md covering:

Installation
Requirements
Commands
Permissions
Configuration
GUI customization
Creating giveaways
Prize handling
Reward claiming
Admin commands
PlaceholderAPI
Storage
MySQL setup
SQLite setup
Troubleshooting
Compatibility
API
Events

Explain every GUI YAML option.

==================================================
71. DEFAULT CONFIGURATION
==================================================

Generate complete usable default configuration files.

Do not provide empty placeholders such as:

# TODO

or:

# configure this yourself

The plugin must work immediately after installation with sensible defaults.

==================================================
72. GUI EXAMPLES
==================================================

Include complete examples for:

main-menu.yml
giveaway-items.yml
giveaway-create.yml

Every example must contain:

menu
filler
items
actions
conditions where useful
dynamic slots

==================================================
73. TESTING
==================================================

Before considering the project complete, test:

- plugin startup
- plugin reload
- main menu
- giveaway item pagination
- create menu
- prize selection
- duration selection
- winner selection
- entry settings
- preview
- start giveaway
- enter giveaway
- cannot enter twice
- cannot enter own giveaway
- giveaway expiration
- winner selection
- offline winner
- reward claiming
- collect all
- partial inventory
- restart recovery
- crash recovery
- cancellation
- reroll
- permissions
- PlaceholderAPI unavailable
- invalid configuration
- invalid material
- invalid action
- GUI click safety
- shift-click
- drag
- hotbar swap
- double-click
- number-key clicks
- item duplication prevention

==================================================
74. FINAL QUALITY REQUIREMENT
==================================================

Do not deliver a prototype.

Deliver a production-ready Paper plugin.

The final result must have:

- clean architecture
- reliable persistent storage
- safe reward handling
- complete player-hosted giveaway system
- polished GUI
- screenshot-inspired layout
- separate GUI files
- border-style configurable glass
- no automatic full glass filler
- NO Collect All button in main-menu.yml
- Collect All only in giveaway-items.yml
- centralized GUI action system
- centralized condition/visibility system
- dynamic giveaway entries
- dynamic reward entries
- pagination
- permissions
- placeholders
- player state conditions
- giveaway state conditions
- conditional visual states
- configurable sounds
- HEX colors
- configurable messages
- broadcasts
- restart recovery
- crash-safe reward handling
- SQLite
- optional MySQL/MariaDB
- optional PlaceholderAPI
- optional Vault
- optional LuckPerms
- API/events
- configuration validation
- complete documentation

Most importantly:

JAVA MUST HANDLE FUNCTIONALITY.

YAML MUST CONTROL THE COMPLETE GUI DESIGN.

A server owner must be able to redesign every GUI, move every button, change every material, change every slot, change every name/lore, modify filler patterns, change visibility conditions, change sounds and change actions without recompiling the plugin.

Build LxGiveaways as a professional, maintainable, secure and production-ready plugin.
Kodari AI
KodariOct 4 at 7:52 am 3
LxGiveaways
A production-ready Paper plugin enabling player-hosted giveaways with configurable GUI menus, persistent SQLite/MySQL storage, safe atomic item handling, and complete restart recovery. Features dynamic giveaway/reward pagination, centralized action and condition engines, HEX color support, configurable broadcasts, sounds, permissions, and optional PlaceholderAPI/Vault/LuckPerms integrations. All GUI layouts are fully YAML-driven with separate menu files, allowing complete redesign without recompilation.
  1. Create the Gradle/plugin scaffold and complete default configuration files.

  2. Implement persistent giveaway lifecycle, commands, rewards, and safe inventory handling.

  3. Add configurable GUIs, documentation, and optional integrations.

  1. Created the Gradle/Paper project, Java 25 startup check, default configuration, and separate GUI YAML files.

  2. Added SQLite persistence, giveaway entry and winner selection, pending rewards, commands, configurable messages/broadcasts, GUI rendering/actions, and a small API wrapper.

  3. Important gaps: MySQL is not implemented; reroll and lifecycle event hooks are missing; the condition engine covers only part of the requested condition set. Reward claims prevent double-claims, but a crash between marking a reward claimed and delivering it could lose that reward. This is not yet production-ready against the full specification.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
README.md
settings.gradle
Code
38 2,061
src/main/java/com/sparkop/lxgiveaways/LxGiveawaysPlugin.java
package com.sparkop.lxgiveaways;

import com.sparkop.lxgiveaways.command.GiveawayCommand;
import com.sparkop.lxgiveaways.giveaway.GiveawayService;
import com.sparkop.lxgiveaways.gui.GuiManager;
import com.sparkop.lxgiveaways.listener.InventoryListener;
import com.sparkop.lxgiveaways.listener.PlayerListener;
import com.sparkop.lxgiveaways.storage.SQLiteStorage;
import com.sparkop.lxgiveaways.utility.BroadcastService;
import com.sparkop.lxgiveaways.utility.MessageService;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.sql.SQLException;

public final class LxGiveawaysPlugin extends JavaPlugin {
    private SQLiteStorage storage;
    private GiveawayService giveawayService;
    private MessageService messages;
    private BroadcastService broadcasts;
    private GuiManager guiManager;

    @Override public void onEnable() {
        if (Runtime.version().feature() < 25) {
            getLogger().severe("LxGiveaways requires Java 25 or newer; found Java " + Runtime.version().feature() + ". Disabling.");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }
        saveDefaultConfig();
        for (String resource : new String[]{"messages.yml", "broadcasts.yml", "permissions.yml", "storage.yml", "gui/main-menu.yml", "gui/giveaway-items.yml", "gui/giveaway-create.yml"}) saveResource(resource, false);
        reloadPluginConfigs();
        try {
            YamlConfiguration storageConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "storage.yml"));
            String databaseName = storageConfig.getString("storage.sqlite.file", "giveaways.db");
            storage = new SQLiteStorage(new File(getDataFolder(), databaseName), getLogger());
            storage.initialize();
            giveawayService = new GiveawayService(this, storage);
            giveawayService.load();
            broadcasts = new BroadcastService(this);
            guiManager = new GuiManager(this);
            guiManager.reload();
            GiveawayCommand command = new GiveawayCommand(this);
            if (getCommand("gwy") != null) {
                getCommand("gwy").setExecutor(command);
                getCommand("gwy").setTabCompleter(command);
            }
            Bukkit.getPluginManager().registerEvents(new InventoryListener(this), this);
            Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
            giveawayService.startTicker();
            getLogger().info("Enabled with " + giveawayService.getActiveGiveaways().size() + " active giveaway(s).");
        } catch (SQLException exception) {
            getLogger().severe("Could not initialize giveaway storage: " + exception.getMessage());
            Bukkit.getPluginManager().disablePlugin(this);
        }
    }

    @Override public void onDisable() {
        if (giveawayService != null) giveawayService.stopTicker();
        if (storage != null) storage.close();
    }

    public void reloadPluginConfigs() {
        reloadConfig();
        if (messages == null) messages = new MessageService(this); else messages.reload();
        if (broadcasts != null) broadcasts.reload();
        if (guiManager != null) guiManager.reload();
    }

    public SQLiteStorage storage() { return storage; }
    public GiveawayService giveaways() { return giveawayService; }
    public MessageService messages() { return messages; }
    public BroadcastService broadcasts() { return broadcasts; }
    public GuiManager guiManager() { return guiManager; }
}