Class SlotChangeAction
java.lang.Object
org.cloudburstmc.server.inventory.transaction.action.InventoryAction
org.cloudburstmc.server.inventory.transaction.action.SlotChangeAction
- Author:
- CreeperFace
-
Field Summary
FieldsFields inherited from class org.cloudburstmc.server.inventory.transaction.action.InventoryAction
sourceItem, targetItem -
Constructor Summary
ConstructorsConstructorDescriptionSlotChangeAction(org.cloudburstmc.api.inventory.Inventory inventory, int inventorySlot, org.cloudburstmc.api.item.ItemStack sourceItem, org.cloudburstmc.api.item.ItemStack targetItem) -
Method Summary
Modifier and TypeMethodDescriptionbooleanexecute(CloudPlayer source)Sets the item into the target inventory.org.cloudburstmc.api.inventory.InventoryReturns the inventory involved in this action.intgetSlot()Returns the inventorySlot in the inventory which this action modified.booleanisValid(CloudPlayer source)Checks if the item in the inventory at the specified inventorySlot is the same as this action's source item.voidonAddToTransaction(InventoryTransaction transaction)Called when the action is added to the specified InventoryTransaction.voidonExecuteFail(CloudPlayer source)Sends the original inventorySlot contents to the source player to revert the action.voidonExecuteSuccess(CloudPlayer source)Sends inventorySlot changes to other viewers of the inventory.Methods inherited from class org.cloudburstmc.server.inventory.transaction.action.InventoryAction
getCreationTime, getSourceItem, getTargetItem, onPreExecute
-
Field Details
-
inventory
protected org.cloudburstmc.api.inventory.Inventory inventory
-
-
Constructor Details
-
SlotChangeAction
public SlotChangeAction(org.cloudburstmc.api.inventory.Inventory inventory, int inventorySlot, org.cloudburstmc.api.item.ItemStack sourceItem, org.cloudburstmc.api.item.ItemStack targetItem)
-
-
Method Details
-
getInventory
public org.cloudburstmc.api.inventory.Inventory getInventory()Returns the inventory involved in this action.- Returns:
- inventory
-
getSlot
public int getSlot()Returns the inventorySlot in the inventory which this action modified.- Returns:
- slot
-
isValid
Checks if the item in the inventory at the specified inventorySlot is the same as this action's source item.- Specified by:
isValidin classInventoryAction- Parameters:
source- player- Returns:
- valid
-
execute
Sets the item into the target inventory.- Specified by:
executein classInventoryAction- Parameters:
source- player- Returns:
- successfully executed
-
onExecuteSuccess
Sends inventorySlot changes to other viewers of the inventory. This will not send any change back to the source Player.- Specified by:
onExecuteSuccessin classInventoryAction- Parameters:
source- player
-
onExecuteFail
Sends the original inventorySlot contents to the source player to revert the action.- Specified by:
onExecuteFailin classInventoryAction- Parameters:
source- player
-
onAddToTransaction
Description copied from class:InventoryActionCalled when the action is added to the specified InventoryTransaction.- Overrides:
onAddToTransactionin classInventoryAction- Parameters:
transaction- to add
-