mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-07 17:28:03 +08:00
Fixed NPE related to Factions (#486)
This commit is contained in:
parent
2e6ca6aa8e
commit
f9883473f5
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Licence is provided in the jar as license.yml also here:
|
||||
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||
*/
|
||||
@ -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