blob: 8b3a32aa5ec2c9ecbd1312f8f09ede7c33edb272 (
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
|
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 EssentialsProtectData spData = null;
public EssentialsProtectPlayerListener(EssentialsProtect parent)
{
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 = Essentials.getStatic().getUser(event.getPlayer());
Block blockClicked = event.getClickedBlock();
if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild())
{
if(Essentials.getStatic().getSettings().warnOnBuildDisallow())
{
user.sendMessage(ChatColor.RED + "You are not permitted to build");
}
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: ");
}
}
}
|