Skip to content

Refactor methods for improved readability, validation, and error handling - #266

Draft
1robie wants to merge 25 commits into
Maxlego08:developfrom
1robie:develop
Draft

Refactor methods for improved readability, validation, and error handling#266
1robie wants to merge 25 commits into
Maxlego08:developfrom
1robie:develop

Conversation

@1robie

@1robie 1robie commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces several important security improvements and bug fixes, primarily focused on preventing "ghost GUI" abuse and strengthening item duplication protection. It also includes various code quality and logic improvements throughout the codebase.

Security improvements:

  • Added new configuration options (close-on-move, max-move-distance, close-on-damage) to automatically close inventory menus when a player moves too far from the open location or takes/deals damage, preventing ghost GUI/session desynchronization exploits. The player's location is now captured when opening a menu and checked on movement and damage events. ([[1]](https://github.com/Maxlego08/zMenu/pull/266/files#diff-9a9449436824297bb658ef3c22a6d3a85ef10e7835de43649133ca8d2cc4935bR291-R318), [[2]](https://github.com/Maxlego08/zMenu/pull/266/files#diff-9a9449436824297bb658ef3c22a6d3a85ef10e7835de43649133ca8d2cc4935bR474-R477), [[3]](https://github.com/Maxlego08/zMenu/pull/266/files#diff-9a9449436824297bb658ef3c22a6d3a85ef10e7835de43649133ca8d2cc4935bR548-R550), [[4]](https://github.com/Maxlego08/zMenu/pull/266/files#diff-9a9449436824297bb658ef3c22a6d3a85ef10e7835de43649133ca8d2cc4935bR612-R615), [[5]](https://github.com/Maxlego08/zMenu/pull/266/files#diff-8f2e80c5a045135f84749982a3114df8a90e5dd07a46c0c71dd6672903ada21fR39), [[6]](https://github.com/Maxlego08/zMenu/pull/266/files#diff-8f2e80c5a045135f84749982a3114df8a90e5dd07a46c0c71dd6672903ada21fR195-R206), [[7]](https://github.com/Maxlego08/zMenu/pull/266/files#diff-3bd14d078188074c410028847113ceae68865d0ad5b844a27183ef87fbe2fcc3R45-R75))
  • Improved anti-dupe protection: Item marking and detection now work on all items, not just those with ItemMeta. This closes a loophole where vanilla items (e.g., NETHERITE_INGOT, TOTEM_OF_UNDYING) could bypass dupe checks. ([[1]](https://github.com/Maxlego08/zMenu/pull/266/files#diff-d78d4624bb34bf6dab228a9b1a85b8094e37c95f41ea0e6310cc2f93f01fa993L30-R34), [[2]](https://github.com/Maxlego08/zMenu/pull/266/files#diff-d78d4624bb34bf6dab228a9b1a85b8094e37c95f41ea0e6310cc2f93f01fa993L49-R49), [[3]](https://github.com/Maxlego08/zMenu/pull/266/files#diff-3bd14d078188074c410028847113ceae68865d0ad5b844a27183ef87fbe2fcc3R45-R75))

Code quality and bug fixes:

  • Improved slot parsing in ButtonLoader: Now trims whitespace and correctly handles closed integer ranges, fixing off-by-one and whitespace bugs in slot definitions. ([API/src/main/java/fr/maxlego08/menu/api/loader/ButtonLoader.javaL62-R71](https://github.com/Maxlego08/zMenu/pull/266/files#diff-7cf26bc11fd0d818fc63eb35ef1b40188c764690933d0f1ef8321e9f9d805ad2L62-R71))
  • Refactored message sending logic to use modern Java features (pattern matching for instanceof) and improved code clarity. ([[1]](https://github.com/Maxlego08/zMenu/pull/266/files#diff-672b4305d3f1b89e9bc2942b8fdb5e5f006b0b21c28e911c4827b1149c5216baL77-R75), [[2]](https://github.com/Maxlego08/zMenu/pull/266/files#diff-672b4305d3f1b89e9bc2942b8fdb5e5f006b0b21c28e911c4827b1149c5216baR98-R103))
  • Enhanced switch button logic to safely handle non-integer placeholder values and decimals, preventing rendering errors when placeholders are missing or invalid. ([src/main/java/fr/maxlego08/menu/button/buttons/ZSwitchButton.javaL46-R87](https://github.com/Maxlego08/zMenu/pull/266/files#diff-cbbf8d938afbe1777df9054f169b6dcd55b507981213e2eaddfbbfa36a00e1d5L46-R87))
  • Fixed a potential ClassCastException in dupe listener by checking the type of the event sender before casting. ([src/main/java/fr/maxlego08/menu/dupe/DupeListener.javaL99-R97](https://github.com/Maxlego08/zMenu/pull/266/files#diff-08d03b363bf802a33a4816a382d82e353c1ec1c94d8d11f02d7045543c5588dcL99-R97))

See the updated changelog.md for detailed descriptions of the security fixes and new configuration options. ([changelog.mdR45-R75](https://github.com/Maxlego08/zMenu/pull/266/files#diff-3bd14d078188074c410028847113ceae68865d0ad5b844a27183ef87fbe2fcc3R45-R75))

1robie added 19 commits August 25, 2026 10:11
…hes method for improved readability and error handling
@1robie
1robie marked this pull request as draft September 6, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant