Skip to content

Conversation

@MaksyKun
Copy link
Contributor

Some reworking regarding the recipe gui. It was continously updated and caused many lags in past.
This approach uses hashing to stop the gui from reloading when not required.

@MaksyKun MaksyKun requested review from Travja and Copilot July 12, 2025 07:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes the recipe GUI by hashing and caching player state to avoid unnecessary redraws, and centralizes event routing.

  • Introduces InventoryFingerprint, IngredientFingerprint, and RecipeCacheKey to fingerprint inventory, ingredients, and build cache keys
  • Refactors RecipeGui.reloadRecipes to early‐exit when inventory/level/money/page/queue state is unchanged and reuses cached CalculatedRecipe
  • Adds RecipeGuiEventRouter and enhances ProfessionGuiRegistry to manage the active recipe GUIs in a single registry

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/main/java/.../RecipeGuiEventRouter.java New listener that forwards inventory and player events to the active RecipeGui
src/main/java/.../RecipeCacheKey.java Defines a cache key combining recipe ID, inventory hash, player level/money
src/main/java/.../InventoryFingerprint.java Computes an MD5 (or fallback) fingerprint of a player’s inventory
src/main/java/.../IngredientFingerprint.java Immutable fingerprint matching item similarity for ingredient lookups
src/main/java/.../RecipeGui.java Overhauled reload logic with hashing, caching, early bail-out, removed dupes
src/main/java/.../ProfessionGuiRegistry.java Added latestRecipeGui map and clear method for tracking open recipe GUIs
src/main/java/.../CalculatedRecipe.java Now uses IngredientFingerprint in create; cleaned up equals/hashCode
src/main/java/.../InventoryPattern.java Switched from ItemBuilder to RecipeItem.fromConfig for pattern items
src/main/java/.../FusionPlayer.java Removed GUI cache; updated queue key to include category name
src/main/java/.../CommandMechanics.java Clears GUI registry and recipe cache on plugin reload
src/main/java/.../ProfessionMigration.java Added but unused import
src/main/java/.../FusionAPI.java Added defaulting getters for managers
src/main/java/.../Fusion.java Registered the new RecipeGuiEventRouter on enable
Comments suppressed due to low confidence (1)

src/main/java/studio/magemonkey/fusion/data/player/FusionPlayer.java:52

  • [nitpick] Changing the cache key to include category.getName() may break existing persisted queue lookups for callers expecting only the profession key. Verify downstream code to ensure compatibility or migrate existing entries.
            cachedQueues.put(profession + "." + category.getName(), new CraftingQueue(getPlayer(), profession, category));

@MaksyKun
Copy link
Contributor Author

I will still put that one on draft for now due to the problem of crafting times being bypassed/skipped on relogging

@MaksyKun MaksyKun marked this pull request as draft July 24, 2025 21:57
@MaksyKun MaksyKun marked this pull request as ready for review July 27, 2025 09:39
@MaksyKun MaksyKun merged commit 7eaf190 into dev Jul 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants