Add minimal f show.

This commit is contained in:
drtshock 2015-08-06 16:59:54 -05:00
parent 3b8bc19460
commit ce77799ef1
4 changed files with 30 additions and 14 deletions

View File

@ -78,6 +78,9 @@ public class CmdShow extends FCommand {
for (String raw : show) { for (String raw : show) {
String parsed = TagUtil.parsePlain(faction, fme, raw); // use relations String parsed = TagUtil.parsePlain(faction, fme, raw); // use relations
if (parsed == null) {
continue; // Due to minimal f show.
}
if (TagUtil.hasFancy(parsed)) { if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed); List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed);
if (fancy != null) { if (fancy != null) {

View File

@ -135,6 +135,9 @@ public enum TagReplacer {
if (this.type == TagType.GENERAL) { if (this.type == TagType.GENERAL) {
return getValue(); return getValue();
} }
boolean minimal = P.p.getConfig().getBoolean("minimal-show", false);
if (fp != null) { if (fp != null) {
switch (this) { switch (this) {
case HEADER: case HEADER:
@ -191,22 +194,22 @@ public enum TagReplacer {
boolean raid = P.p.getConfig().getBoolean("hcf.raidable", false) && fac.getLandRounded() >= fac.getPowerRounded(); boolean raid = P.p.getConfig().getBoolean("hcf.raidable", false) && fac.getLandRounded() >= fac.getPowerRounded();
return raid ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString(); return raid ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString();
case HOME_WORLD: case HOME_WORLD:
return fac.hasHome() ? fac.getHome().getWorld().getName() : "{ig}"; return fac.hasHome() ? fac.getHome().getWorld().getName() : minimal ? null : "{ig}";
case HOME_X: case HOME_X:
return fac.hasHome() ? String.valueOf(fac.getHome().getBlockX()) : "{ig}"; return fac.hasHome() ? String.valueOf(fac.getHome().getBlockX()) : minimal ? null : "{ig}";
case HOME_Y: case HOME_Y:
return fac.hasHome() ? String.valueOf(fac.getHome().getBlockY()) : "{ig}"; return fac.hasHome() ? String.valueOf(fac.getHome().getBlockY()) : minimal ? null : "{ig}";
case HOME_Z: case HOME_Z:
return fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : "{ig}"; return fac.hasHome() ? String.valueOf(fac.getHome().getBlockZ()) : minimal ? null : "{ig}";
case LAND_VALUE: case LAND_VALUE:
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : TL.ECON_OFF.format("value"); return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : minimal ? null : TL.ECON_OFF.format("value");
case LAND_REFUND: case LAND_REFUND:
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandRefund(fac.getLandRounded())) : TL.ECON_OFF.format("refund"); return Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandRefund(fac.getLandRounded())) : minimal ? null : TL.ECON_OFF.format("refund");
case BANK_BALANCE: case BANK_BALANCE:
if (Econ.shouldBeUsed()) { if (Econ.shouldBeUsed()) {
return Conf.bankEnabled ? Econ.moneyString(Econ.getBalance(fac.getAccountId())) : TL.ECON_OFF.format("balance"); return Conf.bankEnabled ? Econ.moneyString(Econ.getBalance(fac.getAccountId())) : minimal ? null : TL.ECON_OFF.format("balance");
} }
return TL.ECON_OFF.format("balance"); return minimal ? null : TL.ECON_OFF.format("balance");
case ALLIES_COUNT: case ALLIES_COUNT:
return String.valueOf(fac.getRelationCount(Relation.ALLY)); return String.valueOf(fac.getRelationCount(Relation.ALLY));
case ENEMIES_COUNT: case ENEMIES_COUNT:

View File

@ -68,7 +68,12 @@ public class TagUtil {
public static String parsePlain(Faction faction, FPlayer fplayer, String line) { public static String parsePlain(Faction faction, FPlayer fplayer, String line) {
for (TagReplacer tagReplacer : TagReplacer.getByType(TagType.PLAYER)) { for (TagReplacer tagReplacer : TagReplacer.getByType(TagType.PLAYER)) {
if (tagReplacer.contains(line)) { if (tagReplacer.contains(line)) {
line = tagReplacer.replace(line, tagReplacer.getValue(faction, fplayer)); String value = tagReplacer.getValue(faction, fplayer);
if (value != null) {
line = tagReplacer.replace(line, value);
} else {
return null; // minimal show, entire line to be ignored
}
} }
} }
return line; return line;
@ -120,6 +125,8 @@ public class TagUtil {
*/ */
protected static List<FancyMessage> getFancy(Faction target, FPlayer fme, TagReplacer type, String prefix) { protected static List<FancyMessage> getFancy(Faction target, FPlayer fme, TagReplacer type, String prefix) {
List<FancyMessage> fancyMessages = new ArrayList<FancyMessage>(); List<FancyMessage> fancyMessages = new ArrayList<FancyMessage>();
boolean minimal = P.p.getConfig().getBoolean("minimal-show", false);
switch (type) { switch (type) {
case ALLIES_LIST: case ALLIES_LIST:
FancyMessage currentAllies = P.p.txt.parseFancy(prefix); FancyMessage currentAllies = P.p.txt.parseFancy(prefix);
@ -140,7 +147,7 @@ public class TagUtil {
} }
} }
fancyMessages.add(currentAllies); fancyMessages.add(currentAllies);
return fancyMessages; // we must return here and not outside the switch return firstAlly && minimal ? null : fancyMessages; // we must return here and not outside the switch
case ENEMIES_LIST: case ENEMIES_LIST:
FancyMessage currentEnemies = P.p.txt.parseFancy(prefix); FancyMessage currentEnemies = P.p.txt.parseFancy(prefix);
boolean firstEnemy = true; boolean firstEnemy = true;
@ -160,7 +167,7 @@ public class TagUtil {
} }
} }
fancyMessages.add(currentEnemies); fancyMessages.add(currentEnemies);
return fancyMessages; // we must return here and not outside the switch return firstEnemy && minimal ? null : fancyMessages; // we must return here and not outside the switch
case ONLINE_LIST: case ONLINE_LIST:
FancyMessage currentOnline = P.p.txt.parseFancy(prefix); FancyMessage currentOnline = P.p.txt.parseFancy(prefix);
boolean firstOnline = true; boolean firstOnline = true;
@ -175,7 +182,7 @@ public class TagUtil {
} }
} }
fancyMessages.add(currentOnline); fancyMessages.add(currentOnline);
return fancyMessages; // we must return here and not outside the switch return firstOnline && minimal ? null : fancyMessages; // we must return here and not outside the switch
case OFFLINE_LIST: case OFFLINE_LIST:
FancyMessage currentOffline = P.p.txt.parseFancy(prefix); FancyMessage currentOffline = P.p.txt.parseFancy(prefix);
boolean firstOffline = true; boolean firstOffline = true;
@ -192,7 +199,7 @@ public class TagUtil {
} }
} }
fancyMessages.add(currentOffline); fancyMessages.add(currentOffline);
return fancyMessages; // we must return here and not outside the switch return firstOffline && minimal ? null : fancyMessages; // we must return here and not outside the switch
} }
return null; return null;
} }

View File

@ -242,6 +242,9 @@ show:
- '<a>Online: (<i>{online}<a>/<i>{members}<a>): {online-list}' - '<a>Online: (<i>{online}<a>/<i>{members}<a>): {online-list}'
- '<a>Offline: (<i>{offline}<a>/<i>{members}<a>): {offline-list}' - '<a>Offline: (<i>{offline}<a>/<i>{members}<a>): {offline-list}'
# For a /f show that does not display fancy messages that are essentially empty, use minimal-show
minimal-show: false
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | Configurable /f list | # # | Configurable /f list | #