blob: 281afdc98ed164a22059d0dc896f3172c161d209 (
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
|
package com.earth2me.essentials.signs;
import com.earth2me.essentials.IEssentials;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EndermanPickupEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
public class SignEntityListener implements Listener
{
private final transient IEssentials ess;
public SignEntityListener(final IEssentials ess)
{
this.ess = ess;
}
@EventHandler(priority = EventPriority.LOW)
public void onEntityExplode(final EntityExplodeEvent event)
{
for (Block block : event.blockList())
{
if (((block.getType() == Material.WALL_SIGN
|| block.getType() == Material.SIGN_POST)
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|| EssentialsSign.checkIfBlockBreaksSigns(block))
{
event.setCancelled(true);
return;
}
for (Signs signs : Signs.values())
{
final EssentialsSign sign = signs.getSign();
if (sign.getBlocks().contains(block.getType()))
{
event.setCancelled(!sign.onBlockExplode(block, ess));
return;
}
}
}
}
@EventHandler(priority = EventPriority.LOW)
public void onEndermanPickup(final EndermanPickupEvent event)
{
if (event.isCancelled() || ess.getSettings().areSignsDisabled())
{
return;
}
final Block block = event.getBlock();
if (((block.getType() == Material.WALL_SIGN
|| block.getType() == Material.SIGN_POST)
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|| EssentialsSign.checkIfBlockBreaksSigns(block))
{
event.setCancelled(true);
return;
}
for (Signs signs : Signs.values())
{
final EssentialsSign sign = signs.getSign();
if (sign.getBlocks().contains(block.getType())
&& !sign.onBlockBreak(block, ess))
{
event.setCancelled(true);
return;
}
}
}
}
|