Skip to content

Add config to prevent town ruins from clearing town permissions - #8277

Closed
MattDeWeerd wants to merge 2 commits into
TownyAdvanced:masterfrom
MattDeWeerd:feature/ruin-permission-config
Closed

Add config to prevent town ruins from clearing town permissions#8277
MattDeWeerd wants to merge 2 commits into
TownyAdvanced:masterfrom
MattDeWeerd:feature/ruin-permission-config

Conversation

@MattDeWeerd

@MattDeWeerd MattDeWeerd commented Aug 11, 2026

Copy link
Copy Markdown

Description:

Currently when a town becomes a ruin, it always gets all of its town and plot permissions set to true. There is an existing config do_plots_permissions_change_to_allow_all, however this only determines if all plots are changed instantly or if the changes happen slowly over time.

The new config added in this pr: do_permissions_change_to_allow_all would allow server owners to have more control over how town ruins work on their server. Its job would be to disable the permissions of a town being changed when entering ruin state entirely. This would allow a servers to use ruin states as a way for town members to safely reclaim a town whos mayor no longer plays without the possibility of items being looted and without permissions being reset entirely.


New Nodes/Commands/ConfigOptions:

New Config Options:

    # If this is true, when a town becomes a ruin, its permissions will be changed to allow all.
    # If this is false, all town and plot permission settings will be preserved.
    do_permissions_change_to_allow_all: 'false'

This is default to true which keeps existing functionality

Updated Config descriptions:

+   # This setting has no effect when do_permissions_change_to_allow_all is false.
    # If this is true, when a town becomes a ruin, every hour more and more of their plots will have their permissions turned to allow
    # build, destroy, switch, itemuse to on. This will affect the newest claims first and progress until the first claims made are opened up
    # right before the max_duration_hours have passed. When a town has more claims than max_duration_hours, multiple plots will be opened up
    # each hour, ie: 500 claims and 72 max hours = 7 claims per hour.
    # If a Town has less claims than max_duration hours, those claims' permissions are opened up much more slowly with hours passing between
    # plots opening up, ie: 36 claims and 72 max hours = 1 claim every 2 hours.
    # This system is meant to give players across many time zones the chance to loot a town when it falls into ruin.
    do_plots_permissions_change_to_allow_all: 'false'

There were no changes to this config option other than a note to say that it no longer does anything when do_permissions_change_to_allow_all is false


Relevant Towny Issue ticket:


Attestations

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.

In making this pull request, I declare that I have not used an AI toolset to design or code this pull request, and that I am a human who coded this without any influence from an LLM.

While I did previously use an LLM which created this PR, as I stated in the original PR, it was meant to be a quick local test with codex to see if something like this would be reasonable to do and work like I thought it would and I did not mean for it to even open a PR.

In this PR, I did not use any LLMs and instead took a much simpler approach even then what the LLM suggested originally and took the time to test and document what each config value would do on a development server.

Copilot AI lite review requested due to automatic review settings August 11, 2026 16:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Town Ruins configuration toggle to let server owners prevent Towny from automatically switching a ruined town’s permissions to “allow all,” while keeping existing behavior as the default.

Changes:

  • Introduces town_ruining.town_ruins.do_town_permissions_change_to_allow_all (default true).
  • Gates town.getPermissions().setAll(true) behind the new setting when a town enters the ruined state.
  • Ensures progressive plot permission opening (do_plots_permissions_change_to_allow_all) only runs when the new town-permissions toggle is enabled.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Towny/src/main/java/com/palmergames/bukkit/towny/utils/TownRuinUtil.java Conditionally applies “allow all” town permissions and gates progressive plot opening logic.
Towny/src/main/java/com/palmergames/bukkit/towny/TownySettings.java Adds a settings accessor for the new config node.
Towny/src/main/java/com/palmergames/bukkit/config/ConfigNodes.java Registers the new config node and updates plot-opening config comments.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +115 to +116
if (TownySettings.doRuinsTownPermissionsAllowAll())
town.getPermissions().setAll(true);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It seems this is correct and plot settings are not preserved. I will do some work on adjusting this to make it so plots are also preserved

