11package com .tcoded .folialib .impl ;
22
33import com .tcoded .folialib .enums .EntityTaskResult ;
4- import com .tcoded .folialib .wrapper .WrappedTask ;
4+ import com .tcoded .folialib .wrapper .task . WrappedTask ;
55import org .bukkit .Location ;
66import org .bukkit .entity .Entity ;
77import org .bukkit .entity .Player ;
@@ -35,6 +35,16 @@ public interface ServerImplementation {
3535
3636 // ----- Run Later -----
3737
38+ /**
39+ * Folia: Synced with the server daylight cycle tick
40+ * Paper: Synced with the server main thread
41+ * Spigot: Synced with the server main thread
42+ * @param runnable Task to run
43+ * @param delay Delay before execution in ticks
44+ * @return WrappedTask instance
45+ */
46+ WrappedTask runLater (Runnable runnable , long delay );
47+
3848 /**
3949 * Folia: Synced with the server daylight cycle tick
4050 * Paper: Synced with the server main thread
@@ -46,6 +56,16 @@ public interface ServerImplementation {
4656 */
4757 WrappedTask runLater (Runnable runnable , long delay , TimeUnit unit );
4858
59+ /**
60+ * Folia: Async
61+ * Paper: Async
62+ * Spigot: Async
63+ * @param runnable Task to run
64+ * @param delay Delay before execution in ticks
65+ * @return WrappedTask instance
66+ */
67+ WrappedTask runLaterAsync (Runnable runnable , long delay );
68+
4969 /**
5070 * Folia: Async
5171 * Paper: Async
@@ -59,6 +79,17 @@ public interface ServerImplementation {
5979
6080 // ----- Global Timers -----
6181
82+ /**
83+ * Folia: Synced with the server daylight cycle tick
84+ * Paper: Synced with the server main thread
85+ * Spigot: Synced with the server main thread
86+ * @param runnable Task to run
87+ * @param delay Delay before first execution in ticks
88+ * @param period Delay between executions in ticks
89+ * @return WrappedTask instance
90+ */
91+ WrappedTask runTimer (Runnable runnable , long delay , long period );
92+
6293 /**
6394 * Folia: Synced with the server daylight cycle tick
6495 * Paper: Synced with the server main thread
@@ -71,6 +102,17 @@ public interface ServerImplementation {
71102 */
72103 WrappedTask runTimer (Runnable runnable , long delay , long period , TimeUnit unit );
73104
105+ /**
106+ * Folia: Async
107+ * Paper: Async
108+ * Spigot: Async
109+ * @param runnable Task to run
110+ * @param delay Delay before first execution in ticks
111+ * @param period Delay between executions in ticks
112+ * @return WrappedTask instance
113+ */
114+ WrappedTask runTimerAsync (Runnable runnable , long delay , long period );
115+
74116 /**
75117 * Folia: Async
76118 * Paper: Async
@@ -96,6 +138,17 @@ public interface ServerImplementation {
96138 */
97139 CompletableFuture <Void > runAtLocation (Location location , Runnable runnable );
98140
141+ /**
142+ * Folia: Synced with the tick of the region of the chunk of the location
143+ * Paper: Synced with the server main thread
144+ * Spigot: Synced with the server main thread
145+ * @param location Location to run the task at
146+ * @param runnable Task to run
147+ * @param delay Delay before execution in ticks
148+ * @return WrappedTask instance
149+ */
150+ WrappedTask runAtLocationLater (Location location , Runnable runnable , long delay );
151+
99152 /**
100153 * Folia: Synced with the tick of the region of the chunk of the location
101154 * Paper: Synced with the server main thread
@@ -108,6 +161,18 @@ public interface ServerImplementation {
108161 */
109162 WrappedTask runAtLocationLater (Location location , Runnable runnable , long delay , TimeUnit unit );
110163
164+ /**
165+ * Folia: Synced with the tick of the region of the chunk of the location
166+ * Paper: Synced with the server main thread
167+ * Spigot: Synced with the server main thread
168+ * @param location Location to run the task at
169+ * @param runnable Task to run
170+ * @param delay Delay before first execution in ticks
171+ * @param period Delay between executions in ticks
172+ * @return WrappedTask instance
173+ */
174+ WrappedTask runAtLocationTimer (Location location , Runnable runnable , long delay , long period );
175+
111176 /**
112177 * Folia: Synced with the tick of the region of the chunk of the location
113178 * Paper: Synced with the server main thread
@@ -144,6 +209,17 @@ public interface ServerImplementation {
144209 */
145210 CompletableFuture <EntityTaskResult > runAtEntityWithFallback (Entity entity , Runnable runnable , Runnable fallback );
146211
212+ /**
213+ * Folia: Synced with the tick of the region of the entity (even if the entity moves)
214+ * Paper: Synced with the server main thread
215+ * Spigot: Synced with the server main thread
216+ * @param entity Entity to run the task at
217+ * @param runnable Task to run
218+ * @param delay Delay before execution in ticks
219+ * @return WrappedTask instance
220+ */
221+ WrappedTask runAtEntityLater (Entity entity , Runnable runnable , long delay );
222+
147223 /**
148224 * Folia: Synced with the tick of the region of the entity (even if the entity moves)
149225 * Paper: Synced with the server main thread
@@ -156,6 +232,18 @@ public interface ServerImplementation {
156232 */
157233 WrappedTask runAtEntityLater (Entity entity , Runnable runnable , long delay , TimeUnit unit );
158234
235+ /**
236+ * Folia: Synced with the tick of the region of the entity (even if the entity moves)
237+ * Paper: Synced with the server main thread
238+ * Spigot: Synced with the server main thread
239+ * @param entity Entity to run the task at
240+ * @param runnable Task to run
241+ * @param delay Delay before first execution in ticks
242+ * @param period Delay between executions in ticks
243+ * @return WrappedTask instance
244+ */
245+ WrappedTask runAtEntityTimer (Entity entity , Runnable runnable , long delay , long period );
246+
159247 /**
160248 * Folia: Synced with the tick of the region of the entity (even if the entity moves)
161249 * Paper: Synced with the server main thread
@@ -181,23 +269,29 @@ public interface ServerImplementation {
181269 void cancelAllTasks ();
182270
183271 /**
184- * Get a player by name (approximately)
272+ * Get a player by name (approximately).
273+ * When using folia, this can be run sync or async. If this is run async on non-folia platforms, it will block
274+ * until the next tick to get the player safely.
185275 * @param name Name of the player
186- * @return Player instance
276+ * @return Player instance or null if not found
187277 */
188278 Player getPlayer (String name );
189279
190280 /**
191281 * Get a player by name (exactly)
282+ * When using folia, this can be run sync or async. If this is run async on non-folia platforms, it will block
283+ * until the next tick to get the player safely.
192284 * @param name Name of the player
193- * @return Player instance
285+ * @return Player instance or null if not found
194286 */
195287 Player getPlayerExact (String name );
196288
197289 /**
198290 * Get a player by UUID
291+ * When using folia, this can be run sync or async. If this is run async on non-folia platforms, it will block
292+ * until the next tick to get the player safely.
199293 * @param uuid UUID of the player
200- * @return Player instance
294+ * @return Player instance or null if not found
201295 */
202296 Player getPlayer (UUID uuid );
203297
0 commit comments