Improve PlaceholderAPI integration
This commit is contained in:
parent
15f03799a9
commit
4dd9e3ee37
@ -6,6 +6,8 @@ import com.massivecraft.factions.entity.MPlayer;
|
|||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
public class PlaceholderFactions extends PlaceholderExpansion
|
public class PlaceholderFactions extends PlaceholderExpansion
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -42,16 +44,17 @@ public class PlaceholderFactions extends PlaceholderExpansion
|
|||||||
{
|
{
|
||||||
if (player == null) return null;
|
if (player == null) return null;
|
||||||
|
|
||||||
|
|
||||||
MPlayer mplayer = MPlayer.get(player);
|
MPlayer mplayer = MPlayer.get(player);
|
||||||
if ("role".equals(params)) params = "rank";
|
if ("role".equals(params)) params = "rank";
|
||||||
|
DecimalFormat df = new DecimalFormat("#.##");
|
||||||
|
|
||||||
switch (params)
|
switch (params)
|
||||||
{
|
{
|
||||||
case "faction": return mplayer.getFaction().describeTo(mplayer);
|
case "faction": return mplayer.getFaction().getName();
|
||||||
case "power": return Double.toString(mplayer.getPower());
|
case "power": return df.format(mplayer.getPower());
|
||||||
case "powermax": return Double.toString(mplayer.getPowerMax());
|
case "powermax": return df.format(mplayer.getPowerMax());
|
||||||
case "factionpower": return Double.toString(mplayer.getFaction().getPower());
|
case "factionpower": return df.format(mplayer.getFaction().getPower());
|
||||||
case "factionpowermax": return Double.toString(mplayer.getFaction().getPowerMax());
|
case "factionpowermax": return df.format(mplayer.getFaction().getPowerMax());
|
||||||
case "title": return mplayer.getTitle();
|
case "title": return mplayer.getTitle();
|
||||||
case "rank": return mplayer.getRank().getName();
|
case "rank": return mplayer.getRank().getName();
|
||||||
case "claims": return Long.toString(BoardColl.get().getAll().stream().mapToInt(board -> board.getCount(mplayer.getFaction())).sum());
|
case "claims": return Long.toString(BoardColl.get().getAll().stream().mapToInt(board -> board.getCount(mplayer.getFaction())).sum());
|
||||||
|
Loading…
Reference in New Issue
Block a user