int typeId = player.getItemInHand().getTypeId();
if (typeId != Residence.getConfigManager().getSelectionTooldID() && typeId != Residence.getConfigManager().getInfoToolID() && typeId != 351) {
return;
}
}
FlagPermissions perms = Residence.getPermsByLocForPlayer(block.getLocation(), player);
String world = player.getWorld().getName();
String permgroup = Residence.getPermissionManager().getGroupNameByPlayer(player);
boolean resadmin = Residence.isResAdminOn(player);
if (event.getAction() == Action.PHYSICAL) {
if (!resadmin) {
boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
boolean haspressure = perms.playerHas(player.getName(), world, "pressure", hasuse);
if ((!hasuse && !haspressure || !haspressure) && (mat == Material.STONE_PLATE || mat == Material.WOOD_PLATE)) {
event.setCancelled(true);
return;
}
}
if (!perms.playerHas(player.getName(), world, "trample", perms.playerHas(player.getName(), world, "build", true)) && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
event.setCancelled(true);
return;
}
return;
}
if (!resadmin && !Residence.getItemManager().isAllowed(heldItem, permgroup, world)) {
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("ItemBlacklisted"));
event.setCancelled(true);
return;
}
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (player.getItemInHand().getTypeId() == Residence.getConfigManager().getSelectionTooldID()) {
Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
if (wep != null) {
if (((WorldEditPlugin) wep).getConfig().getInt("wand-item") == Residence.getConfigManager().getSelectionTooldID()) {
return;
}
}
PermissionGroup group = Residence.getPermissionManager().getGroup(player);
if (player.hasPermission("residence.select") || player.hasPermission("residence.create") && !player.isPermissionSet("residence.select") || group.canCreateResidences() && !player.isPermissionSet("residence.create") && !player.isPermissionSet("residence.select") || resadmin) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
Location loc = block.getLocation();
Residence.getSelectionManager().placeLoc1(player, loc);
player.sendMessage(ChatColor.GREEN + Residence.getLanguage().getPhrase("SelectPoint", Residence.getLanguage().getPhrase("Primary")) + ChatColor.RED + "(" + loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Location loc = block.getLocation();
Residence.getSelectionManager().placeLoc2(player, loc);
player.sendMessage(ChatColor.GREEN + Residence.getLanguage().getPhrase("SelectPoint", Residence.getLanguage().getPhrase("Secondary")) + ChatColor.RED + "(" + loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ() + ")" + ChatColor.GREEN + "!");
}
}
}
if (player.getItemInHand().getTypeId() == Residence.getConfigManager().getInfoToolID()) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
Location loc = block.getLocation();
String res = Residence.getResidenceManager().getNameByLoc(loc);
if (res != null) {
Residence.getResidenceManager().printAreaInfo(res, player);
event.setCancelled(true);
}
if (res == null) {
event.setCancelled(true);
player.sendMessage(Residence.getLanguage().getPhrase("NoResHere"));
}
}
}
if (!resadmin) {
if (player.getItemInHand() != null) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (player.getItemInHand().getTypeId() == 351) {
if (player.getItemInHand().getData().getData() == 15 && block.getType() == Material.GRASS || player.getItemInHand().getData().getData() == 3 && block.getTypeId() == 17 && (block.getData() == 3 || block.getData() == 7 || block.getData() == 11 || block.getData() == 15)) {
perms = Residence.getPermsByLocForPlayer(block.getRelative(event.getBlockFace()).getLocation(), player);
if (!perms.playerHas(player.getName(), world, "build", true)) {
event.setCancelled(true);
return;
}
return;
}
}
}
}
if (isContainer(mat, block) || isCanUseEntity(mat, block)) {
boolean hasuse = perms.playerHas(player.getName(), world, "use", true);
for (Entry<Material, String> checkMat : FlagPermissions.getMaterialUseFlagList().entrySet()) {
if (mat == checkMat.getKey()) {
if (!perms.playerHas(player.getName(), world, checkMat.getValue(), hasuse)) {
if (hasuse || checkMat.getValue().equals("container")) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("FlagDeny", checkMat.getValue()));
return;
} else {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("FlagDeny", "use"));
return;
}
}
}
}
if (Residence.getConfigManager().getCustomContainers().contains(Integer.valueOf(block.getTypeId()))) {
if (!perms.playerHas(player.getName(), world, "container", hasuse)) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("FlagDeny", "container"));
return;
}
}