Skip to content

Commit

Permalink
Fixed NPE when creating legions
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-dev committed Dec 8, 2024
1 parent d86d0bc commit 183e689
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import java.sql.Timestamp;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;

import com.aionemu.gameserver.configs.main.LegionConfig;
Expand Down Expand Up @@ -35,7 +32,7 @@ public class Legion extends AionObject {
private Announcement announcement;
private LegionEmblem legionEmblem = new LegionEmblem();
private LegionWarehouse legionWarehouse;
private Map<Type, List<LegionHistoryEntry>> legionHistoryByType;
private final Map<Type, List<LegionHistoryEntry>> legionHistoryByType = new EnumMap<>(Type.class);
private AtomicBoolean hasBonus = new AtomicBoolean(false);
private int occupiedLegionDominion = 0;
private int currentLegionDominion = 0;
Expand All @@ -45,6 +42,7 @@ public Legion(int legionId, String legionName) {
super(legionId);
this.legionName = legionName;
this.legionWarehouse = new LegionWarehouse(this);
setHistory(Collections.emptyMap());
}

public int getLegionId() {
Expand Down Expand Up @@ -446,7 +444,10 @@ public List<LegionHistoryEntry> addHistory(LegionHistoryEntry entry) {
}

public void setHistory(Map<Type, List<LegionHistoryEntry>> history) {
legionHistoryByType = history;
for (Type type : Type.values()) {
List<LegionHistoryEntry> entries = history.get(type);
legionHistoryByType.put(type, entries == null ? new ArrayList<>(1) : entries);
}
}

public void addBonus() {
Expand Down

0 comments on commit 183e689

Please sign in to comment.