Skip to content

Fix a bunch of nation and town level weirdness#8091

Merged
LlmDl merged 6 commits intomasterfrom
fix/town-nation-levels
Mar 16, 2026
Merged

Fix a bunch of nation and town level weirdness#8091
LlmDl merged 6 commits intomasterfrom
fix/town-nation-levels

Conversation

@Warriorrrr
Copy link
Copy Markdown
Member

Description:

  • Fixed getTownLevelMax always being 1 too high
  • Fixed TownLevelDecrease/IncreaseEvent firing for towns that have a manually set town level.
  • Fixed the code around the Town/NationLevelDecrease/IncreaseEvent bypassing the level calculate events, possibly causing them to be wrongly fired when a plugin is calculating its own levels with the level calculate events.
  • Town merge:
    • Fixed the town's resident amount being used instead of the nation's resident amount for max outpost calculations.
    • Fixed max purchased blocks not using the number of townblocks to calculate the town level when configured to do so.
    • Fixed the purchased and bonus blocks of the succumbing town not being limited by the town block limit option when the town_block_ratio is in use.
  • Fixed nation level methods wrongly using the modifier and level interchangeably (i.e. getNationLevelFromGivenInt was returning the floored modifier rather than the actual level)

  • I have tested this pull request for defects on a server.

By making this pull request, I represent that I have the right to waive copyright and related rights to my contribution, and agree that all copyright and related rights in my contributions are waived, and I acknowledge that the TownyAdvanced organization has the copyright to use and modify my contribution under the Towny License for perpetuity.

Copy link
Copy Markdown
Member

@LlmDl LlmDl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, it would be nice to see the "i tested this stuff" checkbox checked on this one.

@LlmDl
Copy link
Copy Markdown
Member

LlmDl commented Mar 12, 2026

Just a small merge conflict now.

@flyncodes
Copy link
Copy Markdown
Contributor

flyncodes commented Mar 16, 2026

Ran into an issue on 0.102.0.11 Towny, someone wanted to merge their town with /t merge <town> and got the following error
30491017736354129jLhvl5122b 1
dug into it and discovered TownySettings#getMaxOutposts > getNationLevelWithModifier(modifier) returned null with modifier 75 with the default config.yml as getNationLevelWithModifier(modifier) > getNationLevelFromGivenInt(modifier) returned 6 while getNationLevel(levelNumber) expected numResidents which is set to 60 in the config.
So hopefully this PR fixes this, I'll test and get back to you.

@flyncodes
Copy link
Copy Markdown
Contributor

This PR does fix my above error and seems to work fine otherwise. Thank you Warriorrrr.
Whenever this can be merged, would be great cheers.

@LlmDl LlmDl added this to the 0.103.0.0 milestone Mar 16, 2026
@LlmDl LlmDl merged commit cc1b462 into master Mar 16, 2026
3 checks passed
@LlmDl LlmDl deleted the fix/town-nation-levels branch March 16, 2026 13:40
LlmDl added a commit that referenced this pull request Mar 16, 2026
with PR #8091.
    - Fixed getTownLevelMax always being 1 too high
    - Fixed TownLevelDecrease/IncreaseEvent firing for towns that have a
manually set town level.
    - Fixed the code around the Town/NationLevelDecrease/IncreaseEvent
bypassing the level calculate events, possibly causing them to be
wrongly fired when a plugin is calculating its own levels with the level
calculate events.
    - Town merge:
      - Fixed the town's resident amount being used instead of the
nation's resident amount for max outpost calculations.
      - Fixed max purchased blocks not using the number of townblocks to
calculate the town level when configured to do so.
      - Fixed the purchased and bonus blocks of the succumbing town not
being limited by the town block limit option when the town_block_ratio
is in use.
    - Fixed nation level methods wrongly using the modifier and level
interchangeably (i.e. getNationLevelFromGivenInt was returning the
floored modifier rather than the actual level).
  - Fix not throwing PlayerChangePlotEvents for passengers.
  - Add NationRangeAllowTownEvent, courtesy of Veyronity with PR #8128.
    - An event thrown when a town is assessed during the nation
proximity tests, allowing plugins to modify nation proximity rules on a
per-town basis.
  - Bump org.apache.maven.plugins:maven-shade-plugin from 3.6.1 to
3.6.2.
Jsinco pushed a commit to LumaLibre/Towny that referenced this pull request Mar 31, 2026
* Fix a bunch of nation and town level weirdness

* -1 for nation level max too

* Fix poorly resolved merge conflict done via web interface.

* Update since placeholders and a javadoc.

---------

Co-authored-by: LlmDl <LlmDlio@gmail.com>
Jsinco pushed a commit to LumaLibre/Towny that referenced this pull request Mar 31, 2026
with PR TownyAdvanced#8091.
    - Fixed getTownLevelMax always being 1 too high
    - Fixed TownLevelDecrease/IncreaseEvent firing for towns that have a
manually set town level.
    - Fixed the code around the Town/NationLevelDecrease/IncreaseEvent
bypassing the level calculate events, possibly causing them to be
wrongly fired when a plugin is calculating its own levels with the level
calculate events.
    - Town merge:
      - Fixed the town's resident amount being used instead of the
nation's resident amount for max outpost calculations.
      - Fixed max purchased blocks not using the number of townblocks to
calculate the town level when configured to do so.
      - Fixed the purchased and bonus blocks of the succumbing town not
being limited by the town block limit option when the town_block_ratio
is in use.
    - Fixed nation level methods wrongly using the modifier and level
interchangeably (i.e. getNationLevelFromGivenInt was returning the
floored modifier rather than the actual level).
  - Fix not throwing PlayerChangePlotEvents for passengers.
  - Add NationRangeAllowTownEvent, courtesy of Veyronity with PR TownyAdvanced#8128.
    - An event thrown when a town is assessed during the nation
proximity tests, allowing plugins to modify nation proximity rules on a
per-town basis.
  - Bump org.apache.maven.plugins:maven-shade-plugin from 3.6.1 to
3.6.2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants