From 4dd9e3ee372652059d5eb68f5b7e573e5c42fccc Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Sun, 3 Feb 2019 20:52:21 +0100 Subject: [PATCH] Improve PlaceholderAPI integration --- .../placeholderapi/PlaceholderFactions.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/com/massivecraft/factions/integration/placeholderapi/PlaceholderFactions.java b/src/com/massivecraft/factions/integration/placeholderapi/PlaceholderFactions.java index 9b1e4f5e..7483e499 100644 --- a/src/com/massivecraft/factions/integration/placeholderapi/PlaceholderFactions.java +++ b/src/com/massivecraft/factions/integration/placeholderapi/PlaceholderFactions.java @@ -6,6 +6,8 @@ import com.massivecraft.factions.entity.MPlayer; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.entity.Player; +import java.text.DecimalFormat; + public class PlaceholderFactions extends PlaceholderExpansion { // -------------------------------------------- // @@ -42,16 +44,17 @@ public class PlaceholderFactions extends PlaceholderExpansion { if (player == null) return null; - MPlayer mplayer = MPlayer.get(player); if ("role".equals(params)) params = "rank"; + DecimalFormat df = new DecimalFormat("#.##"); + switch (params) { - case "faction": return mplayer.getFaction().describeTo(mplayer); - case "power": return Double.toString(mplayer.getPower()); - case "powermax": return Double.toString(mplayer.getPowerMax()); - case "factionpower": return Double.toString(mplayer.getFaction().getPower()); - case "factionpowermax": return Double.toString(mplayer.getFaction().getPowerMax()); + case "faction": return mplayer.getFaction().getName(); + case "power": return df.format(mplayer.getPower()); + case "powermax": return df.format(mplayer.getPowerMax()); + case "factionpower": return df.format(mplayer.getFaction().getPower()); + case "factionpowermax": return df.format(mplayer.getFaction().getPowerMax()); case "title": return mplayer.getTitle(); case "rank": return mplayer.getRank().getName(); case "claims": return Long.toString(BoardColl.get().getAll().stream().mapToInt(board -> board.getCount(mplayer.getFaction())).sum());