Add truce to tag util

This commit is contained in:
Trent Hensler 2018-01-05 00:25:50 -08:00
parent 79d4a885f8
commit fb0c77efc0
3 changed files with 35 additions and 3 deletions

View File

@ -50,15 +50,15 @@ public class PlaceholderAPIManager extends EZPlaceholderHook {
return faction.getTag();
case "faction_power":
return String.valueOf(faction.getPowerRounded());
case "faction_description":
return faction.getDescription();
case "faction_powermax":
return String.valueOf(faction.getPowerMaxRounded());
case "faction_description":
return faction.getDescription();
case "faction_claims":
return String.valueOf(faction.getAllClaims().size());
case "faction_founded":
return String.valueOf(TL.sdf.format(faction.getFoundedDate()));
case "faction_joning":
case "faction_joining":
return (faction.getOpen() ? TL.COMMAND_SHOW_UNINVITED.toString() : TL.COMMAND_SHOW_INVITATION.toString());
case "faction_peaceful":
return faction.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : "";
@ -91,6 +91,8 @@ public class PlaceholderAPIManager extends EZPlaceholderHook {
return String.valueOf(faction.getRelationCount(Relation.ALLY));
case "faction_enemies":
return String.valueOf(faction.getRelationCount(Relation.ENEMY));
case "faction_truces":
return String.valueOf(faction.getRelationCount(Relation.TRUCE));
case "faction_online":
return String.valueOf(faction.getOnlinePlayers().size());
case "faction_offline":

View File

@ -23,6 +23,7 @@ public enum TagReplacer {
ALLIES_LIST(TagType.FANCY, "{allies-list}"),
ONLINE_LIST(TagType.FANCY, "{online-list}"),
ENEMIES_LIST(TagType.FANCY, "{enemies-list}"),
TRUCES_LIST(TagType.FANCY, "{truces-list}"),
OFFLINE_LIST(TagType.FANCY, "{offline-list}"),
/**
@ -64,6 +65,7 @@ public enum TagReplacer {
BANK_BALANCE(TagType.FACTION, "{faction-balance}"),
ALLIES_COUNT(TagType.FACTION, "{allies}"),
ENEMIES_COUNT(TagType.FACTION, "{enemies}"),
TRUCES_COUNT(TagType.FACTION, "{truces}"),
ONLINE_COUNT(TagType.FACTION, "{online}"),
OFFLINE_COUNT(TagType.FACTION, "{offline}"),
FACTION_SIZE(TagType.FACTION, "{members}"),
@ -76,6 +78,7 @@ public enum TagReplacer {
MAX_WARPS(TagType.GENERAL, "{max-warps}"),
MAX_ALLIES(TagType.GENERAL, "{max-allies}"),
MAX_ENEMIES(TagType.GENERAL, "{max-enemies}"),
MAX_TRUCES(TagType.GENERAL, "{max-truces}"),
FACTIONLESS(TagType.GENERAL, "{factionless}"),
TOTAL_ONLINE(TagType.GENERAL, "{total-online}");
@ -117,6 +120,11 @@ public enum TagReplacer {
return String.valueOf(P.p.getConfig().getInt("max-relations.enemy", 10));
}
return TL.GENERIC_INFINITY.toString();
case MAX_TRUCES:
if (P.p.getConfig().getBoolean("max-relations.enabled", true)) {
return String.valueOf(P.p.getConfig().getInt("max-relations.truce", 10));
}
return TL.GENERIC_INFINITY.toString();
case MAX_WARPS:
return String.valueOf(P.p.getConfig().getInt("max-warps", 5));
}
@ -213,6 +221,8 @@ public enum TagReplacer {
return String.valueOf(fac.getRelationCount(Relation.ALLY));
case ENEMIES_COUNT:
return String.valueOf(fac.getRelationCount(Relation.ENEMY));
case TRUCES_COUNT:
return String.valueOf(fac.getRelationCount(Relation.TRUCE));
case ONLINE_COUNT:
return String.valueOf(fac.getOnlinePlayers().size());
case OFFLINE_COUNT:

View File

@ -162,6 +162,26 @@ public class TagUtil {
}
fancyMessages.add(currentEnemies);
return firstEnemy && minimal ? null : fancyMessages; // we must return here and not outside the switch
case TRUCES_LIST:
FancyMessage currentTruces = P.p.txt.parseFancy(prefix);
boolean firstTruce = true;
for (Faction otherFaction : Factions.getInstance().getAllFactions()) {
if (otherFaction == target) {
continue;
}
String s = otherFaction.getTag(fme);
if (otherFaction.getRelationTo(target).isTruce()) {
currentTruces.then(firstTruce ? s : ", " + s);
currentTruces.tooltip(tipFaction(otherFaction)).color(fme.getColorTo(otherFaction));
firstTruce = false;
if (currentTruces.toJSONString().length() > ARBITRARY_LIMIT) {
fancyMessages.add(currentTruces);
currentTruces = new FancyMessage("");
}
}
}
fancyMessages.add(currentTruces);
return firstTruce && 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;