Added a couple null checks in an attempt to fix #26

Cause for NPE still unknown
This commit is contained in:
Rsl1122 2017-02-25 22:04:04 +02:00
parent 814f6771a8
commit a820da3261
2 changed files with 9 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
@ -151,11 +152,16 @@ public class UserData {
}
public void addSession(SessionData session) {
sessions.add(session);
if (session != null) {
sessions.add(session);
}
}
public void addSessions(Collection<SessionData> sessions) {
this.sessions.addAll(sessions);
Collection<SessionData> filteredSessions = sessions.parallelStream()
.filter(session -> session != null)
.collect(Collectors.toList());
this.sessions.addAll(filteredSessions);
}
public void setCurrentSession(SessionData session) {

View File

@ -24,6 +24,7 @@ public class PlayerActivityGraphCreator {
CopyOnWriteArrayList<Long> sessionEnds = new CopyOnWriteArrayList<>();
CopyOnWriteArrayList<SessionData> s = new CopyOnWriteArrayList(sessionData);
s.parallelStream()
.filter(session -> (session != null))
.filter((session) -> (session.getSessionStart() > nowMinusScale))
.forEach((session) -> {
sessionEnds.add(session.getSessionEnd());