summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java
blob: c71ff7043cf2ed543584dfbc5385560b3c7442dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

package org.bukkit.event.player;

import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;

/**
 * Thrown when a player picks an item up from the ground
 */
public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
    private final Item item;
    private boolean cancel = false;

    public PlayerPickupItemEvent(final Player player, final Item item) {
        super(Event.Type.PLAYER_PICKUP_ITEM, player);
        this.item = item;
    }

    /**
     * Gets the ItemDrop created by the player
     *
     * @return Item
     */
    public Item getItem() {
        return item;
    }

    /**
     * Gets the cancellation state of this event. A cancelled event will not
     * be executed in the server, but will still pass to other plugins
     *
     * If an item pickup event is cancelled, the item will not be picked up.
     * This will not fire an event.
     *
     * @return true if this event is cancelled
     */
    public boolean isCancelled() {
        return 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
     *
     * If an item pickup event is cancelled, the item will not be picked up.
     * This will not fire an event.
     *
     * @param cancel true if you wish to cancel this event
     */
    public void setCancelled(boolean cancel) {
        this.cancel = cancel;
    }
}