Repository navigation
Conversation
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.
Description
Fixes #230
When rapidly clicking between two menus (for example spam-clicking a slot that switches from
profile_own_overviewtoprofile_backgrounds_1and back via[openguimenu] %deluxemenus_last_menu%),%deluxemenus_last_menu%could resolve to the currently open menu or return an empty/stale value due to three interacting issues:Menu.openMenubuilds menu items asynchronously before switching to the main thread to close the previousMenuHolderand open the new inventory. BecausePlayerListener's click cache expires after 75ms, spam-clicking while an async menu open is still in flight could launch a secondopenMenufor the same target menu; when the second open completed right after the first,closeMenuclosed the first instance of the target menu and overwrotelastOpenedMenuswith the target menu itself.openMenucalls had no per-player open request sequence tracking, allowing an older in-flight async build to complete after a newer open request.menus,menuHolders, andlastOpenedMenusused unsynchronizedHashMap/HashSetinstances while%deluxemenus_last_menu%(Menu.getLastMenu) andMenuHolder.refreshMenuaccessed and mutated them across main and async scheduler threads, andcloseMenucould attempt to storenullvalues inlastOpenedMenus.Changes
beginMenuOpen/isCurrentOpenRequest/finishMenuOpen) so superseded async menu builds abort cleanly without mutatingmenuHoldersorlastOpenedMenus, and guardPlayerListener.onClickwithMenu.isOpeningMenu(player)alongsideholder.isUpdating().lastOpenedMenuswith the same menu name during a menu-to-menu transition (closeMenuForTransition), while keeping normal menu closes (nextMenu == null) unchanged.menus,menuHolders, andlastOpenedMenustoConcurrentHashMap/ConcurrentHashMap.newKeySet(), guard againstnullentries, and clean up unloaded menus and disconnecting players.MenuLastMenuTestcovering rapid double-opens, out-of-order async open cancellation, rapid back-and-forth transitions, player disconnect cleanup, and concurrentgetLastMenureads.Testing
./gradlew test shadowJar