Fixed NPE related to Factions (#486)

This commit is contained in:
Rsl1122 2018-01-29 21:26:33 +02:00
parent 2e6ca6aa8e
commit f9883473f5

View File

@ -36,20 +36,27 @@ public class FactionsData extends PluginData {
public InspectContainer getPlayerData(UUID uuid, InspectContainer inspectContainer) {
MPlayer mPlayer = MPlayer.get(uuid);
if (mPlayer == null) {
return inspectContainer;
}
if (mPlayer.hasFaction()) {
Faction faction = mPlayer.getFaction();
String factionName = faction.isNone() ? "-" : faction.getName();
double power = mPlayer.getPower();
double maxPower = mPlayer.getPowerMax();
String powerString = FormatUtils.cutDecimals(power) + " / " + FormatUtils.cutDecimals(maxPower);
String factionLeader = faction.getLeader().getName();
String factionLeaderLink = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(factionLeader), factionLeader);
if (faction != null) {
String factionName = faction.isNone() ? "-" : faction.getName();
String factionLeader = faction.getLeader().getName();
String factionLeaderLink = Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(factionLeader), factionLeader);
inspectContainer.addValue(getWithIcon("Faction", "flag", "deep-purple"), factionName);
inspectContainer.addValue(getWithIcon("Power", "bolt", "purple"), powerString);
inspectContainer.addValue(getWithIcon("Leader", "user", "purple"), factionLeaderLink);
inspectContainer.addValue(getWithIcon("Faction", "flag", "deep-purple"), factionName);
inspectContainer.addValue(getWithIcon("Leader", "user", "purple"), factionLeaderLink);
}
}
double power = mPlayer.getPower();
double maxPower = mPlayer.getPowerMax();
String powerString = FormatUtils.cutDecimals(power) + " / " + FormatUtils.cutDecimals(maxPower);
inspectContainer.addValue(getWithIcon("Power", "bolt", "purple"), powerString);
return inspectContainer;
}