Skip to content

Commit

Permalink
- Add message to the plot forsale notification, shown when a player
Browse files Browse the repository at this point in the history
has no claimed townblocks, advising them how to claim a plot.
  • Loading branch information
LlmDl committed Nov 11, 2024
1 parent f74b75c commit 559cddb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static void loadFormatStrings() {
TownBlockType fromPlotType = null, toPlotType = null;
PlotGroup fromPlotGroup = null, toPlotGroup = null;
District fromDistrict = null, toDistrict = null;
Resident viewerResident = null;

public ChunkNotification(WorldCoord from, WorldCoord to) {

Expand Down Expand Up @@ -130,6 +131,7 @@ public String getNotificationString(Resident resident) {

if (notificationFormat.length() == 0)
return null;
viewerResident = resident;
List<String> outputContent = getNotificationContent(resident);
if (outputContent.size() == 0)
return null;
Expand Down Expand Up @@ -312,17 +314,24 @@ public String getForSaleNotification() {

// Were heading to a plot group do some things differently
if (toForSale && toPlotGroupBlock && (fromPlotGroup != toPlotGroup))
return String.format(forSaleNotificationFormat, getOwner(), getCost(toTownBlock.getPlotObjectGroup().getPrice()));
return getCostNotification(toTownBlock.getPlotObjectGroup().getPrice());

if (toForSale && !toPlotGroupBlock)
return String.format(forSaleNotificationFormat, getOwner(), getCost(toTownBlock.getPlotPrice()));
return getCostNotification(toTownBlock.getPlotPrice());

if (!toForSale && fromForSale && !toWild)
return notForSaleNotificationFormat;

return null;
}

private String getCostNotification(double price) {
String forSaleSlug = String.format(forSaleNotificationFormat, getOwner(), getCost(price));
if (viewerResident.getTownBlocks().isEmpty())
forSaleSlug += Translatable.of("chunknotification_plot_claim_help_message").forLocale(viewerResident);
return forSaleSlug;
}

private String getOwner() {
return toTownBlock.hasResident() ? toTownBlock.getResidentOrNull().getName() : toTownBlock.getTownOrNull().getName();
}
Expand Down
3 changes: 2 additions & 1 deletion Towny/src/main/resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10130,4 +10130,5 @@ v0.92.0.11:
- Fix plot perm hud trying to show too many lines.
- Move plotname and district information from /plot perm hud, to /towny map hud.
- Fix the proximity-to-nation test not removing too-far-away towns in every situation.
- Closes #7668.
- Closes #7668.
- Add message to the plot forsale notification, shown when a player has no claimed townblocks, advising them how to claim a plot.
2 changes: 2 additions & 0 deletions Towny/src/main/resources/lang/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2615,3 +2615,5 @@ msg_admin_eco_convert_success: "Economy conversion successful"
msg_err_mode_does_not_exist: "The mode %s is not recognized."

msg_err_not_allowed_to_switch: "You aren't allowed to Switch here."

chunknotification_plot_claim_help_message: " Use '/plot claim' to buy this plot."

0 comments on commit 559cddb

Please sign in to comment.