Skip to content

Commit

Permalink
- New Placeholders:
Browse files Browse the repository at this point in the history
    - %townyadvanced_resident_join_date_unformatted% - returns the long
value of the time in epoch milliseconds that a player joined the server.
    - %townyadvanced_resident_join_date_formatted% - returns a
human-readable date and time at which the player joined the server.
    - Closes #7691.
  • Loading branch information
LlmDl committed Dec 10, 2024
1 parent 35aaf92 commit 802509c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public static StatusScreen getStatus(Nation nation, CommandSender sender) {
if (nation.getNumTowns() > 0 && nation.hasCapital() && nation.getCapital().hasMayor()) {
Resident king = nation.getCapital().getMayor();
screen.addComponentOf("king", colourKeyValue(translator.of("status_nation_king"), king.getFormattedName()),
HoverEvent.showText(translator.component("registered_last_online", registeredFormat.format(king.getRegistered()), lastOnlineFormatIncludeYear.format(king.getLastOnline()))
HoverEvent.showText(translator.component("registered_last_online", getFormattedResidentRegistration(king), lastOnlineFormatIncludeYear.format(king.getLastOnline()))
.append(Component.newline())
.append(translator.component("status_hover_click_for_more"))),
ClickEvent.runCommand("/towny:resident " + king.getName())
Expand Down Expand Up @@ -640,7 +640,11 @@ public static String formatPopulationBrackets(int size) {
* @return String with registered date formatted for use in the StatusScreen.
*/
private static String getResidentRegisteredLine(Resident resident, Translator translator) {
return (!resident.isNPC() ? colourKeyValue(translator.of("status_registered"), registeredFormat.format(resident.getRegistered())) : colourKeyValue(translator.of("npc_created"), registeredFormat.format(resident.getRegistered())));
return (!resident.isNPC() ? colourKeyValue(translator.of("status_registered"), getFormattedResidentRegistration(resident)) : colourKeyValue(translator.of("npc_created"), getFormattedResidentRegistration(resident)));
}

public static String getFormattedResidentRegistration(Resident resident) {
return registeredFormat.format(resident.getRegistered());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.TownyAPI;
import com.palmergames.bukkit.towny.TownyEconomyHandler;
import com.palmergames.bukkit.towny.TownyFormatter;
import com.palmergames.bukkit.towny.TownySettings;
import com.palmergames.bukkit.towny.TownyUniverse;
import com.palmergames.bukkit.towny.object.Nation;
Expand Down Expand Up @@ -687,6 +688,11 @@ else if (resident.isMayor())
? String.format(TownySettings.getPAPIFormattingNation(), StringMgmt.remUnderscore(resident.getNationOrNull().getName()))
: String.format(TownySettings.getPAPIFormattingTown(), StringMgmt.remUnderscore(resident.getTownOrNull().getName()));

case "resident_join_date_unformatted": // %townyadvanced_resident_join_date_unformatted%
return String.valueOf(resident.getRegistered());
case "resident_join_date_formatted":// %townyadvanced_resident_join_date_formatted%
return TownyFormatter.getFormattedResidentRegistration(resident);

default:
return "";
}
Expand Down
6 changes: 5 additions & 1 deletion Towny/src/main/resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10168,4 +10168,8 @@ v0.92.0.11:
- %townyadvanced_towny_tag_override_with_minimessage_colour%
- This will use the town or nation's tag if they have a tag in use.
- Fix worlds not being saved after using /tw set usedefault.
- Remove ability for /tw set wild being able to set a world to the default settings when no arguments are supplied.
- Remove ability for /tw set wild being able to set a world to the default settings when no arguments are supplied.
- New Placeholders:
- %townyadvanced_resident_join_date_unformatted% - returns the long value of the time in epoch milliseconds that a player joined the server.
- %townyadvanced_resident_join_date_formatted% - returns a human-readable date and time at which the player joined the server.
- Closes #7691.

0 comments on commit 802509c

Please sign in to comment.