Class PlayerProcessItemEvent
java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.player.PlayerEvent
net.risingworld.api.events.player.PlayerProcessItemEvent
- All Implemented Interfaces:
Cancellable
Called when the player "processes" an item in his inventory. For example, this is called
when the player cuts a watermelon, slices bread, fills a canteen or bucket etc. This usually (but not always) results in
the item being removed (e.g the water melon) and one or more new items being added to the inventory (e.g water melon slices).
In other situations (e.g when filling a canteen), the item instance is kept and just the item status/value is changed.
Example: Trigger non-lethal explosion if player cuts a watermelon
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetItem()
Gets the item the player wants to process.int
Gets the new stack size of the item.int
Gets the optional new status for the item.short
Gets the new target item type ID.float
Gets the optional new value for the item.boolean
Determines if the event is cancelled.void
setCancelled
(boolean cancel) Cancels this event.void
setNewStack
(int newStack) Sets a new stack (amount of items).void
setNewStatus
(int newStatus) Sets a new optional status for the item.void
setNewTypeID
(short newTypeID) Sets a new target item type ID (i.e the type ID of the new item).void
setNewValue
(float newValue) Sets a new optional value for the item.Methods inherited from class net.risingworld.api.events.player.PlayerEvent
getPlayer
-
Method Details
-
getItem
Gets the item the player wants to process.- Returns:
- the item that's about to be processed.
-
getNewTypeID
public short getNewTypeID()Gets the new target item type ID. This means this item will transform to this item (e.g ifgetItem()
returns a water melon,getNewTypeID()
would usually return the type ID of a water melon slice etc).- Returns:
- the new type ID.
-
setNewTypeID
public void setNewTypeID(short newTypeID) Sets a new target item type ID (i.e the type ID of the new item).- Parameters:
newTypeID
- the new type ID. Set to 0 or negative value to prevent the game from adding a new item to inventory.
-
getNewStack
public int getNewStack()Gets the new stack size of the item.- Returns:
- the new stack size (amount of items).
-
setNewStack
public void setNewStack(int newStack) Sets a new stack (amount of items).- Parameters:
newStack
- the new stack size (amount of items).
-
getNewStatus
public int getNewStatus()Gets the optional new status for the item.- Returns:
- the new item status.
-
setNewStatus
public void setNewStatus(int newStatus) Sets a new optional status for the item.- Parameters:
newStatus
- the new item status.
-
getNewValue
public float getNewValue()Gets the optional new value for the item.- Returns:
- the new item value.
-
setNewValue
public void setNewValue(float newValue) Sets a new optional value for the item.- Parameters:
newValue
- the new item value.
-
getItemInfoType
-
isCancelled
public boolean isCancelled()Description copied from interface:Cancellable
Determines if the event is cancelled. If an event is cancelled, it will no longer be executed, but other plugins will still receive the event.
Please note: If the event is threaded, cancellation has no effect, i.e the event will still be executed.- Specified by:
isCancelled
in interfaceCancellable
- Returns:
- true if the event is cancelled, or false if not.
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:Cancellable
Cancels this event. This means it will no longer be executed, but other plugins will still receive the event.- Specified by:
setCancelled
in interfaceCancellable
- Parameters:
cancel
- set to true if you want to cancel this event.- Example: Cancel "PlayerEnterAreaEvent", i.e prevent player from entering an area
-