From 30d9978412735feb6a7b59e83c17bcc805fafa99 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 16 Jan 2011 11:54:03 -0800 Subject: [PATCH] Fixed various issues with regions. --- .../worldguard/bukkit/WorldGuardPlayerListener.java | 12 ++++++++---- .../sk89q/worldguard/bukkit/WorldGuardPlugin.java | 2 +- .../sk89q/worldguard/protection/ProtectedRegion.java | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java b/src/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java index 04860b56..a0f28423 100644 --- a/src/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java +++ b/src/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java @@ -101,7 +101,9 @@ public void onPlayerQuit(PlayerEvent event) { Player player = event.getPlayer(); plugin.invinciblePlayers.remove(player.getName()); plugin.amphibiousPlayers.remove(player.getName()); - plugin.blacklist.forgetPlayer(plugin.wrapPlayer(player)); + if (plugin.blacklist != null) { + plugin.blacklist.forgetPlayer(plugin.wrapPlayer(player)); + } } /** @@ -406,11 +408,13 @@ private void handleRegionCommand(Player player, String action, String[] args) { ProtectedRegion region = new ProtectedCuboidRegion(min, max); - if (!plugin.regionManager.overlapsUnownedRegion(region, plugin.wrapPlayer(player))) { + if (plugin.regionManager.overlapsUnownedRegion(region, plugin.wrapPlayer(player))) { player.sendMessage(ChatColor.RED + "This region overlaps with someone else's region."); return; } + region.getOwners().addPlayer(player.getName()); + plugin.regionManager.addRegion(id, region); plugin.regionLoader.save(plugin.regionManager); player.sendMessage(ChatColor.YELLOW + "Region saved as " + id + "."); @@ -666,8 +670,8 @@ private void handleRegionCommand(Player player, String action, String[] args) { + e.getMessage()); } } else if (action.equalsIgnoreCase("load")) { - if (!canUseRegionCommand(player, "/regiondelete")) { - player.sendMessage(ChatColor.RED + "You don't have the /regiondelete permission."); + if (!canUseRegionCommand(player, "/regionload")) { + player.sendMessage(ChatColor.RED + "You don't have the /regionload permission."); return; } diff --git a/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java b/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java index 120da0ac..0614adf9 100644 --- a/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java +++ b/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java @@ -285,7 +285,7 @@ boolean inGroup(Player player, String group) { } boolean hasPermission(Player player, String perm) { - return perm.equals("/regionclaim"); + return perm.equals("/regionclaim") || perm.equals("/regionload") || perm.equals("/regionsave"); } List getGroups(Player player) { diff --git a/src/com/sk89q/worldguard/protection/ProtectedRegion.java b/src/com/sk89q/worldguard/protection/ProtectedRegion.java index c63a91e6..957f050d 100644 --- a/src/com/sk89q/worldguard/protection/ProtectedRegion.java +++ b/src/com/sk89q/worldguard/protection/ProtectedRegion.java @@ -142,9 +142,9 @@ public static boolean intersects(ProtectedRegion region1, ProtectedRegion region ProtectedCuboidRegion r1 = (ProtectedCuboidRegion)region1; ProtectedCuboidRegion r2 = (ProtectedCuboidRegion)region2; BlockVector min1 = r1.getMinimumPoint(); - BlockVector max1 = r1.getMinimumPoint(); + BlockVector max1 = r1.getMaximumPoint(); BlockVector min2 = r2.getMinimumPoint(); - BlockVector max2 = r2.getMinimumPoint(); + BlockVector max2 = r2.getMaximumPoint(); return !(min1.getBlockX() > max2.getBlockX() || min1.getBlockY() > max2.getBlockY()