blob: 96d5e722208b567f2b39dab4f61b0760a903a40f (
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.api.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.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
public class SignEntityListener implements Listener
{
private final transient IEssentials ess;
private final transient ISignsPlugin plugin;
public SignEntityListener(final IEssentials ess, final ISignsPlugin plugin)
{
this.ess = ess;
this.plugin = plugin;
}
@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 (EssentialsSign sign : plugin.getSettings().getEnabledSigns())
{
if (sign.getBlocks().contains(block.getType()))
{
event.setCancelled(!sign.onBlockExplode(block, ess));
return;
}
}
}
}
@EventHandler(priority = EventPriority.LOW)
public void onEntityChangeBlock(final EntityChangeBlockEvent event)
{
if (event.isCancelled())
{
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 (EssentialsSign sign : plugin.getSettings().getEnabledSigns())
{
if (sign.getBlocks().contains(block.getType())
&& !sign.onBlockBreak(block, ess))
{
event.setCancelled(true);
return;
}
}
}
}
|