fixed cake protection in regions

This commit is contained in:
Redecouverte 2011-02-22 14:25:22 +01:00
parent 4b72805a69
commit c707434155

View File

@ -437,9 +437,10 @@ public void onBlockPlace(BlockPlaceEvent event) {
public void onBlockRightClick(BlockRightClickEvent event) {
Player player = event.getPlayer();
Block blockClicked = event.getBlock();
if (plugin.useRegions && event.getItemInHand().getTypeId() == plugin.regionWand) {
Vector pt = toVector(event.getBlock());
Vector pt = toVector(blockClicked);
ApplicableRegionSet app = plugin.regionManager.getApplicableRegions(pt);
List<String> regions = plugin.regionManager.getApplicableRegionsIDs(pt);
@ -460,6 +461,24 @@ public void onBlockRightClick(BlockRightClickEvent event) {
player.sendMessage(ChatColor.YELLOW + "WorldGuard: No defined regions here!");
}
}
Material type = blockClicked.getType();
if (plugin.useRegions && type == Material.CAKE_BLOCK) {
Vector pt = toVector(blockClicked);
LocalPlayer localPlayer = plugin.wrapPlayer(player);
if (!plugin.hasPermission(player, "/regionbypass")
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
blockClicked.setData((byte) (blockClicked.getData() - 1));
player.setHealth(player.getHealth() - 3);
return;
}
}
}