Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize MenuManager and InventoryClickListener for improved server p… #113

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

DimaSergeew
Copy link
Contributor

…erformance and memory management

  • Replaced individual BukkitTask instances per player with a single global scheduled task to handle inventory updates, reducing CPU and memory overhead.
  • Cached static ItemStack objects (filler and custom items) to eliminate repetitive creation and cloning.
  • Precomputed slot-to-day mappings (slotToDayMap) for efficient event handling during inventory clicks.
  • Reduced frequency of ItemStack cloning by reusing cached templates and only updating mutable parts (e.g., time left in lore).
  • Utilized ConcurrentHashMap.newKeySet() to safely track players with open menus, ensuring thread-safe operations.
  • Implemented InventoryCloseListener to remove players from the tracking set when they close the rewards menu, preventing potential memory leaks.
  • Optimized click event processing by using pre-cached action lists for custom buttons, minimizing configuration accesses.
  • Added error handling for invalid sound configurations to prevent plugin crashes.
  • Streamlined code structure for better readability and maintainability, adding clear comments for future developers.

…erformance and memory management

- Replaced individual `BukkitTask` instances per player with a single global scheduled task to handle inventory updates, reducing CPU and memory overhead.
- Cached static `ItemStack` objects (filler and custom items) to eliminate repetitive creation and cloning.
- Precomputed slot-to-day mappings (`slotToDayMap`) for efficient event handling during inventory clicks.
- Reduced frequency of `ItemStack` cloning by reusing cached templates and only updating mutable parts (e.g., time left in lore).
- Utilized `ConcurrentHashMap.newKeySet()` to safely track players with open menus, ensuring thread-safe operations.
- Implemented `InventoryCloseListener` to remove players from the tracking set when they close the rewards menu, preventing potential memory leaks.
- Optimized click event processing by using pre-cached action lists for custom buttons, minimizing configuration accesses.
- Added error handling for invalid sound configurations to prevent plugin crashes.
- Streamlined code structure for better readability and maintainability, adding clear comments for future developers.
@NONPLAYT NONPLAYT added the 🔧 feature New feature or request label Dec 30, 2024
@NONPLAYT NONPLAYT merged commit f9ca6fb into BX-Team:master Jan 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants