Skip to content

Commit

Permalink
fix: Fix Exception in Dynmap integration on empty claimed regions (#41)
Browse files Browse the repository at this point in the history
* this should fix dynmap related error reported on discord
try/catch to handle possible NoSuchElementException when iterating claimed regions and added null check in DynmapManager

* attempt to make requested changes
replaced try/catch with if/else and import explicitly
  • Loading branch information
xsmeths authored Apr 3, 2024
1 parent 699116a commit 6e498c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/main/java/com/craftaro/ultimateclaims/claim/Claim.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.Collections;

import java.util.concurrent.ThreadLocalRandom;

public class Claim {
Expand Down Expand Up @@ -91,7 +91,11 @@ public int getId() {
}

public ClaimedChunk getFirstClaimedChunk() {
return this.claimedRegions.iterator().next().getFirstClaimedChunk();
if (!this.claimedRegions.isEmpty()) {
return this.claimedRegions.iterator().next().getFirstClaimedChunk();
} else {
return null;
}
}

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public void refresh() {

if (this.plugin.getClaimManager() != null) {
for (Claim claim : this.plugin.getClaimManager().getRegisteredClaims()) {
if (Bukkit.getWorld(claim.getFirstClaimedChunk().getWorld()) == null) {
continue;
if (claim.getFirstClaimedChunk() != null && Bukkit.getWorld(claim.getFirstClaimedChunk().getWorld()) == null) {
continue;
}

if (claim.getCorners() != null) {
Expand Down

0 comments on commit 6e498c0

Please sign in to comment.