Odalita-Developments / OdalitaMenus

Advanced yet simple to use inventory api for Spigot plugins (1.16.5-1.21)
https://www.spigotmc.org/resources/110376/
MIT License
18 stars 2 forks source link

Cancel menu close option #9

Closed ItzKiwiSap closed 4 months ago

ItzKiwiSap commented 5 months ago

In #7, an inquiry was made regarding the availability of an option to prevent menu closure. As this feature was not previously included, I have incorporated it into this pull request.

Two new onClose methods have been introduced to MenuContentsEvents, each equipped with a supplier to provide a MenuCloseResult. This new MenuCloseResult encompasses two enum constants: KEEP_OPEN and CLOSE, whose purposes are self-explanatory.

When returning the enum constant KEEP_OPEN prior to handling unregister logic (the default behavior), the menu will simply reopen with the same cache, pagination pages, events, etc. If KEEP_OPEN is returned after handling unregister logic, the menu will reopen with all settings restored to their initial state.

The existing onClose event methods remain intact and do not necessitate a return of MenuCloseResult. They will function equivalently to returning CLOSE in the new event methods.