Folia Scheduler : Do not throw an error if the delay is set to 0, just like for entities.#11339
Folia Scheduler : Do not throw an error if the delay is set to 0, just like for entities.#11339Euphillya wants to merge 1 commit into
Conversation
|
If setting the delay to 0 leads to an exception somewhere (idk if this happens for sure, just assuming), then either that exception should be fixed, or if that isn't feasible, 0 just shouldn't be allowed as an argument value. |
|
The exception is from inside the method itself, clearly stating that the delay/period must be greater than 0, which makes sense to me. The only way that 0 as an input is feasible is to Math.max it like done here |
It is not allowed precisely. But on the entity scheduler, we can set it to 0 but it is corrected by a Math.max so that the lowest value is 1 (see here: ) |
|
After further consideration, we thinking throwing is the more correct behavior. It's odd to clamp values to 1 instead of specifying what values are valid in the first place and disallowing other values. A PR adding a thrown exception for the EntityScheduler#execute method which I think is the only method that doesn't throw out of all the scheduler methods. |
On the entity scheduler, we see that a check using the Math.max method exists, but not on the others. If you set it to 0, you just get an error, so I modified it to default to the next tick instead.