Package io.papermc.paper.event.player

# Class PlayerPurchaseEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
io.papermc.paper.event.player.PlayerPurchaseEvent

All Implemented Interfaces:
  `Cancellable`

Direct Known Subclasses:
  `PlayerTradeEvent`

public class PlayerPurchaseEvent extends PlayerEvent implements Cancellable
Called when a player trades with a standalone merchant GUI.

## Nested Class Summary

## Nested classes/interfaces inherited from class org.bukkit.event.Event

`Event.Result`

## Field Summary

### Fields inherited from class org.bukkit.event.player.PlayerEvent

`player`

## Constructor Summary

Constructors
Constructor
Description
`PlayerPurchaseEvent(@NotNull Player player, @NotNull MerchantRecipe trade, boolean rewardExp, boolean increaseTradeUses)`

## Method Summary

Modifier and Type
Method
Description
`static @NotNull HandlerList`
`getHandlerList()`
`@NotNull HandlerList`
`getHandlers()`
`@NotNull MerchantRecipe`
`getTrade()`
Gets the associated trade with this event
`boolean`
`isCancelled()`
Gets the cancellation state of this event.
`boolean`
`isRewardingExp()`
`void`
`setCancelled(boolean cancel)`
Sets the cancellation state of this event.
`void`
`setIncreaseTradeUses(boolean increaseTradeUses)`
Sets whether or not the trade will count as a use
`void`
`setRewardExp(boolean rewardExp)`
Sets whether the trade will try to reward exp
`void`
`setTrade(@NotNull MerchantRecipe trade)`
Sets the trade.
`boolean`
`willIncreaseTradeUses()`

### Methods inherited from class org.bukkit.event.player.PlayerEvent

`getPlayer`

### Methods inherited from class org.bukkit.event.Event

`callEvent, getEventName, isAsynchronous`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PlayerPurchaseEvent

public PlayerPurchaseEvent(@NotNull @NotNull Player player, @NotNull @NotNull MerchantRecipe trade, boolean rewardExp, boolean increaseTradeUses)

## Method Details

### getTrade

@NotNull public @NotNull MerchantRecipe getTrade()
Gets the associated trade with this event

Returns:
  the trade

### setTrade

public void setTrade(@NotNull @NotNull MerchantRecipe trade)
Sets the trade. This is then used to determine the next prices

Parameters:
  `trade` - the trade to use

### isRewardingExp

public boolean isRewardingExp()

Returns:
  will trade try to reward exp

### setRewardExp

public void setRewardExp(boolean rewardExp)
Sets whether the trade will try to reward exp

Parameters:
  `rewardExp` - try to reward exp

### willIncreaseTradeUses

public boolean willIncreaseTradeUses()

Returns:
  whether or not the trade will count as a use of the trade

### setIncreaseTradeUses

public void setIncreaseTradeUses(boolean increaseTradeUses)
Sets whether or not the trade will count as a use

Parameters:
  `increaseTradeUses` - true to count/false to not count

### isCancelled

public boolean isCancelled()
Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins

Specified by:
  `isCancelled` in interface `Cancellable`
Returns:
  true if this event is cancelled

### setCancelled

public void setCancelled(boolean cancel)
Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.

Specified by:
  `setCancelled` in interface `Cancellable`
Parameters:
  `cancel` - true if you wish to cancel this event

### getHandlers

@NotNull public @NotNull HandlerList getHandlers()

Specified by:
  `getHandlers` in class `Event`

### getHandlerList

@NotNull public static @NotNull HandlerList getHandlerList()