Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,13 @@ public enum ConfigNodes {
"# treated as normal nation members when plot perms are calculated.",
"# When set to false plot permission tests will treat conquered towns' residents as not members of their nations,",
"# preventing them from using their host nation's plots while the nation's towns have nation plot perms enabled."),
GNATION_SETTINGS_CAN_CONQUERED_TOWNS_BE_SANCTIONED_FROM_NATION_BONUS(
"global_nation_settings.can_conquered_towns_be_sanctioned_from_nation_bonus",
"true",
"",
"# While true, conquered towns can be sanctioned by the nation who conquered them,",
"# and, if sanctioned, will not receive nation bonus blocks from the nation who conquered and sanctioned them.",
"# When set to false, conquered towns will always receive nation bonus, and cannot be sanctioned by the conquerer nation"),
GNATION_SETTINGS_PROXIMITY_ROOT(
"global_nation_settings.proximity", "", ""),
GNATION_SETTINGS_NATION_PROXIMITY_TO_CAPITAL(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,8 @@ else if (isDeletingOldResidents() && isDeletingOldResidentsRemovingTownOnly() &&
amount += numResidents * ratio;

final Nation nation = town.getNationOrNull();
if (nation != null) {
// Do not add nation bonus blocks if nation is null or if config setting and sanctioned and conquered are all true
if (nation != null && !(TownySettings.canConqueredTownsBeSanctionedFromNationBonus() && town.getNationOrNull().hasSanctionedTown(town) && town.isConquered())) {
amount += getNationBonusBlocks(nation, nationLevelModifier);
}

Expand Down Expand Up @@ -1455,7 +1456,9 @@ public static int getNationBonusBlocks(Nation nation, int modifier) {
public static int getNationBonusBlocks(Town town) {

if (town.hasNation())
return getNationBonusBlocks(town.getNationOrNull());
// Do not add nation bonus blocks if config setting and sanctioned and conquered are all true
if (!(TownySettings.canConqueredTownsBeSanctionedFromNationBonus() && town.getNationOrNull().hasSanctionedTown(town) && town.isConquered()))
return getNationBonusBlocks(town.getNationOrNull());
return 0;
}

Expand Down Expand Up @@ -3894,6 +3897,10 @@ public static boolean areConqueredTownsGivenNationPlotPerms() {
return getBoolean(ConfigNodes.GNATION_SETTINGS_ARE_CONQUERED_TOWNS_GIVEN_NATION_PLOT_PERMS);
}

public static boolean canConqueredTownsBeSanctionedFromNationBonus() {
return getBoolean(ConfigNodes.GNATION_SETTINGS_CAN_CONQUERED_TOWNS_BE_SANCTIONED_FROM_NATION_BONUS);
}

public static String getBankHistoryBookFormat() {
return getString(ConfigNodes.BANKHISTORY_BOOK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ else if (args.length == 3)
if (args.length == 3 && (args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("remove")))
return NameUtil.filterByStart(TownyUniverse.getInstance().getTowns()
.stream()
.filter(t -> !nation.hasTown(t))
// Town is invalid tab complete if it is in the nation and not applicable to be sanctioned
.filter(t -> !(nation.hasTown(t) && !(TownySettings.canConqueredTownsBeSanctionedFromNationBonus() && t.isConquered())))
.map(Town::getName)
.collect(Collectors.toList()), args[2]);
if (args.length == 3 && args[1].equalsIgnoreCase("list"))
Expand Down Expand Up @@ -1447,7 +1448,8 @@ private static void nationSanctionTownList(CommandSender sender, Nation nation)
}

private static void nationSanctionTownAdd(CommandSender sender, Nation nation, Town town) throws TownyException {
if (nation.hasTown(town))
// You cannot sanction a town in your nation unless the config setting is true and the town is conquered by you.
if (nation.hasTown(town) && !(TownySettings.canConqueredTownsBeSanctionedFromNationBonus() && town.isConquered()))
throw new TownyException(Translatable.of("msg_err_nation_cannot_sanction_own_town"));

if (nation.hasSanctionedTown(town))
Expand All @@ -1457,7 +1459,12 @@ private static void nationSanctionTownAdd(CommandSender sender, Nation nation, T

nation.addSanctionedTown(town);
nation.save();
TownyMessaging.sendMsg(sender, Translatable.of("msg_err_nation_town_sanctioned", town.getName()));
if (nation.hasTown(town)) {
// At this point, if nation has the town, it therefore must be a conquered town, so send the conquered town variant of the sanction message
TownyMessaging.sendMsg(sender, Translatable.of("msg_err_nation_conquered_town_sanctioned", town.getName()));
} else {
TownyMessaging.sendMsg(sender, Translatable.of("msg_err_nation_town_sanctioned", town.getName()));
}
}

private static void nationSactionTownRemove(CommandSender sender, Nation nation, Town town) throws TownyException {
Expand Down
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 @@ -2492,6 +2492,8 @@ msg_err_nation_town_already_sanctioned: "Your nation already sanctions that town

msg_err_nation_town_sanctioned: "Your nation has now sanctioned %s, they will not be allowed to join your nation."

msg_err_nation_conquered_town_sanctioned: "Your nation has now sanctioned %s, they will not receive nation bonus from your nation."

msg_err_nation_town_unsanctioned: "Your nation is no longer sanctioning %s."

msg_err_nation_has_no_sanctioned_towns: "The nation has no sanctioned towns."
Expand Down
Loading