Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new permission flag to toggle snowfall, like you would for firespread #7690

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

jwkerr
Copy link
Contributor

@jwkerr jwkerr commented Dec 2, 2024

Description:

I made this pull request as in my experience many people dread making towns in snow due to the constant covering of your builds in snow. It takes a lot of time and maintenance to keep your town clean, I've seen some go to the extreme of placing thousands of iron bars at the highest Y level to prevent snowfall. I think it is fair to add the ability to toggle this for players, if lag is a concern server admins can force snowfall on or otherwise remove access to turning it off.


New Nodes/Commands/ConfigOptions:

New config nodes:

  • new_world_settings.snow.world_snowfall_enabled
  • new_world_settings.snow.force_snow_on

New commands and their permissions:

  • /town toggle snow
    • towny.command.town.toggle.snow
  • /plot toggle snow
    • towny.command.plot.toggle.snow
  • /res toggle snow
    • towny.command.resident.toggle.snow
  • /tw toggle snow
    • towny.command.townyworld.toggle.snow
  • /tw toggle forcesnow
    • towny.command.townyworld.toggle.forcesnow

Relevant Towny Issue ticket:

N/A


  • 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.

@jwkerr
Copy link
Contributor Author

jwkerr commented Dec 2, 2024

some things i know need to be looked at:

  • i think plot perm hud might break, couldn't test it as my test server is folia but it might make it too big
  • not sure if i'm misunderstanding something but afaik i made the default behaviour for towns that snowfall is on, however in my test server it was off, the config's default value is true though and the value displayed was how it functioned in game

@LlmDl LlmDl added this to the 0.101.1.0 milestone Dec 27, 2024
Copy link
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.

Before I merge this I would like you to tell me what happens to all of the plots before this feature is added.

Does the town/resident/plot require their TownyPermission to include Snow in order to have snow fall?

Will this update mean that all of a sudden snow accumulates nowhere on the server until those towns, residents, plots have their snow enabled?

@jwkerr
Copy link
Contributor Author

jwkerr commented Dec 27, 2024

as I wrote in a previous comment, I noticed that it defaulted to false and I don't know how to change that

@jwkerr
Copy link
Contributor Author

jwkerr commented Dec 27, 2024

#7690 (comment)

@LlmDl
Copy link
Member

LlmDl commented Dec 27, 2024

the property in the townypermission should probably get renamed to nosnow, and have the logic flipped. If this PR were to cause all of the snow to not function anywhere it would be disruptive.

@LlmDl LlmDl modified the milestones: 0.101.1.0, 0.101.2.0 Jan 6, 2025
Copy link
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.

As commented earlier this will have to get overhauled to work in the opposite manner, or we'll end up breaking snow everywhere on already-existing servers.

Also moved this off of the 0.101.1.0 milestone.

@jwkerr
Copy link
Contributor Author

jwkerr commented Jan 8, 2025

@LlmDl i don't think it needs to be flipped, i just don't understand why this code:


snow = TownySettings.getPermFlag_Town_Default_Snow();

doesn't load towns existing before this change as having snowfall enabled as that is the default, towns created afterwards have it enabled so why wouldn't old ones? if we can just fix that behaviour it should be ready to merge

@LlmDl
Copy link
Member

LlmDl commented Jan 8, 2025

This is only kept when a town is newly created; when a town is loaded on startup it will use this constructor, then the permission line is changed when the town's permission line is read from the db.

@LlmDl
Copy link
Member

LlmDl commented Jan 8, 2025

doesn't load towns existing before this change as having snowfall enabled as that is the default, towns created afterwards have it enabled so why wouldn't old ones? if we can just fix that behaviour it should be ready to merge

That's why it would make more sense for the db-aspect of it to assume that snow is wanted, and only get put on the perm line when snow is not wanted.

@jwkerr
Copy link
Contributor Author

jwkerr commented Jan 8, 2025

by db side, do you mean for example changing this sql default from a 0 to a 1?

columns.add("`snowfall` bool NOT NULL DEFAULT '0'");

and if that is correct, i'm unsure what i would need to change to alter the default if flatfile is used, i've been digging around the code but its a bit hard for me to follow what exactly is used in which loading circumstances

and as for not showing it on the perm line, i can do that, and if you would like i can also or alternatively have it show in red if it is off unlike the other perm line settings that show as green if off since it might make more sense

@jwkerr
Copy link
Contributor Author

jwkerr commented Jan 8, 2025

i suppose an else statement here setting it to true if the key is null would work?

@jwkerr
Copy link
Contributor Author

jwkerr commented Jan 8, 2025

nvm it should be a change under loadTown right

@jwkerr
Copy link
Contributor Author

jwkerr commented Jan 8, 2025

okay after 0729040 i deleted all my data, reloaded on a non-snowfall version, made a town, loaded a snowfall version and it was defaulted to on, so towns should no longer unexpectedly stop snowing

Copy link
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.

I like the hiding of the snow flag when it isn't blocking snow, that should make things a bit cleaner.

I'm not so sure I like this part of the loading though:

		// To update perm lines from before the snowfall toggle was added to make sure snow doesn't unexpectedly stop falling
		snow = true; 

It feels like a band-aid or one-off fix to something that should be approached from a different direction.

I would rather the snow property that gets saved be a nosnow, which is only saved into residents/plots/towns' permission lines in the DB when a player doesn't want snow. Rather than saving snow into every resident/plot/town permission line. My thinking is that fire is fairly uncommon to want on in a plot, same with explosions. Only in the rare occurrence where a player wants fire, explosions, mobs on, does the DB get the property added to it. Not wanting snow is also the rarer state of this property and we should reflect that in how the property acts when it isn't present in the permission line.

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.

2 participants