Refactor methods for improved readability, validation, and error handling - #266
Draft
1robie wants to merge 25 commits into
Draft
Refactor methods for improved readability, validation, and error handling#2661robie wants to merge 25 commits into
1robie wants to merge 25 commits into
Conversation
…be evaluated as expression (Placeholder)
…d handle errors gracefully
…hes method for improved readability and error handling
… for better resource management
…th-resources for better resource management
…check asynchronously
…ors for invalid types
…Meta and use Objects.equals for comparison
… log errors for invalid types
…afely and log errors for invalid values
…r inclusive slot ranges
…g inventory on player movement and damage
…a are correctly tagged and detected
1robie
marked this pull request as draft
September 6, 2026 13:56
…memory overflow and key collisions (ZM-05)
… to prevent data loss during crashes (ZM-06)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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))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:
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))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))[src/main/java/fr/maxlego08/menu/button/buttons/ZSwitchButton.javaL46-R87](https://github.com/Maxlego08/zMenu/pull/266/files#diff-cbbf8d938afbe1777df9054f169b6dcd55b507981213e2eaddfbbfa36a00e1d5L46-R87))ClassCastExceptionin 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.mdfor detailed descriptions of the security fixes and new configuration options. ([changelog.mdR45-R75](https://github.com/Maxlego08/zMenu/pull/266/files#diff-3bd14d078188074c410028847113ceae68865d0ad5b844a27183ef87fbe2fcc3R45-R75))