@@ -53,31 +53,35 @@ Create a new instance of the FoliaLib class:
5353// Assuming "this" is your plugin instance
5454FoliaLib foliaLib = new FoliaLib (this );
5555```
56- Then you can use the scheduler options :
56+ Here are some examples of how to use the library :
5757``` java
5858// Remember that 20 ticks = 1000 milliseconds, and 20 * 50L = 1000L
5959
60- // On a spigot server, runTimer() will run on the main thread
61- // On a folia server, runTimer() will run using the AsyncScheduler
62- foliaLib. getImpl(). runTimer(() - > {/* Code */ }, 0L , 20 * 50L , TimeUnit . MILLISECONDS );
63-
64- // You can also specify the thread that you want it to run on
65- // On a Folia server, the SYNC option will run using the GlobalRegionScheduler
60+ // On a folia server, runNextTick() will run using the GlobalRegionScheduler
6661// !! This does not make it safe to use for players or block changes !!
6762// Use other methods below for handling those
6863// This should only be used for updating the following (see GlobalRegionScheduler.java for more info)
6964// - world day time, world game time, weather cycle, sleep night skipping, executing commands for console, and other misc
70- // On a spigot server, the SYNC option will run on the main thread
71- // In both cases, the ASYNC option will run asynchronously
72- foliaLib. getImpl(). runTimer(ThreadScope . ASYNC , () - > {/* Code */ }, 0L , 20 * 50L , TimeUnit . MILLISECONDS );
65+ // On a Spigot server, runNextTick() will run on the main thread
66+ foliaLib. getImpl(). runNextTick(() - > {/* Code */ });
67+
68+ // In both cases, this method will run asynchronously
69+ foliaLib. getImpl(). runAsync(() - > {/* Code */ });
70+
71+ // On a Folia server, this method will run using the GlobalRegionScheduler
72+ // On a Spigot server, this method will run on the main thread
73+ foliaLib. getImpl(). runTimer(() - > {/* Code */ }, 0L , 20 * 50L , TimeUnit . MILLISECONDS );
74+
75+ // In both cases, this method will run asynchronously
76+ foliaLib. getImpl(). runTimerAsync(() - > {/* Code */ }, 0L , 20 * 50L , TimeUnit . MILLISECONDS );
7377
7478// On a folia server, this will run the code using the RegionScheduler that is appropriate for the location
7579// On a spigot server, this will run the code on the main thread
76- foliaLib. getImpl(). runInRegion (location, () - > {/* Code */ });
80+ foliaLib. getImpl(). runAtLocation (location, () - > {/* Code */ });
7781
78- // On a folia server, you need to run code that affects a player or the world in a region.
82+ // On a folia server, this will run the code using the RegionScheduler that is appropriate for the entity
7983// On a spigot server, this will just run the code on the main thread
80- foliaLib. getImpl(). runInPlayerRegion(player , () - > {/* Code */ });
84+ foliaLib. getImpl(). runAtEntity(entity , () - > {/* Code */ });
8185```
8286
8387## License
0 commit comments