mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-05 10:20:23 +01:00
Fixed NPE related to Factions (#486)
This commit is contained in:
parent
2e6ca6aa8e
commit
f9883473f5
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user