Skip to content

Conversation

@Kyriakum
Copy link
Contributor

@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
JRoy added 3 commits November 24, 2024 21:31
…cale-pay

# Conflicts:
#	Essentials/src/main/java/com/earth2me/essentials/commands/Commandpay.java
@JRoy JRoy enabled auto-merge (squash) November 25, 2024 02:51
@JRoy JRoy changed the title Fixes commas (if per-player-locale) is enabled else uses NumberUtils default Locale for /pay Add locale based comma support for /pay Nov 25, 2024
@JRoy
Copy link
Member

JRoy commented Nov 25, 2024

Thanks for the contribution :)

@JRoy JRoy merged commit 3f0a412 into EssentialsX:2.x Nov 25, 2024
1 check passed
Euphillya added a commit to Euphillya/Essentials-Folia that referenced this pull request Dec 10, 2024
EssentialsX@1778bf5 Respect per player locale for command descriptions (EssentialsX#5972)
EssentialsX@2418a6f Improvements to Random Teleport (EssentialsX#4271)
EssentialsX@38e42f9 Add argument to /skull to give skull to other player (EssentialsX#5822)
EssentialsX@1af1565 Discord: Add start time placeholder for start message (EssentialsX#5686)
EssentialsX@bea43e8 Fix mini message parsing in NumberUtil#displayCurrency (EssentialsX#5921)
EssentialsX@3203e97 Parse /pay modifiers more strictly (EssentialsX#5638)
EssentialsX@f02eeec Add method to get all linked players in DiscordLinkService (EssentialsX#5896)
EssentialsX@9590d4c Add translation key for /alts output (EssentialsX#5595)
EssentialsX@3f0a412 Add locale based comma support for /pay (EssentialsX#5962)
EssentialsX@57c9edc Add optional requirements for balance top listing (EssentialsX#5394)
EssentialsX@c7cc1b4 Fix respawn-at-anchor setting. (EssentialsX#5825)
EssentialsX@2a41ea0 Add config options for specific chat type formats
EssentialsX@b560bbd Fix actions permissions on PRs for junit reports
EssentialsX@d31ff55 Remove extraneous code in command preprocess event handling
EssentialsX@bc8aa76 Revert removal of InvalidWorldException (EssentialsX#5984)
EssentialsX@d58db0d Update to 1.21.4
EssentialsX@c37064f Add 1.21.4 Mobs
EssentialsX@baa8258 Add 1.21.4 Tree Types
EssentialsX@424816e Add 1.21.4 Items
Starmism pushed a commit to valence-smp/Essentials that referenced this pull request Jan 8, 2025
Co-authored-by: JRoy <10731363+JRoy@users.noreply.github.com>
@mdcfe mdcfe modified the milestones: 2.22.0, 2.21.0 Feb 14, 2025
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)

3 participants