more fixed for cake protection, protected cake now is semi-proteced, only the first slice is not protected

This commit is contained in:
Redecouverte 2011-02-22 15:02:57 +01:00
parent c707434155
commit 135d92303d

View File

@ -39,6 +39,7 @@
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
public class WorldGuardBlockListener extends BlockListener {
/**
* Plugin.
*/
@ -105,6 +106,22 @@ public void onBlockDamage(BlockDamageEvent event) {
return;
}
}
Block blockDamaged = event.getBlock();
if (plugin.useRegions && blockDamaged.getType() == Material.CAKE_BLOCK) {
Vector pt = toVector(blockDamaged);
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.");
event.setCancelled(true);
return;
}
}
}
/**
@ -473,7 +490,10 @@ public void onBlockRightClick(BlockRightClickEvent event) {
&& !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));
byte newData = (byte) (blockClicked.getData() - 1);
newData = newData < 0 ? 0 : newData;
blockClicked.setData(newData);
player.setHealth(player.getHealth() - 3);
return;