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

Fixes commas (if per-player-locale) is enabled else uses NumberUtils default Locale for /pay #5962

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

Conversation

Kyriakum
Copy link

@Kyriakum Kyriakum commented Oct 31, 2024

  • Added locale functionality to /pay command
  • Added tests for String to BigDecimal parsing & locale specific parsing

Information

This PR fixes #2355 .

Details

Proposed fix:

NumberUtils.java includes PRETTY_LOCALE which uses as default for PRETTY_FORMAT
NumberUtils.java includes 2 new methods for parsing Strings to BigDecimals in default locale OR specified locale.
Commandpay.java uses those two new methods to parse the String to BigDecimal according to whether per-player-locale is enabled or not
/pay String to BigDecimal parsing moved from Commandpay.java to NumberUtils.java
Instead of parsing manually with regex, use NumberFormat instead to make sure parsing is done as intended
Regex filtering & empty string checking is still left in Commandpay.java to handle wrong inputs from the user

Environments tested:

OS: Windows 11

Java version: java version "21.0.4" 2024-07-16 LTS

  • Most recent Paper version (1.XX.Y, git-Paper-BUILD)
  • CraftBukkit/Spigot/Paper 1.12.2
  • CraftBukkit 1.8.8
  • Paper 1.19.4

Demonstration:

@mdcfe mdcfe added the type: enhancement Features and feature requests. label Nov 7, 2024
@mdcfe mdcfe added this to the 2.22.0 milestone Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Features and feature requests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

/pay uses wrong currency format (decimals)
2 participants