Class InventoryAction
java.lang.Object
cn.nukkit.inventory.transaction.action.InventoryAction
- Direct Known Subclasses:
CraftingTakeResultAction
,CraftingTransferMaterialAction
,CreativeInventoryAction
,DamageAnvilAction
,DropItemAction
,GrindstoneItemAction
,NoOpIventoryAction
,SlotChangeAction
,SmithingItemAction
,TakeLevelAction
- Author:
- CreeperFace
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
Performs actions needed to complete the inventory-action server-side.long
Returns the item that was present before the action took place.Returns the item that the action attempted to replace the source item with.abstract boolean
Returns whether this action is currently valid.void
onAddToTransaction
(InventoryTransaction transaction) Called when the action is added to the specified InventoryTransaction.abstract void
onExecuteFail
(Player source) Performs additional actions when this inventory-action did not complete successfully.abstract void
onExecuteSuccess
(Player source) Performs additional actions when this inventory-action completed successfully.boolean
onPreExecute
(Player source) Called by inventory transactions before any actions are processed.toString()
-
Field Details
-
sourceItem
-
targetItem
-
-
Constructor Details
-
InventoryAction
-
-
Method Details
-
getCreationTime
public long getCreationTime() -
getSourceItem
Returns the item that was present before the action took place.- Returns:
- source item
-
getTargetItem
Returns the item that the action attempted to replace the source item with.- Returns:
- target item
-
onPreExecute
Called by inventory transactions before any actions are processed. If this returns false, the transaction will be cancelled.- Parameters:
source
- player- Returns:
- cancelled
-
isValid
Returns whether this action is currently valid. This should perform any necessary sanity checks.- Parameters:
source
- player- Returns:
- valid
-
onAddToTransaction
Called when the action is added to the specified InventoryTransaction.- Parameters:
transaction
- to add
-
execute
Performs actions needed to complete the inventory-action server-side. Returns if it was successful. Will return false if plugins cancelled events. This will only be called if the transaction which it is part of is considered valid.- Parameters:
source
- player- Returns:
- successfully executed
-
onExecuteSuccess
Performs additional actions when this inventory-action completed successfully.- Parameters:
source
- player
-
onExecuteFail
Performs additional actions when this inventory-action did not complete successfully.- Parameters:
source
- player
-
toString
-