SpongeAPI icon indicating copy to clipboard operation
SpongeAPI copied to clipboard

Add Ticks#infinite

Open aromaa opened this issue 1 year ago • 1 comments

Added Ticks#infinite and updated the documentation where we would not accept it with the current design. At the moment vanilla only supports this for PotionEffects.

Some immediate problems are that we have no way of blocking the usage of infinite ticks in events in a nice way where we accept Ticks to modify the outcome. The event execution would explode at the implementation when it eventually call Ticks#ticks which would end up throwing IllegalStateException. Should we return Integer.MAX_VALUE or Long.MAX_VALUE instead? Or should we look at how we could easily solve the problem of being able to deny these params.

aromaa avatar Dec 18 '23 22:12 aromaa

Some other alternatives that I don't quite like are that we could change the PotionEffect#duration type to Optional<Ticks> but that's quite vague. Would that imply that not specifying the duration in the builder mean that it creates a infinite one? That however could be solved with another method PotionEffect.Builder#infinite.

Adding new more concreate type like TicksOrInfinite is basically the same approach as the Optional<Ticks> one as we couldn't implement the Ticks interface or we are back at square one. Also adds more surface area for not much added clarity?

aromaa avatar Dec 18 '23 23:12 aromaa