Class InventoryAction
java.lang.Object
org.cloudburstmc.server.inventory.transaction.action.InventoryAction
- Direct Known Subclasses:
CraftingTakeResultAction,CraftingTransferMaterialAction,CreativeInventoryAction,DropItemAction,SlotChangeAction
- Author:
- CreeperFace
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.cloudburstmc.api.item.ItemStackprotected org.cloudburstmc.api.item.ItemStack -
Constructor Summary
ConstructorsConstructorDescriptionInventoryAction(org.cloudburstmc.api.item.ItemStack sourceItem, org.cloudburstmc.api.item.ItemStack targetItem) -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanexecute(CloudPlayer source)Performs actions needed to complete the inventory-action server-side.longorg.cloudburstmc.api.item.ItemStackReturns the item that was present before the action took place.org.cloudburstmc.api.item.ItemStackReturns the item that the action attempted to replace the source item with.abstract booleanisValid(CloudPlayer source)Returns whether this action is currently valid.voidonAddToTransaction(InventoryTransaction transaction)Called when the action is added to the specified InventoryTransaction.abstract voidonExecuteFail(CloudPlayer source)Performs additional actions when this inventory-action did not complete successfully.abstract voidonExecuteSuccess(CloudPlayer source)Performs additional actions when this inventory-action completed successfully.booleanonPreExecute(CloudPlayer source)Called by inventory transactions before any actions are processed.
-
Field Details
-
sourceItem
protected org.cloudburstmc.api.item.ItemStack sourceItem -
targetItem
protected org.cloudburstmc.api.item.ItemStack targetItem
-
-
Constructor Details
-
InventoryAction
public InventoryAction(org.cloudburstmc.api.item.ItemStack sourceItem, org.cloudburstmc.api.item.ItemStack targetItem)
-
-
Method Details
-
getCreationTime
public long getCreationTime() -
getSourceItem
public org.cloudburstmc.api.item.ItemStack getSourceItem()Returns the item that was present before the action took place.- Returns:
- source item
-
getTargetItem
public org.cloudburstmc.api.item.ItemStack 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
-