summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java
blob: 90a14ca63de9e81f238b2dacff181b73587566f3 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package org.bukkit.event.block;

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

/**
 * @author SpeaKeasY
 *
 * Represents a block ignite event.
 */
public class BlockIgniteEvent extends BlockEvent implements Cancellable {

    private IgniteCause cause;
    private boolean cancel;
    private Player thePlayer;
    private Block theBlock;

    /**
     * @param Block, IgniteCause, Player or null.
     */
    public BlockIgniteEvent(Block theBlock, IgniteCause cause, Player thePlayer) {
        super(Event.Type.BLOCK_IGNITE, theBlock);
        this.cause = cause;
        this.theBlock = theBlock;
        this.thePlayer = thePlayer;
        this.cancel = false;
    }

    /**
     * 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 ignite event is cancelled, the block will not be ignited.
     * 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 ignite event is cancelled, the block will not be ignited.
     * This will not fire an event.
     *
     * @param cancel true if you wish to cancel this event
     */
    public void setCancelled(boolean cancel) {
        this.cancel = cancel;
    }

    /**
     * Gets the cause of block ignite.
     * @return An IgniteCause value detailing the cause of block ignition.
     */
    public IgniteCause getCause()
    {
        return cause;
    }

    /**
     * Gets the player who ignited this block
     *
     * @return Player who placed the block, if not ignited by player returns null.
     */
    public Player getPlayer() {
        return thePlayer;
    }

    /**
     * An enum to specify the cause of the ignite
     */
    public enum IgniteCause {
        /**
         * Block ignition caused by lava.
         */
        LAVA,
        /**
         * Block ignition caused by player using flint-and-steel.
         */
        FLINT_AND_STEEL,
        /**
         * Block ignition caused by dynamic spreading of fire.
         */
        SPREAD,
        /**
         * Block ignition caused by VERY SLOW dynamic spreading of fire.
         */
        SLOW_SPREAD

    }

}