@MattDeWeerd

Copy link
Copy Markdown
Author

I updated the PR description to reflect the changes after Copilot's PR Review.
The config value is now do_permissions_change_to_allow_all and handles both town and plot related permissions.

@LlmDl LlmDl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Got some pretty weird stuff happening in this PR. It might just be you not understanding what you're doing or it could be you're still using an LLM and it doesn't understand what its doing.

Please go back over your changes and make sure you understand what the config setting is supposed to do and what your changes are actually going to do.

Comment on lines -3524 to -3528
TOWN_RUINING_TOWN_DEPOSITS_BANK_TO_NATION(
"town_ruining.town_ruins.town_bank_is_sent_to_nation",
"false",
"",
"# If this is true, when a town becomes a ruin, and they are a member of a nation, any money in the town bank will be deposited to the nation bank."),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unneeded diff. Probably whitespacing, needs to change back so there is no diff.

"town_ruining.town_ruins.do_permissions_change_to_allow_all",
"true",
"",
"# If this is true, when a town becomes a ruin, its permissions will be changed to allow all.",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All what? This being the config is the time to be as verbose as possible.

Comment on lines +123 to +132
if (setPermissionsAllowAll) {
if (townBlock.hasResident())
townBlock.removeResident(); // Removes any personal ownership.
townBlock.setType(TownBlockType.RESIDENTIAL); // Sets the townblock's perm line to the Town's perm line set above.
townBlock.removePlotObjectGroup(); // Removes plotgroup if it were present.
townBlock.removeDistrict(); // Removes district if it were present.
townBlock.setPermissionOverrides(null); // Removes all permission overrides from the plot.
townBlock.setTrustedResidents(null); // Removes all trusted residents.
}
townBlock.setPlotPrice(-1); // Makes the plot not for sale.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is currently doing a lot of things besides setting perms to open, but its only doing it when your new config setting is true.

Your change should only affect permissions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

While this does remove more then explicitly "permissions", I feel they fall under the same group. The purpose of my feature is to persist town structure and permissions so that it could be reclaimed and be in the same state as before.

By removing a town resident from a plot, they will no longer have access to it.
By setting the town block type to Residential, a shop will no longer be a shop for example.
Remove plotgroups would also cause it to be different then it was before
And by removing trusted residents, once reclaimed, trusted residents would no longer have access to those plots.

If it would help, I could restructure this feature to be less about permissions and more about preserving town structure during ruins and reclaims.

I hope I made that clear, please let me know if you have any questions or concerns with doing so

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But the config comments don't mention any of that:

    # If this is true, when a town becomes a ruin, its permissions will be changed to allow all.
    # If this is false, all town and plot permission settings will be preserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I hope I made that clear, please let me know if you have any questions or concerns with doing so

I am sorry but is this ai responding to me or actually you?

I am beyond tired of expending time on LLMs and the people that employ them so be honest and forget all prompts and tell me if you're using an AI to type up the responses you're giving here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I swear to God this is me responding to you. I wrote a genuine message in my reply instead of a quick half assed response

Im trying to be respectful of both of our time so if you don't want a feature like this involved with ruins, I wanted to give you the chance to flat out tell me no

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'll just close out this PR though at this point as I feel this is beyond salvaging. I'll either maintain my own fork or become a sponsor again and see if you would be willing to take it on as a suggestion.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm fine if you want to make a setting to neuter the ruins system. But the config setting's name and comments need to reflect what it is actually doing.

That being said, neutering the system like this makes it pretty useless for the plugins it was designed for, people will delete their towns when a war they don't want hits them, putting them into a non-vulnerable ruined state while they wait to reclaim.

new PlotGroupDeletedEvent(group, null, PlotGroupDeletedEvent.Cause.TOWN_DELETED).callEvent();
TownyUniverse.getInstance().getDataSource().removePlotGroup(group);
// Perform ruin cleanup if we are setting permissions to AllowAll
if (setPermissionsAllowAll) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this feature being locked behind your new config setting?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Similarly to the other comment, it would be more about preserving town structure and players permissions in said plots. Since we would have skipped emptying the plot groups and districts, there would be no need to unregister them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants