Skip to content

Commit

Permalink
- Fix potential NPE thrown in outpost name tab completer, caused by
Browse files Browse the repository at this point in the history
outposts in non-existent worlds.
  • Loading branch information
LlmDl committed Aug 7, 2024
1 parent 3313e7f commit 60b06e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,12 @@ public List<Town> getTownsWithoutNation() {
*/
@Nullable
public TownBlock getTownBlock(Location location) {
WorldCoord worldCoord = WorldCoord.parseWorldCoord(location);
WorldCoord worldCoord;
try {
worldCoord = WorldCoord.parseWorldCoord(location);
} catch (IllegalArgumentException ignored) {
return null;
}
return worldCoord.getTownBlockOrNull();
}

Expand Down
17 changes: 11 additions & 6 deletions Towny/src/main/java/com/palmergames/bukkit/towny/object/Town.java
Original file line number Diff line number Diff line change
Expand Up @@ -1044,13 +1044,18 @@ public List<String> getOutpostNames() {
for (Location loc : getAllOutpostSpawns()) {
i++;
TownBlock tboutpost = TownyAPI.getInstance().getTownBlock(loc);
if (tboutpost != null) {
String name = !tboutpost.hasPlotObjectGroup() ? tboutpost.getName() : tboutpost.getPlotObjectGroup().getName();
if (!name.isEmpty())
outpostNames.add(name);
else
outpostNames.add(String.valueOf(i));

if (tboutpost == null) {
removeOutpostSpawn(loc);
save();
continue;
}

String name = !tboutpost.hasPlotObjectGroup() ? tboutpost.getName() : tboutpost.getPlotObjectGroup().getName();
if (!name.isEmpty())
outpostNames.add(name);
else
outpostNames.add(String.valueOf(i));
}
return outpostNames;
}
Expand Down
3 changes: 2 additions & 1 deletion Towny/src/main/resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9958,4 +9958,5 @@ v0.92.0.11:
- Support custom biomes with the unwanted biomes feature, courtesy of Warrior with PR #7540.
- Fix worldcoord upper corners being in another worldcoord, courtesy of Warrior with PR #7539.
- Fix possible ConcurrentModificationException when using /ta plot claim {residentname}
- Fix potential NPE thrown by PlayerMoveEvent and PlayerTeleportEvents with a null destination location.
- Fix potential NPE thrown by PlayerMoveEvent and PlayerTeleportEvents with a null destination location.
- Fix potential NPE thrown in outpost name tab completer, caused by outposts in non-existent worlds.

0 comments on commit 60b06e1

Please sign in to comment.