Add packet-based GUI backend#1
Open
Keviro wants to merge 15 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an internal “packet GUI” backend for the Bukkit platform, intended to render chest-style GUIs using PacketEvents (with a fallback to standard Bukkit inventories when unavailable or unsupported).
Changes:
- Adds a
GuiBackendabstraction with a default Bukkit implementation and an optional PacketEvents-driven packet backend. - Introduces packet GUI session/render/click tracking to open/update/close GUIs via packets.
- Adds PacketEvents as an optional (soft) dependency and updates build configuration to include the required repository and version catalog entry.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- add handling for closing inventory sessions based on user actions - improve session management by ensuring proper windowId checks - update session inventory state after closing to reflect changes
- implement normalization for item display names and lore - utilize reflection to access ItemMeta properties - ensure non-italic display names for better consistency
Adds coalesced SetSlot-based updates and per-session item conversion caching so normal GUI interactions no longer rebuild and resend the full window. Keeps full WindowItems only for open/reopen/hard repair paths, preserves Folia-safe scheduling, and maintains PacketEvents as the packet API. This massively reduces repeated ItemStack conversion and fullResync overhead during clicks, pagination, and dynamic shop GUI updates.
Handle QUICK_MOVE, SWAP, and CLONE click actions in the packet GUI backend while keeping unsafe drag/drop/double-click actions cancelled and repaired. Shift and keyboard-style clicks now enter the normal click pipeline and trigger a hard repair to avoid client-side ghost item movement.
Handle server-side close packets without sending an extra close packet or forcing updateInventory, preventing packet GUI cleanup from immediately closing dialogs opened from click handlers.
Force a post-click repair for normal left/right PICKUP clicks so client-side prediction cannot leave fake GUI items missing or stuck on the cursor. Keeps shift, swap, clone, and unsafe click repair behavior intact.
Ensure offhand swap clicks repair the client-side offhand slot and cursor so fake GUI items cannot appear as ghost items in the player's hand.
Author
|
Die neuste Version ist auf dem Dev Survival Server zum Testen |
Replace normal-click full window repairs with targeted slot/cursor repair scopes, reduce full WindowItems usage, and simplify packet item caching to avoid expensive render hashing.
Avoid expensive full window item resyncs during normal GUI clicks, remove debug toString calls from hotpaths, and batch packet writes through a guarded send plan.
Build packet GUI render/repair plans on the player scheduler, but move the expensive Bukkit-to-PacketEvents item conversion onto dedicated worker threads. This keeps GUI state access Folia-safe while reducing region thread load from PacketItemConverter/SpigotConversionUtil during packet GUI renders and click repairs. Async conversion is enabled by default and logs a warning when disabled.
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 pull request adds an optional packet-based GUI backend for InventoryFramework.
The goal is to render GUI contents as virtual packet items instead of placing real items into Bukkit inventories. This makes GUI item rendering safer against duplication issues while keeping the existing InventoryFramework API unchanged for consumers.
PacketEvents is used as the packet abstraction layer, with the Bukkit inventory backend remaining available as a fallback. The packet backend is designed to work on the current Paper/SurfCanvas/Folia runtime and keeps player-facing inventory state synchronized through packet updates.
Motivation
Inventory GUIs should not need to store their visual items as real server-side inventory contents. Rendering them through packets allows the framework to display the same GUI items to players without making those items physically exist in the server inventory state.
This improves safety for GUI-heavy plugins and provides a cleaner backend model for future inventory rendering behavior.
Notes