From 4612ccd13fc9ec0cf952f74e431a9c9ad5df3f94 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 6 Dec 2017 15:34:59 +0200 Subject: [PATCH] Fixed NPE related to Factions #451 --- .../pluginbridge/plan/factions/FactionsData.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsData.java b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsData.java index 7cb420ec9..9acd67b20 100644 --- a/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsData.java +++ b/PlanPluginBridge/src/main/java/com/djrapitops/pluginbridge/plan/factions/FactionsData.java @@ -68,10 +68,14 @@ public class FactionsData extends PluginData { if (mPlayer.hasFaction()) { Faction faction = mPlayer.getFaction(); - String leadername = faction.getLeader().getName(); + if (faction == null) { + continue; + } + MPlayer leader = faction.getLeader(); + String leaderName = leader != null ? leader.getName() : ""; String factionName = faction.isNone() ? "-" : faction.getName(); - userFactions.put(uuid, mPlayer.getName().equals(leadername) ? "" + factionName + "" : factionName); + userFactions.put(uuid, mPlayer.getName().equals(leaderName) ? "" + factionName + "" : factionName); } } @@ -81,16 +85,15 @@ public class FactionsData extends PluginData { return analysisContainer; } - public final List getTopFactions() { - List topFactions = new ArrayList<>(); - topFactions.addAll(FactionColl.get().getAll()); + private List getTopFactions() { + List topFactions = new ArrayList<>(FactionColl.get().getAll()); topFactions.remove(FactionColl.get().getWarzone()); topFactions.remove(FactionColl.get().getSafezone()); topFactions.remove(FactionColl.get().getNone()); List hide = Settings.HIDE_FACTIONS.getStringList(); - topFactions.sort(new FactionComparator()); return topFactions.stream() .filter(faction -> !hide.contains(faction.getName())) + .sorted(new FactionComparator()) .collect(Collectors.toList()); } } \ No newline at end of file