Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for null owner in AddUnits #7269

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ public class AddUnits extends Change {
}

private Map<UUID, String> buildUnitOwnerMap(final Collection<Unit> units) {
return units.stream().collect(Collectors.toMap(Unit::getId, unit -> unit.getOwner().getName()));
return units.stream()
.collect(
Collectors.toMap(
Unit::getId,
unit -> {
if (unit.getOwner() == null || unit.getOwner().getName() == null) {
return null;
}
return unit.getOwner().getName();
}));
}

@Override
Expand All @@ -67,8 +76,10 @@ private Collection<Unit> buildUnitsWithOwner(final GameData data) {
if (unit == null) {
unit = uuidToUnits.get(entry.getKey());
}
final GamePlayer player = data.getPlayerList().getPlayerId(entry.getValue());
unit.setOwner(player);
if (entry.getValue() != null) {
final GamePlayer player = data.getPlayerList().getPlayerId(entry.getValue());
unit.setOwner(player);
}
return unit;
})
.collect(Collectors.toList());
Expand Down