Skip to content

Add NationRangeAllowTownEvent#8128

Merged
LlmDl merged 4 commits intoTownyAdvanced:masterfrom
Veyronity:event/NationRangeAllowTownEvent
Mar 16, 2026
Merged

Add NationRangeAllowTownEvent#8128
LlmDl merged 4 commits intoTownyAdvanced:masterfrom
Veyronity:event/NationRangeAllowTownEvent

Conversation

@Veyronity
Copy link
Copy Markdown
Contributor

@Veyronity Veyronity commented Mar 1, 2026

Description:

Added NationRangeAllowTownEvent, allowing other plugins to override/ignore Towny's proximity rules
For my specific case, I'd like to allow towns from the other side of the world border to join nations


  • [ x ] 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.

@Veyronity
Copy link
Copy Markdown
Contributor Author

In regards to my 2nd commit, if you think firing an event for each town when just gathering a list of in range towns is unnecessary, it can be moved to ProximityUtil#removeOutOfRangeTowns as that's the only usage that kicks them.

Other usages are just a warning to players when moving nation/town, or when merging a nation.

Copy link
Copy Markdown
Member

@Warriorrrr Warriorrrr left a comment

Choose a reason for hiding this comment

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

Generally looks fine to me, the the event could use some javadocs explaining what it does, how it can be fired pre-cancelled if the town isn't allowed according to nation range rules

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.

This looks alright but it looks like a town that is within range of the nation never gets an event thrown which would stop a plugin from making things more strict than Towny would act.

It might be worth making it throw an event for every town that is tested.

@Veyronity
Copy link
Copy Markdown
Contributor Author

Done
I honestly think all these methods serving basically the same purpose is a mess, maybe Ill refactor that next

@LlmDl LlmDl modified the milestone: 0.103.0.0 Mar 16, 2026
@LlmDl LlmDl merged commit d3c9e81 into TownyAdvanced:master Mar 16, 2026
1 check passed
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
* Add NationRangeAllowTownEvent

Allowing other plugins to override Towny's proximity rules

* Fire NationRangeAllowTownEvent when gathering in-range towns

* Add javadoc

* Fire event even for in range towns
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