brigadier icon indicating copy to clipboard operation
brigadier copied to clipboard

Allow scientific notation of numbers and `+` sign

Open NeunEinser opened this issue 7 years ago • 11 comments

This is a simple fix to allow for scientific notation of floating point numbers. This commit would also fix the following ticket on the Minecraft Bug tracker: https://bugs.mojang.com/browse/MC-130925

NeunEinser avatar Oct 09 '18 09:10 NeunEinser

It might also be a good idea to allow the plus sign since all of Java's number parsing methods allow it, but it's also not necessary. Maybe it would be a bit cleaner to split the isAllowedNumber method into isAllowedFloatingPointNumber and isAllowedIntegerNumber, but I'll wait for developer feedback for this.

NeunEinser avatar Oct 09 '18 09:10 NeunEinser

Tests? :)

kashike avatar Oct 09 '18 19:10 kashike

:+1: for splitting isAllowedNumber and allowing the + sign in both

Earthcomputer avatar Oct 11 '18 09:10 Earthcomputer

CLA assistant check
All CLA requirements met.

msftclas avatar Oct 11 '18 17:10 msftclas

Tests? :)

Good point. Added tests for double and float with both positive and negative exponent. That should be sufficient, I hope :)

NeunEinser avatar Oct 11 '18 17:10 NeunEinser

I now added a method that is specific for integer numbers. The old method still exists and does the same thing as before (so backwards compatibility is supported). Both methods do accept the + sign now.

NeunEinser avatar Oct 11 '18 19:10 NeunEinser

Did that. Makes sense to provide this information to the user. I'm a bit unsure about the recommended max line length of this project but I found that the examples of double and float became a bit long, so I split them into two lines now.

NeunEinser avatar Oct 15 '18 11:10 NeunEinser

Thank you! Unfortunately, Mojang doesn't seem to care about user contributions anymore and this is effectively a dead repo.

NeunEinser avatar May 03 '19 18:05 NeunEinser

i think they will probably take it for 1.14's additional releases or more likely, 1.15 snapshots

liach avatar May 03 '19 19:05 liach

Well, this pr is from well before the 1.14 snapshot phase, so I am not that hopeful. In fact, the latest Mojang activity on user prs or issues was on Oct 14, 2018. The only pr that was worked on since then was an internal one, probably because boq told Dinnerbone to look at it when they were at work.

NeunEinser avatar May 04 '19 09:05 NeunEinser

Closing and reopening to rerun checks. Hopefully this works... 🤞

peterix avatar Oct 26 '22 15:10 peterix