public final class ItemStackTransaction extends Object
ItemStack
being offered to something. Normally,
this is useful for events where an ItemStack
is being used in an
ItemStackSnapshot
at which the outcome of the ItemStack
being used can be "invalidated" or changed.Constructor and Description |
---|
ItemStackTransaction(ItemStackSnapshot snapshot) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
Optional<ItemStackSnapshot> |
getCustom()
Gets the custom
ItemStackSnapshot for the proposed offer. |
ItemStackSnapshot |
getFinalSnapshot()
Gets the final
ItemStackSnapshot to be used. |
ItemStackSnapshot |
getSnapshot()
Gets the original
ItemStackSnapshot proposed for use, this
is considered the "default" in getFinalSnapshot() if the
custom snapshot is null . |
int |
hashCode() |
boolean |
isValid()
Gets whether this transaction is considered "valid".
|
void |
setCustom(ItemStackSnapshot custom)
Sets the custom
ItemStackSnapshot to be used in
getFinalSnapshot() . |
void |
setIsValid(boolean valid)
Sets whether this transaction is "valid" or not.
|
String |
toString() |
public ItemStackTransaction(ItemStackSnapshot snapshot)
public ItemStackSnapshot getSnapshot()
ItemStackSnapshot
proposed for use, this
is considered the "default" in getFinalSnapshot()
if the
custom snapshot is null
.public Optional<ItemStackSnapshot> getCustom()
ItemStackSnapshot
for the proposed offer. If
the custom ItemStackSnapshot
is null
,
Optional.absent()
is returned.public void setCustom(@Nullable ItemStackSnapshot custom)
ItemStackSnapshot
to be used in
getFinalSnapshot()
. If set to null
, the
getSnapshot()
will be used instead.custom
- The custom snapshotpublic ItemStackSnapshot getFinalSnapshot()
ItemStackSnapshot
to be used. If there is a valid
custom ItemStackSnapshot
, it will be used, otherwise, the
original getSnapshot()
will be returned.public boolean isValid()
false
is returned, the transaction is not "valid".public void setIsValid(boolean valid)
valid
- Whether this transaction is valid or not