fixed crash in removeRegion

This commit is contained in:
Redecouverte 2011-02-28 11:00:37 +01:00
parent e4d05e14ac
commit cdf067bba8
3 changed files with 26 additions and 8 deletions

View File

@ -444,7 +444,7 @@ public void onBlockInteract(BlockInteractEvent event) {
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, (Player)entity);
if (!applicableRegions.isFlagAllowed(AreaFlags.FLAG_LEVER_AND_BUTTON, true, localPlayer)) {
if (!applicableRegions.isFlagAllowed(AreaFlags.FLAG_LEVER_AND_BUTTON, true, null)) {
((Player)entity).sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
event.setCancelled(true);
return;

View File

@ -30,6 +30,7 @@
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
import java.util.Iterator;
/**
* A very simple implementation of the region manager that uses a flat list
@ -94,11 +95,19 @@ public void removeRegion(String id) {
regions.remove(id);
if (region != null) {
for (Map.Entry<String, ProtectedRegion> entry : regions.entrySet()) {
if (entry.getValue().getParent() == region) {
removeRegion(entry.getKey());
List<String> removeRegions = new ArrayList<String>();
Iterator<ProtectedRegion> iter = regions.values().iterator();
while (iter.hasNext()) {
ProtectedRegion curRegion = iter.next();
if (curRegion.getParent() == region) {
removeRegions.add(curRegion.getId());
}
}
for(String remId : removeRegions)
{
removeRegion(remId);
}
}
}

View File

@ -33,6 +33,7 @@
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
import java.io.IOException;
import java.util.Iterator;
public class PRTreeRegionManager extends RegionManager {
@ -122,14 +123,22 @@ public void removeRegion(String id) {
regions.remove(id);
if (region != null) {
for (Map.Entry<String, ProtectedRegion> entry : regions.entrySet()) {
if (entry.getValue().getParent() == region) {
removeRegion(entry.getKey());
List<String> removeRegions = new ArrayList<String>();
Iterator<ProtectedRegion> iter = regions.values().iterator();
while (iter.hasNext()) {
ProtectedRegion curRegion = iter.next();
if (curRegion.getParent() == region) {
removeRegions.add(curRegion.getId());
}
}
for(String remId : removeRegions)
{
removeRegion(remId);
}
}
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
tree.load(regions.values());
}