Skip to content

Commit

Permalink
Add sanctioned towns hover component to nation status screen (#7207)
Browse files Browse the repository at this point in the history
* Add sanctioned towns hover component to nation status screen

* Use nation name in click event

* Update comment
  • Loading branch information
jwkerr authored Jan 27, 2024
1 parent c972650 commit ccb98a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,18 @@ public static StatusScreen getStatus(Nation nation, CommandSender sender) {
.append(Component.newline())
.append(translator.component("status_hover_click_for_more"))),
ClickEvent.runCommand("/towny:nation enemylist " + nation.getName()));

// [Sanctioned Towns] with hover showing Sanctioned Towns [3]: Prague, Berlin, Vienna
List<String> sanctionedTowns = getFormattedNames(nation.getSanctionedTowns());
if (sanctionedTowns.size() > 10)
shortenOverLengthList(sanctionedTowns, 11, translator);

if (sanctionedTowns.size() > 0)
screen.addComponentOf("sanctionedtowns", colourHoverKey(translator.of("status_nation_sanctioned_towns")),
HoverEvent.showText(TownyComponents.miniMessage(getFormattedStrings(translator.of("status_nation_sanctioned_towns"), sanctionedTowns, nation.getSanctionedTowns().size()))
.append(Component.newline())
.append(translator.component("status_hover_click_for_more"))),
ClickEvent.runCommand("/towny:nation sanctiontown list " + nation.getName()));

// Add any metadata which opt to be visible.
List<Component> fields = getExtraFields(nation);
Expand Down
4 changes: 3 additions & 1 deletion Towny/src/main/resources/lang/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2426,4 +2426,6 @@ msg_err_unable_to_use_bank_outside_bank_plot_no_homeblock: 'You cannot use that

msg_err_you_cannot_outlaw_your_mayor: "You cannot outlaw your town's mayor."

msg_err_you_cannot_outlaw_because_of_rank: "You cannot outlaw %s because of a town rank they hold."
msg_err_you_cannot_outlaw_because_of_rank: "You cannot outlaw %s because of a town rank they hold."

status_nation_sanctioned_towns: "Sanctioned Towns"

0 comments on commit ccb98a6

Please sign in to comment.