Add denial messages to region protection. Changed use-protected-regions to use-regions and turned it on by default.

This commit is contained in:
sk89q 2011-01-08 16:36:25 -08:00
parent 2e225a9452
commit 953d1f0aed

View File

@ -175,7 +175,7 @@ public void loadConfiguration() {
recentLogins.clear(); recentLogins.clear();
// Load basic options // Load basic options
useRegions = properties.getBoolean("use-protected-regions", false); useRegions = properties.getBoolean("use-regions", true);
enforceOneSession = properties.getBoolean("enforce-single-session", true); enforceOneSession = properties.getBoolean("enforce-single-session", true);
blockCreepers = properties.getBoolean("block-creepers", false); blockCreepers = properties.getBoolean("block-creepers", false);
blockTNT = properties.getBoolean("block-tnt", false); blockTNT = properties.getBoolean("block-tnt", false);
@ -710,6 +710,7 @@ public boolean onItemUse(Player player, Block blockPlaced,
LocalPlayer localPlayer = new HMPlayer(player); LocalPlayer localPlayer = new HMPlayer(player);
if (!regionManager.getApplicableRegions(pt).canBuild(localPlayer)) { if (!regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
player.sendMessage(Colors.Red + "You don't have permission for this area.");
return true; return true;
} }
} }
@ -738,6 +739,7 @@ public boolean onBlockPlace(Player player, Block blockPlaced,
LocalPlayer localPlayer = new HMPlayer(player); LocalPlayer localPlayer = new HMPlayer(player);
if (!regionManager.getApplicableRegions(pt).canBuild(localPlayer)) { if (!regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
player.sendMessage(Colors.Red + "You don't have permission for this area.");
return true; return true;
} }
} }
@ -811,6 +813,7 @@ public boolean onBlockBreak(Player player, Block block) {
LocalPlayer localPlayer = new HMPlayer(player); LocalPlayer localPlayer = new HMPlayer(player);
if (!regionManager.getApplicableRegions(pt).canBuild(localPlayer)) { if (!regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
player.sendMessage(Colors.Red + "You don't have permission for this area.");
return true; return true;
} }
} }
@ -840,6 +843,19 @@ public boolean onOpenInventory(Player player, Inventory inventory) {
return true; return true;
}*/ }*/
if (useRegions && (inventory instanceof Chest
|| inventory instanceof DoubleChest
|| inventory instanceof Furnace)) {
ComplexBlock chest = (ComplexBlock)inventory;
Vector pt = new Vector(chest.getX(), chest.getY(), chest.getZ());
LocalPlayer localPlayer = new HMPlayer(player);
if (!regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
player.sendMessage(Colors.Red + "You don't have permission for this area.");
return true;
}
}
return false; return false;
} }