-
Notifications
You must be signed in to change notification settings - Fork 1
Recipe hashing #57
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
Recipe hashing #57
Conversation
…ull for some times)
# Conflicts: # pom.xml
There was a problem hiding this 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, andRecipeCacheKeyto fingerprint inventory, ingredients, and build cache keys - Refactors
RecipeGui.reloadRecipesto early‐exit when inventory/level/money/page/queue state is unchanged and reuses cachedCalculatedRecipe - Adds
RecipeGuiEventRouterand enhancesProfessionGuiRegistryto 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));
src/main/java/studio/magemonkey/fusion/gui/recipe/RecipeGuiEventRouter.java
Outdated
Show resolved
Hide resolved
src/main/java/studio/magemonkey/fusion/gui/recipe/InventoryFingerprint.java
Outdated
Show resolved
Hide resolved
src/main/java/studio/magemonkey/fusion/cfg/migrations/ProfessionMigration.java
Outdated
Show resolved
Hide resolved
src/main/java/studio/magemonkey/fusion/data/recipes/CalculatedRecipe.java
Show resolved
Hide resolved
…gerprint.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
I will still put that one on draft for now due to the problem of crafting times being bypassed/skipped on relogging |
…ine=true` (offline updates still dont work, but online time works now)
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.