Prevent taking placeholder items from bounty GUI #5

Merged
NotAlexNoyle merged 1 commits from codex/fix-item-extraction-bug-in-gui into main 2026-03-09 04:52:53 -04:00
NotAlexNoyle commented 2026-03-09 04:52:11 -04:00 (Migrated from github.com)

Motivation

  • Players were able to remove decorative/placeholder items (e.g. glass panes) from the main bounty GUI, but those items are intended to be visual-only.
  • The GUI needs protection so interactions with the top inventory do not allow item extraction or moving placeholder items into player inventories.

Description

  • Add a new GuiProtectionListener that cancels InventoryClickEvent for clicks targeting the top inventory of the bounty GUI to block item extraction (src/main/java/com/tcoded/playerbountiesplus/listener/GuiProtectionListener.java).
  • Add drag protection by cancelling InventoryDragEvent when any dragged slot intersects the GUI top inventory (src/main/java/com/tcoded/playerbountiesplus/listener/GuiProtectionListener.java).
  • Scope protections to the bounty menu by matching the inventory title against the configured gui.main.title string from the language util.
  • Register the new listener during plugin startup so the protections are active (src/main/java/com/tcoded/playerbountiesplus/PlayerBountiesOG.java).

Testing

  • Ran ./gradlew compileJava in this environment, which failed before compilation due to a Gradle runtime error (What went wrong: 25.0.1).

Codex Task

### Motivation - Players were able to remove decorative/placeholder items (e.g. glass panes) from the main bounty GUI, but those items are intended to be visual-only. - The GUI needs protection so interactions with the top inventory do not allow item extraction or moving placeholder items into player inventories. ### Description - Add a new `GuiProtectionListener` that cancels `InventoryClickEvent` for clicks targeting the top inventory of the bounty GUI to block item extraction (`src/main/java/com/tcoded/playerbountiesplus/listener/GuiProtectionListener.java`). - Add drag protection by cancelling `InventoryDragEvent` when any dragged slot intersects the GUI top inventory (`src/main/java/com/tcoded/playerbountiesplus/listener/GuiProtectionListener.java`). - Scope protections to the bounty menu by matching the inventory title against the configured `gui.main.title` string from the language util. - Register the new listener during plugin startup so the protections are active (`src/main/java/com/tcoded/playerbountiesplus/PlayerBountiesOG.java`). ### Testing - Ran `./gradlew compileJava` in this environment, which failed before compilation due to a Gradle runtime error (`What went wrong: 25.0.1`). ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_69ae89659e94832f87c80c3b4bb07ab4)
Sign in to join this conversation.