@Override
public void onEnable()
{
Bukkit.getPluginManager().registerEvents(this, this);
FileConfiguration config = this.getConfig();
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockBreak(BlockBreakEvent e)
{
if(!e.getPlayer().hasPermission("untouchableregions.admin.*") || !e.getPlayer().isOp())
{
ApplicableRegionSet region = plugin.getRegionManager(e.getBlock().getWorld()).getApplicableRegions(e.getBlock().getLocation());
Set<ProtectedRegion> sregion = region.getRegions();
for(ProtectedRegion reg : sregion)
{
for(String regs : regions)
if(!e.getPlayer().hasPermission("untouchableregions.admin"+ reg.getId()))
{
if(reg.getId().equalsIgnoreCase(regs))
{
e.setCancelled(true);
e.getPlayer().sendMessage(ChatColor.RED+"Вы не имеете права ломать регион "+reg.getId());
log.info(e.getPlayer() + " try to destroy block in region "+reg.getId());
return;
}
}
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockPlace(BlockPlaceEvent e)
{
if(!e.getPlayer().hasPermission("untouchableregions.admin.*") || !e.getPlayer().isOp())
{
ApplicableRegionSet region = plugin.getRegionManager(e.getBlock().getWorld()).getApplicableRegions(e.getBlock().getLocation());
Set<ProtectedRegion> sregion = region.getRegions();
for(ProtectedRegion reg : sregion)
{
[U][I][B] if(!e.getPlayer().hasPermission("untouchableregions.admin"+ reg.getId()))[/B][/I][/U]
{
for(String regs : regions)
{
if(reg.getId().equalsIgnoreCase(regs))
{
e.setCancelled(true);
e.getPlayer().sendMessage(ChatColor.RED+"Вы не имеете права ломать регион "+reg.getId());
log.info(e.getPlayer() + " try to place block in region "+reg.getId());
return;
}
}
}
}
}
}
}