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) {
String parsed = TagUtil.parsePlain(faction, fme, raw); // use relations
if (parsed == null) {
continue; // Due to minimal f show.
}
if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed);
if (fancy != null) {
@ -90,7 +93,7 @@ public class CmdShow extends FCommand {
// replaces all variables with no home TL
parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString();
}
if(parsed.contains("%")) {
if (parsed.contains("%")) {
parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it.
}
msg(p.txt.parse(parsed));

View File

@ -135,6 +135,9 @@ public enum TagReplacer {
if (this.type == TagType.GENERAL) {
return getValue();
}
boolean minimal = P.p.getConfig().getBoolean("minimal-show", false);
if (fp != null) {
switch (this) {
case HEADER:
@ -191,22 +194,22 @@ public enum TagReplacer {
boolean raid = P.p.getConfig().getBoolean("hcf.raidable", false) && fac.getLandRounded() >= fac.getPowerRounded();
return raid ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString();
case HOME_WORLD:
return fac.hasHome() ? fac.getHome().getWorld().getName() : "{ig}";
return fac.hasHome() ? fac.getHome().getWorld().getName() : minimal ? null : "{ig}";
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:
return fac.hasHome() ? String.valueOf(fac.getHome().getBlockY()) : "{ig}";
return fac.hasHome() ? String.valueOf(fac.getHome().getBlockY()) : minimal ? null : "{ig}";
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:
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:
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:
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:
return String.valueOf(fac.getRelationCount(Relation.ALLY));
case ENEMIES_COUNT:

View File

@ -68,7 +68,12 @@ public class TagUtil {
public static String parsePlain(Faction faction, FPlayer fplayer, String line) {
for (TagReplacer tagReplacer : TagReplacer.getByType(TagType.PLAYER)) {
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;
@ -120,6 +125,8 @@ public class TagUtil {
*/
protected static List<FancyMessage> getFancy(Faction target, FPlayer fme, TagReplacer type, String prefix) {
List<FancyMessage> fancyMessages = new ArrayList<FancyMessage>();
boolean minimal = P.p.getConfig().getBoolean("minimal-show", false);
switch (type) {
case ALLIES_LIST:
FancyMessage currentAllies = P.p.txt.parseFancy(prefix);
@ -140,7 +147,7 @@ public class TagUtil {
}
}
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:
FancyMessage currentEnemies = P.p.txt.parseFancy(prefix);
boolean firstEnemy = true;
@ -160,7 +167,7 @@ public class TagUtil {
}
}
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:
FancyMessage currentOnline = P.p.txt.parseFancy(prefix);
boolean firstOnline = true;
@ -175,7 +182,7 @@ public class TagUtil {
}
}
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:
FancyMessage currentOffline = P.p.txt.parseFancy(prefix);
boolean firstOffline = true;
@ -192,7 +199,7 @@ public class TagUtil {
}
}
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;
}

View File

@ -242,6 +242,9 @@ show:
- '<a>Online: (<i>{online}<a>/<i>{members}<a>): {online-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 | #