From 76e6fd27650aded039505780788e9114b2563a68 Mon Sep 17 00:00:00 2001 From: drtshock Date: Thu, 6 Aug 2015 16:34:01 -0500 Subject: [PATCH] Add factionless sidebar. --- .../scoreboards/sidebar/FDefaultSidebar.java | 18 ++++++++++++++++-- src/main/resources/config.yml | 5 +++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/scoreboards/sidebar/FDefaultSidebar.java b/src/main/java/com/massivecraft/factions/scoreboards/sidebar/FDefaultSidebar.java index d92e18b4..af93921b 100644 --- a/src/main/java/com/massivecraft/factions/scoreboards/sidebar/FDefaultSidebar.java +++ b/src/main/java/com/massivecraft/factions/scoreboards/sidebar/FDefaultSidebar.java @@ -4,6 +4,7 @@ import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.P; import com.massivecraft.factions.scoreboards.FSidebarProvider; +import java.util.ArrayList; import java.util.List; import java.util.ListIterator; @@ -11,12 +12,25 @@ public class FDefaultSidebar extends FSidebarProvider { @Override public String getTitle(FPlayer fplayer) { - return replaceTags(fplayer, P.p.getConfig().getString("scoreboard.default-title", "i love drt")); + return replaceTags(fplayer, P.p.getConfig().getString("scoreboard.default-title", "{name}")); } @Override public List getLines(FPlayer fplayer) { - List lines = P.p.getConfig().getStringList("scoreboard.default"); + if (fplayer.hasFaction()) { + return getOutput(fplayer, "scoreboard.default"); + } else if (P.p.getConfig().getBoolean("scoreboard.factionless-enabled", false)) { + return getOutput(fplayer, "scoreboard.factionless"); + } + return getOutput(fplayer, "scoreboard.default"); // no faction, factionless-board disabled + } + + public List getOutput(FPlayer fplayer, String list) { + List lines = P.p.getConfig().getStringList(list); + + if (lines == null || lines.isEmpty()) { + return new ArrayList(); + } ListIterator it = lines.listIterator(); while (it.hasNext()) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 32240b86..47952b36 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -144,6 +144,11 @@ scoreboard: - "&aBalance" - "${balance}" + factionless-enabled: false + factionless: + - "Make a new Faction" + - "Use /f create" + # Configration section for warmups. # Warmup times are in seconds - if a value of 0 is set, there is no warmup. warmups: