Improved chest-sign protection.

This commit is contained in:
sk89q 2011-05-04 01:24:38 -07:00
parent b58e04707d
commit b23e35cf26
3 changed files with 41 additions and 5 deletions

View File

@ -46,6 +46,10 @@ public boolean isProtected(Block block, Player player) {
}
}
public boolean isProtectedPlacement(Block block, Player player) {
return isProtectedSignAround(block, player);
}
private boolean isProtectedSignAround(Block searchBlock, Player player) {
Block side;
Boolean res;

View File

@ -347,4 +347,14 @@ public boolean isChestProtected(Block block) {
return chestProtection.isProtected(block, null);
}
public boolean isChestProtectedPlacement(Block block, Player player) {
if (!signChestProtection) {
return false;
}
if (plugin.hasPermission(player, "worldguard.chest-protection.override")) {
return false;
}
return chestProtection.isProtectedPlacement(block, player);
}
}

View File

@ -365,6 +365,7 @@ public void onBlockBurn(BlockBurnEvent event) {
}
}
if (wcfg.isChestProtected(event.getBlock())) { event.setCancelled(true); return; }
if (wcfg.useRegions) {
Block block = event.getBlock();
Vector pt = toVector(block);
@ -512,6 +513,13 @@ public void onSignChange(SignChangeEvent event) {
if (wcfg.signChestProtection) {
if (event.getLine(0).equalsIgnoreCase("[Lock]")) {
if (wcfg.isChestProtectedPlacement(event.getBlock(), player)) {
player.sendMessage(ChatColor.DARK_RED + "You do not own the adjacent chest.");
dropSign(event.getBlock());
event.setCancelled(true);
return;
}
if (event.getBlock().getType() != Material.SIGN_POST) {
player.sendMessage(ChatColor.RED
+ "The [Lock] sign must be a sign post, not a wall sign.");
@ -519,19 +527,33 @@ public void onSignChange(SignChangeEvent event) {
dropSign(event.getBlock());
event.setCancelled(true);
return;
} else if (!event.getLine(1).equalsIgnoreCase(player.getName())) {
}
if (!event.getLine(1).equalsIgnoreCase(player.getName())) {
player.sendMessage(ChatColor.RED
+ "The first owner line must be your name.");
dropSign(event.getBlock());
event.setCancelled(true);
return;
} else {
}
Material below = event.getBlock().getRelative(0, -1, 0).getType();
if (below == Material.TNT || below == Material.SAND
|| below == Material.GRAVEL || below == Material.SIGN_POST) {
player.sendMessage(ChatColor.RED
+ "That is not a safe block that you're putting this sign on.");
dropSign(event.getBlock());
event.setCancelled(true);
return;
}
event.setLine(0, "[Lock]");
player.sendMessage(ChatColor.YELLOW
+ "A chest or double chest above is now protected.");
}
}
} else {
if (event.getLine(0).equalsIgnoreCase("[Lock]")) {
player.sendMessage(ChatColor.RED