@@ -69,6 +69,7 @@ public void cancel() throws IllegalStateException {
6969 public @ NotNull SchedulerTaskInter runDelayed (@ NotNull Plugin plugin , SchedulerType schedulerType , long delay ) throws IllegalArgumentException , IllegalStateException {
7070 checkNotYetScheduled ();
7171 if (Energie .isFolia ()) {
72+ delay = Math .max (1 , delay );
7273 if (schedulerType .equals (SchedulerType .ASYNC )) {
7374 return setupTask (new FoliaSchedulerTask (Bukkit .getAsyncScheduler ().runDelayed (plugin , task1 -> this .run (), delay * 50 , TimeUnit .MILLISECONDS ), false ));
7475 } else {
@@ -89,6 +90,7 @@ public void cancel() throws IllegalStateException {
8990 return runTask (plugin , schedulerType );
9091 }
9192 checkNotYetScheduled ();
93+ delayTicks = Math .max (1 , delayTicks );
9294 return setupTask (new FoliaSchedulerTask (Bukkit .getRegionScheduler ().runDelayed (plugin , worldChunk .world (), worldChunk .chunkX (), worldChunk .chunkZ (), task1 -> this .run (), delayTicks ), true ));
9395 }
9496
@@ -98,6 +100,7 @@ public void cancel() throws IllegalStateException {
98100 return runTask (plugin , schedulerType );
99101 }
100102 checkNotYetScheduled ();
103+ delayTicks = Math .max (1 , delayTicks );
101104 return setupTask (new FoliaSchedulerTask (Bukkit .getRegionScheduler ().runDelayed (plugin , location , task1 -> this .run (), delayTicks ), true ));
102105 }
103106
@@ -108,13 +111,16 @@ public void cancel() throws IllegalStateException {
108111 return runTask (plugin , schedulerType );
109112 }
110113 checkNotYetScheduled ();
114+ delayTicks = Math .max (1 , delayTicks );
111115 return setupTask (new FoliaSchedulerTask (entity .getScheduler ().runDelayed (plugin , task1 -> this .run (), retired , delayTicks ), true ));
112116 }
113117
114118 @ Override
115119 public @ NotNull SchedulerTaskInter runAtFixedRate (@ NotNull Plugin plugin , SchedulerType schedulerType , long delay , long period ) throws IllegalArgumentException , IllegalStateException {
116120 checkNotYetScheduled ();
117121 if (Energie .isFolia ()) {
122+ delay = Math .max (1 , delay );
123+ period = Math .max (1 , period );
118124 if (schedulerType .equals (SchedulerType .ASYNC )) {
119125 return setupTask (new FoliaSchedulerTask (Bukkit .getAsyncScheduler ().runAtFixedRate (plugin , task1 -> this .run (), delay * 50 , period * 50 , TimeUnit .MILLISECONDS ), false ));
120126 } else {
@@ -130,30 +136,36 @@ public void cancel() throws IllegalStateException {
130136 }
131137
132138 @ Override
133- public @ NotNull SchedulerTaskInter runAtFixedRate (@ NotNull Plugin plugin , @ NotNull SchedulerType schedulerType , MultipleRecords .WorldChunk worldChunk , long initialDelayTicks , long periodTicks ) {
139+ public @ NotNull SchedulerTaskInter runAtFixedRate (@ NotNull Plugin plugin , @ NotNull SchedulerType schedulerType , MultipleRecords .WorldChunk worldChunk , long delay , long period ) {
134140 if (!Energie .isFolia () || schedulerType .equals (SchedulerType .ASYNC )) {
135141 return runTask (plugin , schedulerType );
136142 }
137143 checkNotYetScheduled ();
138- return setupTask (new FoliaSchedulerTask (Bukkit .getRegionScheduler ().runAtFixedRate (plugin , worldChunk .world (), worldChunk .chunkX (), worldChunk .chunkZ (), task1 -> this .run (), initialDelayTicks , periodTicks ), true ));
144+ delay = Math .max (1 , delay );
145+ period = Math .max (1 , period );
146+ return setupTask (new FoliaSchedulerTask (Bukkit .getRegionScheduler ().runAtFixedRate (plugin , worldChunk .world (), worldChunk .chunkX (), worldChunk .chunkZ (), task1 -> this .run (), delay , period ), true ));
139147 }
140148
141149 @ Override
142- public @ NotNull SchedulerTaskInter runAtFixedRate (@ NotNull Plugin plugin , @ NotNull SchedulerType schedulerType , Location location , long initialDelayTicks , long periodTicks ) {
150+ public @ NotNull SchedulerTaskInter runAtFixedRate (@ NotNull Plugin plugin , @ NotNull SchedulerType schedulerType , Location location , long delay , long period ) {
143151 if (!Energie .isFolia () || schedulerType .equals (SchedulerType .ASYNC )) {
144152 return runTask (plugin , schedulerType );
145153 }
146154 checkNotYetScheduled ();
147- return setupTask (new FoliaSchedulerTask (Bukkit .getRegionScheduler ().runAtFixedRate (plugin , location , task1 -> this .run (), initialDelayTicks , periodTicks ), true ));
155+ delay = Math .max (1 , delay );
156+ period = Math .max (1 , period );
157+ return setupTask (new FoliaSchedulerTask (Bukkit .getRegionScheduler ().runAtFixedRate (plugin , location , task1 -> this .run (), delay , period ), true ));
148158 }
149159
150160 @ Override
151- public @ NotNull SchedulerTaskInter runAtFixedRate (@ NotNull Plugin plugin , @ NotNull SchedulerType schedulerType , Entity entity , @ Nullable Runnable retired , long initialDelayTicks , long periodTicks ) {
161+ public @ NotNull SchedulerTaskInter runAtFixedRate (@ NotNull Plugin plugin , @ NotNull SchedulerType schedulerType , Entity entity , @ Nullable Runnable retired , long delay , long period ) {
152162 checkNotYetScheduled ();
153163 if (!Energie .isFolia () || schedulerType .equals (SchedulerType .ASYNC )) {
154164 return runTask (plugin , schedulerType );
155165 }
156166 checkNotYetScheduled ();
157- return setupTask (new FoliaSchedulerTask (entity .getScheduler ().runAtFixedRate (plugin , task1 -> this .run (), retired , initialDelayTicks , periodTicks ), true ));
167+ delay = Math .max (1 , delay );
168+ period = Math .max (1 , period );
169+ return setupTask (new FoliaSchedulerTask (entity .getScheduler ().runAtFixedRate (plugin , task1 -> this .run (), retired , delay , period ), true ));
158170 }
159171}
0 commit comments