Fix GUI concurrent access and autocrafter deadlock#38
Open
Distolfix wants to merge 4 commits intoSongoda-Plugins:developmentfrom
Open
Fix GUI concurrent access and autocrafter deadlock#38Distolfix wants to merge 4 commits intoSongoda-Plugins:developmentfrom
Distolfix wants to merge 4 commits intoSongoda-Plugins:developmentfrom
Conversation
Bug fix Songoda-Plugins#1 - GUI Concurrent Access: Multiple players can now simultaneously access the same hopper GUI without closing each other's views. Changed activePlayer tracking from single Player to Set<Player>, and implemented proper cleanup when players close their GUIs individually. Bug fix Songoda-Plugins#2 - Autocrafter Deadlock Prevention: Fixed issue where hoppers with active autocrafters would fill all slots when thousands of items were on the ground, preventing the autocrafter from functioning. The suction module now reserves slots when an autocrafter is detected, maintaining at least 2 free slots (one for craft output, one for the next craft). Additionally, the autocrafter module will now automatically eject items when completely full of ingredients to prevent deadlocks.
Fix two critical bugs causing item loss with stacker plugins: 1. Suction module item loss prevention - Moved addAny() call before event emission - Only emit InventoryPickupItemEvent when items are actually added - Prevents stacker plugins from modifying entities when hopper is full 2. Storage cache slot reservation fix - Fixed overly conservative slot counting for autocrafter - Correctly calculates usable slots: (freeSlots - 1) when reserving - Allows partial stack filling regardless of reservation - Prevents items getting stuck on ground with available slots Both fixes are essential for servers using WildStacker, UltimateStacker, or RoseStacker to prevent hundreds of items disappearing during suction pickup with autocrafter active.
- Fix item duplication with protected items from other plugins Add rollbackAdd() method to revert cache changes when InventoryPickupItemEvent is cancelled This prevents duplication loop when items are protected by shop plugins - Fix slot reservation logic for autocrafter Only reserve slot when autocrafter has configured recipe, not just when module exists Remove overly restrictive slot blocking that prevented partial stack filling - Improve slot usage calculation Correctly handle free slot reservation with (freeSlots - 1) logic Allow partial stack filling even when reserving slots for autocrafter
- Save autocrafter configuration to database instead of config file Prevents data loss when server crashes or is force-killed - Use complete ItemStack serialization to preserve custom items Support items with custom names, lore, enchantments, and NBT data - Add automatic migration from old config format to database Existing autocrafter configurations are migrated on first load - Add AUTOCRAFTER type to ItemType enum for database storage
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.
Summary
This PR fixes three critical issues: GUI concurrent access crashes, autocrafter deadlock, and WildStacker/UltimateStacker item loss.
Problems Fixed
1. GUI Concurrent Access (ConcurrentModificationException)
Multiple players opening the same hopper GUI simultaneously caused server crashes due to unsynchronized iterator access in the GUI update task.
2. Autocrafter Deadlock
When autocrafter was active, it would fill all 5 slots (ingredients + output), preventing any new items from being added. The hopper would become permanently stuck with items unable to enter.
3. WildStacker/UltimateStacker Item Loss
Two separate bugs causing hundreds of items to disappear:
Solutions
GUI Thread Safety
synchronizedList()wrapper for GUI update task viewer listConcurrentModificationExceptioncrashesAutocrafter Slot Reservation
reserveOneSlotparameter inaddAny()to enforce reservationWildStacker Item Loss Fixes
addAny()before event emission, only emit event whenadded > 0(freeSlots - 1)when reservingTechnical Details
Thread Safety Implementation
Slot Reservation Logic
Event Emission Fix
Testing
Compatibility