Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Add Tick TemporalUnit

Open kezz opened this issue 4 years ago • 7 comments

This PR adds a new class Tick that implements TemporalUnit to allow easy handling of ticks as a unit of time. Additionally, some unit tests have been provided just for fun.

For example, to create a new duration from a certain number of ticks you can simply do one of the following:

Duration.of(50, Tick.tick());
Tick.of(50);

The inverse is also possible, calculating the whole number of ticks in a given duration:

Tick.fromDuration(Duration.of(100, ChronoUnit.SECONDS));

This PR is a more restrictive version of the equivalent PR in Minestom.

kezz avatar Apr 02 '21 16:04 kezz

isDurationEstimated should return true, the nature of tying this hard to a time seems a bit flawed to me

electronicboy avatar Apr 02 '21 16:04 electronicboy

isDurationEstimated should return true, the nature of tying this hard to a time seems a bit flawed to me

Good point! I've edited the return type and added a note in the javadoc.

EDIT: It's worth noting that markin the duration as estimated prevents the main use of this class existing. Might just be worth closing this and leaving it to maths tbh.

kezz avatar Apr 02 '21 16:04 kezz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 19 '21 12:08 stale[bot]

No!

Owen1212055 avatar Aug 19 '21 13:08 Owen1212055

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 18 '21 16:10 stale[bot]

The only place for concern has to do with the "isDurationEstimated", as it was mentioned

It's worth noting that markin the duration as estimated prevents the main use of this class existing.

Cause, for example, image

Owen1212055 avatar Oct 22 '22 15:10 Owen1212055

Yea, I mean, I really feel iffy on this. Like, the expectation of time is that, it, well, progresses at a steady rate, and, ticks trrrrrrry to but technically kinda don't. I guess the limitation of it not allowing maths from that unit elsewhere is kinda dumb and probably justifies not marking it as as an "estimation", I would probably maybe make a note of that

electronicboy avatar Oct 24 '22 03:10 electronicboy