Skip to content

Improve MenuItemStack#237

Open
1robie wants to merge 2 commits intoMaxlego08:developfrom
1robie:developement
Open

Improve MenuItemStack#237
1robie wants to merge 2 commits intoMaxlego08:developfrom
1robie:developement

Conversation

@1robie
Copy link
Copy Markdown
Collaborator

@1robie 1robie commented Apr 10, 2026

This pull request introduces several enhancements and refactorings to the menu item stack building system, particularly around durability handling, context management, and item stack construction. The changes improve flexibility by supporting placeholder-based durability, add richer context to item building, and clean up code for better maintainability.

Durability and ItemStack Improvements:

  • Refactored durability from an int to a String in ZMenuItemStack, allowing for placeholder-based durability values and added new methods (getDura, parseDura) to support this. The legacy getDurability method is now deprecated. ([[1]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-b38284c0ff63ceb184858ecc788746921202ac0187409aab4da38e35f119d5cdR104-R123), [[2]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-8ee6101b08df5d1ab53ebac20fb2dc86d74972948816c2a824ed09ffedcb5319L55-R55), [[3]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-8ee6101b08df5d1ab53ebac20fb2dc86d74972948816c2a824ed09ffedcb5319L263-R287))
  • Updated the item stack building process to apply durability using placeholders and to ensure the amount and durability are set correctly during construction. ([Common/src/main/java/fr/maxlego08/menu/ZMenuItemStack.javaL263-R287](https://github.com/Maxlego08/zMenu/pull/237/files#diff-8ee6101b08df5d1ab53ebac20fb2dc86d74972948816c2a824ed09ffedcb5319L263-R287))

Context and API Enhancements:

  • Added getItemStack() to BuildContext and its implementation in ZBuildContext, enabling the passing of a base ItemStack during item construction. Also introduced a builder method for setting the base item stack. ([[1]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-5150cca036a8f78ee5c4576ad5334971c1240d581e5df80e8879e4fe1c8b8949R33-R34), [[2]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-119cc3c9803d66d1aa8013e77edb1e8c4644efe8b183bc6b201426bf0e7edaf8L1-R11), [[3]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-119cc3c9803d66d1aa8013e77edb1e8c4644efe8b183bc6b201426bf0e7edaf8R21), [[4]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-119cc3c9803d66d1aa8013e77edb1e8c4644efe8b183bc6b201426bf0e7edaf8R39-R48), [[5]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-119cc3c9803d66d1aa8013e77edb1e8c4644efe8b183bc6b201426bf0e7edaf8R68-R73))
  • Moved ZBuildContext from common to api package, making it more accessible for API consumers. ([API/src/main/java/fr/maxlego08/menu/api/context/ZBuildContext.javaL1-R11](https://github.com/Maxlego08/zMenu/pull/237/files#diff-119cc3c9803d66d1aa8013e77edb1e8c4644efe8b183bc6b201426bf0e7edaf8L1-R11))

Code Quality and Refactoring:

  • Replaced direct field access with this. for improved clarity and consistency throughout ZMenuItemStack. ([[1]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-8ee6101b08df5d1ab53ebac20fb2dc86d74972948816c2a824ed09ffedcb5319L107-R113), [[2]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-8ee6101b08df5d1ab53ebac20fb2dc86d74972948816c2a824ed09ffedcb5319L121-R125), [[3]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-8ee6101b08df5d1ab53ebac20fb2dc86d74972948816c2a824ed09ffedcb5319L138-R155), etc.)
  • Improved cache usage logic to avoid caching for certain item types (e.g., player heads without URLs). ([Common/src/main/java/fr/maxlego08/menu/ZMenuItemStack.javaL194-R218](https://github.com/Maxlego08/zMenu/pull/237/files#diff-8ee6101b08df5d1ab53ebac20fb2dc86d74972948816c2a824ed09ffedcb5319L194-R218))
  • Cleaned up method calls to ensure all internal logic consistently uses the instance (this) context. ([[1]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-8ee6101b08df5d1ab53ebac20fb2dc86d74972948816c2a824ed09ffedcb5319L297-R305), [[2]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-8ee6101b08df5d1ab53ebac20fb2dc86d74972948816c2a824ed09ffedcb5319L317-R315), [[3]](https://github.com/Maxlego08/zMenu/pull/237/files#diff-8ee6101b08df5d1ab53ebac20fb2dc86d74972948816c2a824ed09ffedcb5319L326-R324))

These changes collectively enhance the flexibility and maintainability of the menu item stack system while improving support for dynamic and context-sensitive item properties.

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