blob: 3aed5d155a986ab8c2355fe87e1f0a41fd1c71d3 (
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
|
package com.earth2me.essentials.signs;
import com.earth2me.essentials.api.IEssentials;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
public class SignPlayerListener implements Listener
{
private final transient IEssentials ess;
private final transient ISignsPlugin plugin;
public SignPlayerListener(final IEssentials ess, final ISignsPlugin plugin)
{
this.ess = ess;
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(final PlayerInteractEvent event)
{
if (event.isCancelled())
{
return;
}
final Block block = event.getClickedBlock();
if (block == null)
{
return;
}
final int mat = block.getTypeId();
if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId())
{
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
final Sign csign = (Sign)block.getState();
for (EssentialsSign sign : plugin.getSettings().getEnabledSigns())
{
if (csign.getLine(0).equalsIgnoreCase(sign.getSuccessName()))
{
sign.onSignInteract(block, event.getPlayer(), ess);
event.setCancelled(true);
return;
}
}
}
else
{
for (EssentialsSign sign : plugin.getSettings().getEnabledSigns())
{
if (sign.getBlocks().contains(block.getType())
&& !sign.onBlockInteract(block, event.getPlayer(), ess))
{
event.setCancelled(true);
return;
}
}
}
}
}
|