TownyAdvanced / Towny

Towny Advanced Minecraft plugin for Bukkit/Spigot.
https://townyadvanced.github.io
Other
526 stars 352 forks source link

Suggestion: Custom math formula for Daily Town and Nation upkeep #3781

Closed emanondev closed 4 years ago

emanondev commented 4 years ago

Please explain your feature request to the best of your abilities: Add on config the ability to select and use custom formula based on variables to set daily upkeep of towns and nations town variables: {residents}, {plots}, {allied_towns} which are respectively the number of residents of the town, number of plots claimed by the town, number of town in the nation less one or zero if town has no nation nation variables: {residents}, {plots}, {towns}, {allied_nations} which are respectively the sum of number of the residents of each town of the nation, the sum of number of plots claimed of each town of the nation, the number of towns in the nation, the number of allied nations

this code might help to evaluate formulas https://pastebin.com/sLXRRnc4 when eval() is called try catch must surround it for Arithmetic and Runtime Exceptions, if an exception is thrown it should be logged and visible on console, also upkeep should be 0 for that town/nation

if eval() return a negative value upkeep should 0, a maybe that should be logged like a eval() exception

LlmDl commented 4 years ago

Taxes or upkeep?

emanondev commented 4 years ago

upkeep

LlmDl commented 4 years ago

For both {resident}: The way the town and nation levels work you are able to modify the upkeep based on resident level.

Setting the town and nation upkeep to $1 each. Then using the upkeepModifiers in the town/nation levels you can cause the upkeep to be any value you want. ie: town pays $500 when the upkeepModifier is 500.0.


For town {plot}: There is the per-plot-upkeep which can also be affected by the town/nation levels.


For {alliedTowns}: I don't really understand how charging a town more money for their upkeep because there's more towns in a nation. That feels like an upkeep that would be charged to the nation who then burdens the towns with a higher tax.


For nation {plot}: This one is covered in this ticket: https://github.com/TownyAdvanced/Towny/issues/3181


For {towns}: This is covered in the config already here:

    # Uses total number of towns in the nation to determine upkeep instead of nation level (Number of Residents)
    # calculated by (number of towns in nation X price_nation_upkeep).
    nation_pertown_upkeep: 'false'
    # If set to true, the per-town-upkeep system will be modified by the Nation Levels' upkeep modifiers.
    nation_pertown_upkeep_affected_by_nation_level_modifier: 'false'

For {allied_nations}: This one is a new suggestion. I could see it being useful to stop large blocks of nations from dominating a server.


All of this being said, if you desire a truly complex tax system like this you could always use the Towny API to get all of the numbers you require.

emanondev commented 4 years ago

per-plot-upkeep is a linear function, which is quite limiting, i wish for players to be able to build more than just essentials and keep expanding and building, yet i can't blame them if they can't both expand and pay upkeep, i need something that grows softer than linear when the town is already big

i think using a formula is the most expressive way for server owners to set upkeeps, but i also understand that most of them are fine with linear or costant values

LlmDl commented 4 years ago

per-plot-upkeep for towns is not linear, you can use the upkeepmodifier in the town level to affect it:

    # Uses total amount of owned plots to determine upkeep instead of the town level (Number of residents)
    # calculated by (number of claimed plots X price_town_upkeep).
    town_plotbased_upkeep: 'false'
    # If set to true, the plot-based-upkeep system will be modified by the Town Levels' upkeep modifiers.
    town_plotbased_upkeep_affected_by_town_level_modifier: 'false'
emanondev commented 4 years ago

town_level isn't based on number of residents?

may i set something like price of 40 if you have 1 town claim, 70 if you have 2 town claims, 90 if you have 3... regardless of town resident amount?

LlmDl commented 4 years ago

Town_level is based on resident count.

You cannot set a varying per-plot-upkeep-price that is not using the town_level upkeepModifier, so the per-plot costs are tied to resident count.

What you are wanting can be done using the Towny API and a third-party plugin that hooks into the preNewDayEvent that was just added in Towny 0.95.2.23. Using that preNewDayEvent you could charge towns/nations whatever you'd like using your formula.

emanondev commented 4 years ago

wonderful, is there also a way to fix the shown upkeep price on /t [town] and /n [nation] ?

LlmDl commented 4 years ago

fix it how?

emanondev commented 4 years ago

town upkeep showed on /town [town] wouldn't be affected by external plugins unless i override /town command, This pull request: https://github.com/TownyAdvanced/Towny/pull/3792 adds required events for me to edit the upkeep for both /t [town] display and upkeep collecting

same for nations