SpongeAPI icon indicating copy to clipboard operation
SpongeAPI copied to clipboard

Account for Unsuccessful Transactions with DataHolderBuilder.add(Key, value)

Open WillBAnders opened this issue 4 years ago • 0 comments

Following #2388, when using builders such as ItemStack.Builder the transaction result of add(Key, value) is silently ignored. This includes adding to readonly values as in that issue, but could also apply to custom data which fails to be applied.

I don't really have any good proposed solutions; the ones I can think of are throwing an exception, adding a new method/argument which throws an exception, or adding a buildResult() method that returns a Tuple<ItemStack, DataTransactionResult> or similar (but I'm not sure how this accounts for multiple failures). I personally prefer throwing an exception for my use cases (as I'm often hardcoding this and expect it to work), but in general I would think buildResult() is likely better.

WillBAnders avatar Sep 05 '21 00:09 WillBAnders