Prevent dupe bug with recipe command#6455
Conversation
|
This also needs to be applied for shapeless recipes and recipesee would still be true here, closing inventory + setting recipeSee to false would be best so that if they have a previous recipe GUI open and cancels the GUI it wouldn't allow them to take items out |
There was a problem hiding this comment.
LGTM! Thanks for addressing this! I think that (despite the concerns of @CullanP) this is a nice quick fix for the very first place. 👍
Essentials/src/main/java/com/earth2me/essentials/commands/Commandrecipe.java
Outdated
Show resolved
Hide resolved
…andrecipe.java Co-authored-by: Benedikt Johannes <benedikt.johannes.hofer@gmail.com>
|
@benediktjohannes Can you please avoiding approving PRs or requesting changes unless you have a major feedback (not things already caught by checkstyle). |
|
Addressed the comments. Thank you! As far as I can tell, the only reason it works for the shaped recipes is because of the use of getTopInventory. The InventoryView is always a view of a crafting table when returned. |
@JRoy yes, of course! Sorry for the approval, I just wanted to give some feedback. One question: Is it ok to comment with suggestions in order to help out and let other people fix things faster like the |
The API docs are deceiving, you can still dupe using shapeless recipes, the API also states it returns null when the inventory is not opened but it doesn't return null, it returns your current view, that includes when in a bed. Tested on latest paper 1.21.11 using this fork and you can still dupe shapeless recipes using /recipe magma_cream tested with this eventhandler and running /recipe magma_cream, you'll see the items in your crafting slots, this did fix shaped recipes from duping though |
Addressed this by extracting the check into a helper method. Please re-test this for me as I was unable to test it myself. |
There is an error now on line 53 and the shaped recipes dupe again with these changes, it needs to check WORKBENCH |
|
Addressed, thank you. |
Information
This PR fixes #6450 .
Details
Proposed fix:
I added a check to make sure that items are only placed into the inventory when it successfully opens.
Environments tested:
OS: Linux Mint
Java version: 21
Demonstration:
In order to replicate the issue, I used the following code to test: