Dupe Bug with RepairRecipe
attrib opened this issue ยท 8 comments
I'm the developer of the RepairRecipe Plugin and a player reported a dupe bug issue.
After some mails and after he sent me his complete bukkit folder I nailed it down to a incompatiblity with StackableItems. Maybe we can work together to fix this issue.
I checkout your code and added some extra debug messages to figure out where the bug is.
The Problem is your InventoryUtil.checkItemInInventory() Method. This doesn't return the right amount, because in the for-loop the item is not found, therefor CraftAmount is always 0. But because of the other ingredient is found , the amount return in getCraftingAmount() is the amount you got from the other ingredient. In my case the user can dupe 5 enchanted tools, with only 1 damged enchanted tool and 5 iron ingots by using the shift key. Because the item issn't found initiatly it also doesn't get removed. So he ends up with 5 repaired dupes and the original damaged one.
The ItemUtil.isSameItem() Method does not found the right item. As the item in the inventory is an enchanted item, but the item from the recipe is an unenchanted item. Bukkit/Minecraft doesn't check the enchantment, because the rawdata (durability) set as Ingredient is -1. So in this case you do not need to check for the same enchantments.
No pull request/patch because I saw this function is used in many methodes and I do not have the time to check all this usages :(
Reprocduce:
- Install StackableItems and RepairRecipe
- Put into the workbench grid one enchanted damaged weapon/tool (iron sword)
- Put into the workbench grid five base items (iron ingots)
- Shift + Right Click the Result
Result expected: One repaired enchanted tool in the inventory, workbench grid with four iron ingots
Result currently: Five repaired enchanted tools in the inventory, workbench grid with damaged enchanted tool
I still have yet to be able to replicate this. Can you provide exact settings for both RepairRecipe and StackableItems when this happens? Also, what other plugins are you using? (especially any that affect inventory in any way)
I'm pretty sure I've fixed this, but it could use a thorough testing. I'm fixing some other bugs that I'm finding and will be testing for a couple days for a release this weekend. If you'd like a test version, let me know and I can get one up.
Man, I love getting developer bug reports. You actually looked into the issue and tried to find the problem.
Thanks, I'll look into this today hopefully and see if I can fix it.
OT: I know what you mean and I think thats the reason why I tried to help you out as much as I could. Doesn't we all love these issues with only four words - "Doesn't work, please fix" ;)
I've taken a look and tried to duplicate this, but I could not get duplicate items to be created. What version of RepairRecipe, StackableItems, and Craftbukkit are you using?
RepairRecipe 0.4.1, StackableItems v0.8.7, Bukkit 1.3.1-2.0
Maybe you need this tool in the inventory. Like get 20 iron axes, mine some wood, so that it is broken. Put 1 iron axe in the workbench grind, leave the rest in the inventory. Put 20 iron ingots in the workbench. SHIFT+Right Click on the Result.
Not quite sure if this helps and works, i'm currently at work so can't test this.