Skip to content

Commit

Permalink
Fix ConcurrentModificationException iterating region names.
Browse files Browse the repository at this point in the history
  • Loading branch information
totemo committed Apr 24, 2018
1 parent 017e53b commit 98f0fec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>nu.nerd</groupId>
<name>ItemLocker</name>
<artifactId>${project.name}</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>
<packaging>jar</packaging>
<description>Locks the orientation of item frames.</description>
<url>https://github.com/NerdNu/${project.name}</url>
Expand Down
8 changes: 4 additions & 4 deletions src/nu/nerd/itemlocker/ItemLocker.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.bukkit.plugin.java.JavaPlugin;

import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;

Expand Down Expand Up @@ -788,9 +787,10 @@ protected String getRegionString(String region) {
*/
protected Set<String> getMostSpecificRegionNames(Location loc) {
RegionManager manager = getWorldGuard().getRegionManager(loc.getWorld());
ApplicableRegionSet applicableRegions = manager.getApplicableRegions(loc);
Set<ProtectedRegion> distinctRegions = applicableRegions.getRegions();
for (ProtectedRegion region : applicableRegions.getRegions()) {
// Clone set to avoid observed concurrent modification exception.
Set<ProtectedRegion> applicableRegions = new TreeSet<>(manager.getApplicableRegions(loc).getRegions());
Set<ProtectedRegion> distinctRegions = new TreeSet<>(applicableRegions);
for (ProtectedRegion region : applicableRegions) {
ProtectedRegion ancestor = region.getParent();
while (ancestor != null) {
distinctRegions.remove(ancestor);
Expand Down

0 comments on commit 98f0fec

Please sign in to comment.