Skript icon indicating copy to clipboard operation
Skript copied to clipboard

Add infinite timespans

Open sovdeeth opened this issue 7 months ago • 0 comments

Problem

Potions have had truly infinite durations for a while now, but using them in Skript has been a bit hit or miss. EffPotionEffect has a separate flag for them, exclusive with the duration timespan option. ExprPotionEffect doesn't even allow it. A simple and elegant solution would be to allow an infinite duration as a timespan, or a similar syntax for infinite duration. The upcoming potions rework would also benefit from this concept.

Solution

This PR adds the ability for a timespan to be infinite by using Long.MAX_VALUE milliseconds to represent an eternity: [an] eternity, forever, [an] (indefinite|infinite) (duration|timespan). Math operations on eternities act like Double.POSITIVE_INFINITY, though operations that would result in NaN instead return a 0 length timespan. Since the backing value for an eternity is MAX_VALUE, it means that any syntax given an infinite timespan that doesn't have explicit infinity support can instead treat it as normal and still get the largest possible value for use.

CondIsInfinite has been updated to accept timespans. ExprPotionEffect has had an [a] added to the start of its patterns for grammatical reasons.

Breaking changes:

  • Timespan math that would have been clamped at MAX_VALUE now becomes an eternity, mimicking the behavior of numbers.

Testing Completed

LitEternity.sk

Supporting Information

The Temporal interfaces that Timespan and TimePeriod implement don't support infinite values, so it may be wise to deprecate those methods and eventually un-implement the temporals.


Completes: #7458 Related: none

sovdeeth avatar Jun 16 '25 20:06 sovdeeth