Skip to content

Add FloatArg and FloatRangeArg - #180

Merged
mfnalex merged 2 commits into
SpigotBasics:mainfrom
JanTuck:add-float-range-arg
Oct 14, 2026
Merged

mfnalex merged 2 commits into
SpigotBasics:mainfrom
JanTuck:add-float-range-arg

Conversation

@JanTuck

@JanTuck JanTuck commented Oct 14, 2026 •

Copy link
Copy Markdown

Adds decimal counterparts to IntArg / IntRangeArg so modules don't need their own float parsing (first user: /speed in #160).

Class Behaviour
FloatArg Parses any finite float (NaN / Infinity are rejected); non-numbers get the default invalid-value message
FloatRangeArg(name, min, max) Like IntRangeArg: lambdas for the bounds, tab-completes them, and reports not in range for numbers outside them

Supporting changes:

  • CoreMessages: a Float overload of invalidValueForArgumentNumberNotInRange, reusing the existing message key.
  • FormatUtils: Float.toShortString(), so whole numbers show as 10 instead of 10.0 in that message and in completions.

Testing

  • ./gradlew :core:build (compile + ktlint + tests) passes on Java 17.

JanTuck added 2 commits October 14, 2026 16:57
Decimal counterparts to IntArg and IntRangeArg, with a must-be-a-number message and
a float overload of the not-in-range message.
CommandArgument's default message already covers it, so the extra message key isn't
needed.
@mfnalex
mfnalex merged commit f93abe9 into SpigotBasics:main Oct 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants