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

AbstractSetting: Add "formatter" parameter #470

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

Conversation

Baitinq
Copy link
Contributor

@Baitinq Baitinq commented Jan 20, 2023

This patch adds a new "formatter: (T) -> String" parameter to the
AbstractSetting abstract class. This allows for formatter functions to
be passed to settings for them to display their value in a more user
friendly way :)

A possible usage of this would be to replace the unit parameter, as it
simply concatenates the unit string to the setting value, which is a bit
misleading IMO.

P.S. This PR also includes an actual usage of this new parameter in the AntiDisconnect module

This patch adds a new "formatter: (T) -> String" parameter to the
AbstractSetting abstract class. This allows for formatter functions to
be passed to settings for them to display their value in a more user
friendly way :)

A possible usage of this would be to replace the unit parameter, as it
simply concatenates the unit string to the setting value, which is a bit
misleading IMO.
We now show "$x presses" by using the newly added setting formatter
@Baitinq Baitinq changed the title Formatter AbstractSetting: Add "formatter" variable Jan 20, 2023
@Baitinq Baitinq changed the title AbstractSetting: Add "formatter" variable AbstractSetting: Add "formatter" parameter Jan 20, 2023
@Avanatiker
Copy link
Member

this is very similar to the unit parameter which is only suffix. yours can be any format. so if you want you can add some default formattings like "x ticks" or "x blocks" and remove unit.

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