Improve PlaceholderAPI integration

This commit is contained in:
Magnus Ulf 2019-02-03 20:52:21 +01:00
parent 15f03799a9
commit 4dd9e3ee37

View File

@ -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());