From ab6a19e4364dabfa722c9bbb931a999299a2548b Mon Sep 17 00:00:00 2001 From: Nick Porillo Date: Tue, 12 May 2015 21:47:22 -0400 Subject: [PATCH] Fully configurable /f list Implement the configurable f list feature from HCF --- .../com/massivecraft/factions/cmd/CmdList.java | 18 ++++++++++++++---- src/main/resources/config.yml | 16 +++++++++++++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdList.java b/src/main/java/com/massivecraft/factions/cmd/CmdList.java index 5793068a..45e64125 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdList.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdList.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TL; +import com.massivecraft.factions.zcore.util.TagUtil; import java.util.ArrayList; import java.util.Collections; @@ -13,11 +14,18 @@ import java.util.Comparator; public class CmdList extends FCommand { + private String[] defaults = new String[3]; + public CmdList() { super(); this.aliases.add("list"); this.aliases.add("ls"); + // default values in case user has old config + defaults[0] = "&e&m----------&r&e[ &2Faction List &9{pagenumber}&e/&9{pagecount} &e]&m----------"; + defaults[1] = "Factionless {factionless} online"; + defaults[2] = "{faction} {online} / {members} online, Land / Power / Maxpower: {chunks}/{power}/{maxPower}"; + //this.requiredArgs.add(""); this.optionalArgs.put("page", "1"); @@ -90,16 +98,18 @@ public class CmdList extends FCommand { end = factionList.size(); } - lines.add(p.txt.titleize("Faction List " + pagenumber + "/" + pagecount)); + + String header = p.getConfig().getString("list.header", defaults[0]); + header = header.replace("{pagenumber}", String.valueOf(pagenumber)).replace("{pagecount}", String.valueOf(pagecount)); + lines.add(p.txt.parse(header)); for (Faction faction : factionList.subList(start, end)) { if (faction.isNone()) { - lines.add(p.txt.parse("Factionless %d online", Factions.getInstance().getNone().getFPlayersWhereOnline(true).size())); + lines.add(p.txt.parse(TagUtil.parsePlain(faction, p.getConfig().getString("list.factionless", defaults[1])))); continue; } - lines.add(p.txt.parse("%s %d/%d online, %d/%d/%d", faction.getTag(fme), faction.getFPlayersWhereOnline(true).size(), faction.getFPlayers().size(), faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded())); + lines.add(p.txt.parse(TagUtil.parsePlain(faction, fme, p.getConfig().getString("list.entry", defaults[2])))); } - sendMessage(lines); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d028f631..37b493e7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -230,4 +230,18 @@ show: - 'Balance: {balance}' - 'Allies({allies}/{max-allies}): {allies-list} ' - 'Online: ({online}/{members}): {online-list}' - - 'Offline: ({offline}/{members}): {offline-list}' \ No newline at end of file + - 'Offline: ({offline}/{members}): {offline-list}' + +############################################################ +# +------------------------------------------------------+ # +# | Configurable /f list | # +# +------------------------------------------------------+ # +############################################################ + +list: + # You can only use {pagenumber} and {pagecount} in the header + header: '&e&m----------&r&e[ &2Faction List &9{pagenumber}&e/&9{pagecount} &e]&m----------' + # You can use any variables here + factionless: 'Factionless {factionless} online' + # You can use any variable here + entry: '{faction} {online} / {members} online, Land / Power / Maxpower: {chunks}/{power}/{maxPower}' \ No newline at end of file