Allow removing regions

This commit is contained in:
Eric 2018-11-16 14:37:49 +01:00
parent e43eed1821
commit fd1178edce
3 changed files with 29 additions and 0 deletions

View File

@ -132,4 +132,13 @@ public interface IWorldGuardImplementation {
return addRegion(id, Arrays.asList(point1, point2), 0, 0); return addRegion(id, Arrays.asList(point1, point2), 0, 0);
} }
/**
* Remove a region, including inheriting children.
*
* @param world The world
* @param id The region ID
* @return A list of removed regions where the first entry is the region specified by {@code id}
*/
Optional<Set<WrappedRegion>> removeRegion(@NonNull World world, @NonNull String id);
} }

View File

@ -215,4 +215,14 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
} }
} }
@Override
public Optional<Set<WrappedRegion>> removeRegion(World world, String id) {
Optional<Set<ProtectedRegion>> set = getWorldManager(world).map(manager -> manager.removeRegion(id));
if (set.isPresent()) {
return Optional.of(set.get().stream().map(region -> toRegion(region)).collect(Collectors.toSet()));
} else {
return Optional.empty();
}
}
} }

View File

@ -230,4 +230,14 @@ public class WorldGuardImplementation implements IWorldGuardImplementation {
return Optional.empty(); return Optional.empty();
} }
} }
@Override
public Optional<Set<WrappedRegion>> removeRegion(World world, String id) {
Optional<Set<ProtectedRegion>> set = getWorldManager(world).map(manager -> manager.removeRegion(id));
if (set.isPresent()) {
return Optional.of(set.get().stream().map(region -> toRegion(region)).collect(Collectors.toSet()));
} else {
return Optional.empty();
}
}
} }