Class SlotChangeAction
java.lang.Object
cn.nukkit.inventory.transaction.action.InventoryAction
cn.nukkit.inventory.transaction.action.SlotChangeAction
- Author:
- CreeperFace
-
Field Summary
Fields inherited from class cn.nukkit.inventory.transaction.action.InventoryAction
sourceItem, targetItem
-
Constructor Summary
ConstructorDescriptionSlotChangeAction
(Inventory inventory, int inventorySlot, Item sourceItem, Item targetItem) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Sets the item into the target inventory.Returns the inventory involved in this action.int
getSlot()
Returns the inventorySlot in the inventory which this action modified.boolean
Checks if the item in the inventory at the specified inventorySlot is the same as this action's source item.void
onAddToTransaction
(InventoryTransaction transaction) Called when the action is added to the specified InventoryTransaction.void
onExecuteFail
(Player source) Sends the original inventorySlot contents to the source player to revert the action.void
onExecuteSuccess
(Player source) Sends inventorySlot changes to other viewers of the inventory.toString()
Methods inherited from class cn.nukkit.inventory.transaction.action.InventoryAction
getCreationTime, getSourceItem, getTargetItem, onPreExecute
-
Field Details
-
inventory
-
-
Constructor Details
-
SlotChangeAction
-
-
Method Details
-
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:
isValid
in classInventoryAction
- Parameters:
source
- player- Returns:
- valid
-
execute
Sets the item into the target inventory.- Specified by:
execute
in 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:
onExecuteSuccess
in classInventoryAction
- Parameters:
source
- player
-
onExecuteFail
Sends the original inventorySlot contents to the source player to revert the action.- Specified by:
onExecuteFail
in classInventoryAction
- Parameters:
source
- player
-
onAddToTransaction
Description copied from class:InventoryAction
Called when the action is added to the specified InventoryTransaction.- Overrides:
onAddToTransaction
in classInventoryAction
- Parameters:
transaction
- to add
-
toString
- Overrides:
toString
in classInventoryAction
-