Skip to content

Commit

Permalink
- Added the ability to give Nation Capitals an additional bonus number
Browse files Browse the repository at this point in the history
of outposts.
    - Requires that your config has
limit_outposts_using_town_and_nation_levels set to true.
    - In the nation_level sections of your config a new setting will be
added: nationCapitalBonusOutpostLimit.
    - The amount set there will be added to a nation capital (in
addition to the already applied nationBonusOutpostLimit amount.)
    - Closes #7447.
  - Automatic Config Edit: nationCapitalBonusOutpostLimit will be added
to each nation_level section with a value of 0.
  • Loading branch information
LlmDl committed Jul 19, 2024
1 parent 0dc6e7b commit 0f8f3e6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public record NationLevel(
double peacefulCostMultiplier,
double bankCapModifier,
int nationZonesSize,
int nationBonusOutpostLimit) {}
int nationBonusOutpostLimit,
int nationCapitalBonusOutpostLimit) {}

private static CommentedConfiguration config;
private static CommentedConfiguration newConfig;
Expand Down Expand Up @@ -153,7 +154,8 @@ public static void newNationLevel(
double peacefulCostMultiplier,
double bankCapModifier,
int nationZonesSize,
int nationBonusOutpostLimit) {
int nationBonusOutpostLimit,
int nationCapitalBonusOutpostLimit) {

configNationLevel.put(numResidents, new NationLevel(
namePrefix,
Expand All @@ -168,7 +170,8 @@ public static void newNationLevel(
peacefulCostMultiplier,
bankCapModifier,
nationZonesSize,
nationBonusOutpostLimit
nationBonusOutpostLimit,
nationCapitalBonusOutpostLimit
));
}

Expand Down Expand Up @@ -249,7 +252,7 @@ public static void loadNationLevelConfig() throws TownyException {

// Some configs end up having their numResident: 0 level removed which causes big errors.
// Add a 0 level nation_level here which may get replaced when the config's nation_levels are loaded below.
newNationLevel(0, "Land of ", " (Nation)", "", "", "Leader ", "", 10, 1.0, 1.0, 1.0, 1.0, 1, 0);
newNationLevel(0, "Land of ", " (Nation)", "", "", "Leader ", "", 10, 1.0, 1.0, 1.0, 1.0, 1, 0, 0);

List<Map<?, ?>> levels = config.getMapList("levels.nation_level");
for (int i = 0; i < levels.size(); i++) {
Expand All @@ -273,7 +276,8 @@ public static void loadNationLevelConfig() throws TownyException {
levelGetAndParse(level, description, numResidentsIndex, "peacefulCostMultiplier", 1.0, Double::parseDouble),
levelGetAndParse(level, description, numResidentsIndex, "bankCapModifier", 1.0, Double::parseDouble),
levelGetAndParse(level, description, numResidentsIndex, "nationZonesSize", 1, Integer::parseInt),
levelGetAndParse(level, description, numResidentsIndex, "nationBonusOutpostLimit", 1, Integer::parseInt)
levelGetAndParse(level, description, numResidentsIndex, "nationBonusOutpostLimit", 0, Integer::parseInt),
levelGetAndParse(level, description, numResidentsIndex, "nationCapitalBonusOutpostLimit", 0, Integer::parseInt)
);
} catch (Exception e) {
Towny.getPlugin().getLogger().warning("An exception occurred when a loading nation level with " + numResidentsIndex + ", this can be caused by having an outdated nation_level section.");
Expand Down Expand Up @@ -1305,6 +1309,8 @@ public static int getMaxOutposts(Town town) {
Nation nation = town.getNationOrNull();
if (nation != null)
nationOutposts = nation.getNationLevel().nationBonusOutpostLimit();
if (town.isCapital())
nationOutposts += nation.getNationLevel().nationCapitalBonusOutpostLimit();
}

return townOutposts + nationOutposts;
Expand Down
8 changes: 7 additions & 1 deletion Towny/src/main/resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9919,4 +9919,10 @@ v0.92.0.11:
- New Config Option: resident_settings.min_time_to_join_town
- Default: 0m
- How long does a resident have to wait to join a town, after joining the server.
- Set to 0m to disable. 1m = 1 minute, 1h = 1 hour, 1d = 1 day.
- Set to 0m to disable. 1m = 1 minute, 1h = 1 hour, 1d = 1 day.
- Added the ability to give Nation Capitals an additional bonus number of outposts.
- Requires that your config has limit_outposts_using_town_and_nation_levels set to true.
- In the nation_level sections of your config a new setting will be added: nationCapitalBonusOutpostLimit.
- The amount set there will be added to a nation capital (in addition to the already applied nationBonusOutpostLimit amount.)
- Closes #7447.
- Automatic Config Edit: nationCapitalBonusOutpostLimit will be added to each nation_level section with a value of 0.
10 changes: 10 additions & 0 deletions Towny/src/main/resources/config-migration.json
Original file line number Diff line number Diff line change
Expand Up @@ -865,5 +865,15 @@
"key": "update_farm_blocks"
}
]
},
{
"version": "0.100.3.9",
"changes": [
{
"type": "NATION_LEVEL_ADD",
"key": "nationCapitalBonusOutpostLimit",
"value": "0"
}
]
}
]

0 comments on commit 0f8f3e6

Please sign in to comment.