Add ms suffix support to DurationTag - #125
Open
BehrRiley wants to merge 2 commits into
Open
Conversation
MC-Samuel
reviewed
Aug 25, 2026
| return new DurationTag(numVal * 0.05); | ||
| } | ||
| else if (string.endsWith("ms")) { | ||
| return new DurationTag(numVal / 1000.0); |
Contributor
There was a problem hiding this comment.
Should stick with the conversion pattern that already exists ("* 0.001" rather than "/ 1000.0").
| else if (string.endsWith("t")) { | ||
| return new DurationTag(numVal * 0.05); | ||
| } | ||
| else if (string.endsWith("ms")) { |
Member
There was a problem hiding this comment.
This code is wrong; this branch cannot ever be hit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
this pull request adds millisecond suffix support to the
DurationTag, allowing scripters to define rapid durations nicely (eg:<duration[3ms]>). this removes the need to divide define millisecondsProblem
when defining durations, we previously lacked a native millisecond suffix; and when checking for suffixes, there was a structural issue where
msstrings were being trimmed by only one character which would fail to parse right. if placed wrongly,"3ms".endsWith("s")would trigger as seconds instead. this fixes the length-check to strip two characters forms, scales the numeric value by0.001to maintain consistency with our existing multiplier standard, and uses themsbranch before seconds to avoid problemsTesting
500ms,250.5ms)DurationTag.in_secondsused various examples:
/ex -q narrate "1ms = <duration[1ms].in_milliseconds>ms"/ex -q narrate "500ms = <duration[500ms].in_milliseconds>ms"/ex -q narrate "1000ms = <duration[1000ms].in_milliseconds>ms"/ex -q narrate "500ms = <duration[500ms].in_seconds>s"/ex -q narrate "250.5ms = <duration[250.5ms].in_milliseconds>ms"here's a startup log referencing this test with tags parsed for verification:
https://paste.denizenscript.com/View/141404
a working build of my latest successful build which has no errors can be built with this branch or found at:
https://files.behr.dev/file-share/Denizen-1.3.3-bUnknown-CUSTOM-ms-durationtag.jar