Skip to content

Commit

Permalink
- Add town join date to a resident's status screen in the town hover
Browse files Browse the repository at this point in the history
section.
    - Closes #5282.
  - Bump language files to 0.126.
  • Loading branch information
LlmDl committed Oct 4, 2021
1 parent 01a236d commit 28cfa0b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6791,4 +6791,7 @@ v0.92.0.11:
- Add nation's capital to the nation status screen.
- Add protection for glow berries being harvest off cave vines.
- Treated as a destroy test.
- Prevent outlaws from being able to join towns, courtesy of Warriorrrr with PR #5329.
- Prevent outlaws from being able to join towns, courtesy of Warriorrrr with PR #5329.
- Add town join date to a resident's status screen in the town hover section.
- Closes #5282.
- Bump language files to 0.126.
4 changes: 3 additions & 1 deletion resources/lang/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1531,4 +1531,6 @@ msg_you_have_lost_your_invulnerability: 'You have lost your invulnerability.'
#Added in 0.126

#Used in the nation screen:
status_capital: 'Capital:'
status_capital: 'Capital:'
#Used in the resident screen's town hover, to denote when a player joined a town.
status_joined_town: 'Joined town:'
6 changes: 6 additions & 0 deletions src/com/palmergames/bukkit/towny/TownyFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ public static StatusScreen getStatus(Resident resident, Player player, Locale lo
residents = shortenOverlengthArray(residents, 35, translator);
screen.addComponentOf("town", townLine,
HoverEvent.showText(Component.text(Colors.translateColorCodes(String.format(TownySettings.getPAPIFormattingTown(), town.getFormattedName())))
.append(Component.newline())
.append(Component.text(getResidentJoinedTownDate(resident, translator)))
.append(Component.newline())
.append(Component.text(colourKeyValue(translator.of("rank_list_mayor"), town.getMayor().getFormattedName())))
.append(Component.newline())
Expand Down Expand Up @@ -638,6 +640,10 @@ private static String getResidentLastOnline(Resident resident, Translator transl
return (sameYear(resident) ? colourKeyValue(translator.of("status_lastonline"), lastOnlineFormat.format(resident.getLastOnline())) : colourKeyValue(translator.of("status_lastonline"), lastOnlineFormatIncludeYear.format(resident.getLastOnline())));
}

private static String getResidentJoinedTownDate(Resident resident, Translator translator) {
return colourKeyValue(translator.of("status_joined_town"), resident.getJoinedTownAt() > 0 ? lastOnlineFormatIncludeYear.format(resident.getJoinedTownAt()) : "unknown");
}

private static boolean sameYear(Resident resident) {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(resident.getLastOnline());
Expand Down

0 comments on commit 28cfa0b

Please sign in to comment.