MerchantRecipe result setter
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Is your feature request related to a problem?
It seems needlessly complicated to register a fresh merchant recipe and replace the original when all you want to change is the result item.
Describe the solution you'd like.
I think just adding this to paper-api/src/main/java/org/bukkit/inventory/MerchantRecipe.java oughta do it. Haven't tested it, though.
public void setResult(@NotNull ItemStack item) {
Preconditions.checkArgument(!item.isEmpty(), "Result cannot be an empty itemstack.");
result = item.clone();
}
Describe alternatives you've considered.
The recommended approach I've seen is to unregister the recipe and register a new one in its place, which requires copying in all the old values and doesn't seem like a very robust solution.
Other
I've poked around and haven't seen any discussion about why this would be a bad idea, so I'm assuming it was just never added. I don't see a reason why the result has to be immutable, but this isn't my code base so I can't be sure.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with paper-api/src/main/java/org/bukkit/inventory/MerchantRecipe.java and review the existing result handling and validation around MerchantRecipe. Confirm the proposed setter preserves the stated non-empty result behavior, then run the repository's relevant API checks; done means callers can replace the result without unregistering and recreating the recipe.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100