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
|
package com.earth2me.essentials.protect;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.inventory.ItemStack;
public class EssentialsProtectPlayerListener extends PlayerListener
{
private EssentialsProtect parent;
private int signBlockX;
private int signBlockY;
private int signBlockZ;
private EssentialsProtectData spData = null;
public EssentialsProtectPlayerListener(EssentialsProtect parent)
{
Essentials.loadClasses();
this.parent = parent;
}
public void initialize()
{
if (spData != null) return;
spData = new EssentialsProtectData();
}
@Override
public void onPlayerInteract(PlayerInteractEvent event)
{
initialize();
if (event.isCancelled()) return;
ItemStack item = event.getItem();
User user = User.get(event.getPlayer());
Block blockClicked = event.getClickedBlock();
if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild())
{
event.setCancelled(true);
return;
}
if (item != null && EssentialsProtect.checkProtectionItems(EssentialsProtect.usageList, item.getTypeId()) && !user.isAuthorized("essentials.protect.exemptusage"))
{
event.setCancelled(true);
return;
}
if (user.isAuthorized("essentials.protect.ownerinfo"))
{
String ownerName = spData.getBlockOwner(user.getWorld().getName(), user.getName(),
blockClicked);
if (ownerName != null)
{
user.sendMessage(ChatColor.GOLD + "[EssentialsProtect] Protection owner: "
+ ownerName);
}
}
if (item != null && EssentialsProtect.checkProtectionItems(EssentialsProtect.onUseAlert, item.getTypeId()))
{
parent.alert(user, item.getType().toString(), "used: ");
}
/*if (item != null && item.getTypeId() == 323)
{
if (EssentialsProtect.genSettings.get("protect.protect.signs"))
{
if (user.isAuthorized("essentials.protect"))
{
signBlockX = blockClicked.getX();
signBlockY = blockClicked.getY();
signBlockZ = blockClicked.getZ();
initialize();
spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), signBlockX,
signBlockY + 1, signBlockZ);
if (EssentialsProtect.genSettings.get("protect.protect.block-below"))
{
spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), signBlockX,
signBlockY, signBlockZ);
}
}
}
}*/
}
}
|