-
Notifications
You must be signed in to change notification settings - Fork 185
/
Copy pathBarrelAccessEvent.java
75 lines (64 loc) · 1.83 KB
/
BarrelAccessEvent.java
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
package com.dre.brewery.api.events.barrel;
import com.dre.brewery.Barrel;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* A Player opens a Barrel by rightclicking it.
* <p>The PlayerInteractEvent on the Barrel may be cancelled. In that case this never gets called
* <p>Can be cancelled to silently deny opening the Barrel
*/
public class BarrelAccessEvent extends BarrelEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Player player;
private final Block clickedBlock;
private final BlockFace clickedBlockFace;
private boolean isCancelled;
public BarrelAccessEvent(Barrel barrel, Player player, Block clickedBlock) {
this(barrel, player, clickedBlock, BlockFace.UP);
}
public BarrelAccessEvent(Barrel barrel, Player player, Block clickedBlock, BlockFace clickedBlockFace) {
super(barrel);
this.player = player;
this.clickedBlock = clickedBlock;
this.clickedBlockFace = clickedBlockFace;
}
/**
* Gets the Block that was actually clicked.
* <p>For access Permissions getSpigot() should be used
*/
public Block getClickedBlock() {
return clickedBlock;
}
/**
* Get the clicked Block Face when clicking on the Barrel Block
*
* @since v3.0 (Api 3)
*/
public BlockFace getClickedBlockFace() {
return clickedBlockFace;
}
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean cancelled) {
isCancelled = cancelled;
}
public Player getPlayer() {
return player;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
// Required by Bukkit
public static HandlerList getHandlerList() {
return handlers;
}
}