Skip to content

Commit

Permalink
Translate most of the info window that isn't translated. (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
LlmDl authored May 2, 2024
1 parent 29bf6b1 commit 872b83e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.dynmap</groupId>
<artifactId>Dynmap-Towny</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>

<build>
<defaultGoal>clean package</defaultGoal>
Expand Down
37 changes: 18 additions & 19 deletions src/main/java/org/dynmap/towny/mapupdate/TownInfoWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.palmergames.bukkit.towny.TownySettings;
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.object.Translation;
import com.palmergames.bukkit.towny.utils.TownRuinUtil;
import com.palmergames.util.StringMgmt;

Expand All @@ -27,7 +28,7 @@ public static String formatInfoWindow(Town town) {
String[] entire = residents;
residents = new String[35 + 1];
System.arraycopy(entire, 0, residents, 0, 35);
residents[35] = "and more...";
residents[35] = Translation.of("status_town_reslist_overlength");
}

String res = String.join(", ", residents);
Expand All @@ -49,7 +50,7 @@ public static String formatInfoWindow(Town town) {
v = v.replace("%residentcount%", town.getResidents().size() + "");
v = v.replace("%founded%", town.getRegistered() != 0 ? TownyFormatter.registeredFormat.format(town.getRegistered()) : "Not set");
v = v.replace("%board%", town.getBoard());
v = v.replace("%towntrusted%", town.getTrustedResidents().isEmpty() ? "None"
v = v.replace("%towntrusted%", town.getTrustedResidents().isEmpty() ? Translation.of("status_no_town") //Translation is "None"
: StringMgmt.join(town.getTrustedResidents().stream().map(trustedRes-> trustedRes.getName()).collect(Collectors.toList()), ", "));

if (TownySettings.isUsingEconomy() && TownyEconomyHandler.isActive()) {
Expand All @@ -75,26 +76,20 @@ public static String formatInfoWindow(Town town) {

v = v.replace("%nationstatus%", natStatus);

v = v.replace("%public%", town.isPublic() ? "true" : "false");
v = v.replace("%peaceful%", town.isNeutral() ? "true" : "false");
v = v.replace("%public%", getEnabledDisabled(town.isPublic()));
v = v.replace("%peaceful%", getEnabledDisabled(town.isNeutral()));


/* Build flags */
List<String> flags = new ArrayList<>();
flags.add("Has Upkeep: " + town.hasUpkeep());
flags.add("pvp: " + town.isPVP());
flags.add("mobs: " + town.hasMobs());
flags.add("explosion: " + town.isExplosion());
flags.add("fire: " + town.isFire());
flags.add("nation: " + nation);

if (TownySettings.getTownRuinsEnabled()) {
String ruinedString = "ruined: " + town.isRuined();
if (town.isRuined())
ruinedString += " (Time left: " + (TownySettings.getTownRuinsMaxDurationHours() - TownRuinUtil.getTimeSinceRuining(town)) + " hours)";

flags.add(ruinedString);
}
flags.add(Translation.of("msg_perm_hud_pvp") + getEnabledDisabled(town.isPVP()));
flags.add(Translation.of("msg_perm_hud_mobspawns") + getEnabledDisabled(town.hasMobs()));
flags.add(Translation.of("msg_perm_hud_explosions") + getEnabledDisabled(town.isExplosion()));
flags.add(Translation.of("msg_perm_hud_firespread") + getEnabledDisabled(town.isFire()));

if (TownySettings.getTownRuinsEnabled() && town.isRuined())
flags.add(Translation.of("msg_comptype_ruined") + " " + Translation.of("msg_time_remaining_before_full_removal",
TownySettings.getTownRuinsMaxDurationHours() - TownRuinUtil.getTimeSinceRuining(town)));

BuildTownFlagsEvent buildTownFlagsEvent = new BuildTownFlagsEvent(town, flags);
Bukkit.getPluginManager().callEvent(buildTownFlagsEvent);
Expand All @@ -103,4 +98,8 @@ public static String formatInfoWindow(Town town) {

return v;
}
}

private static String getEnabledDisabled(boolean b) {
return b ? Translation.of("enabled") : Translation.of("disabled");
}
}

0 comments on commit 872b83e

Please sign in to comment.