Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nea89o/bukkitcoroutines
https://github.com/nea89o/bukkitcoroutines
bukkit coroutines hacktoberfest kotlin
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nea89o/bukkitcoroutines
- Owner: nea89o
- Created: 2021-10-21T22:08:03.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-28T22:55:14.000Z (over 3 years ago)
- Last Synced: 2024-11-30T06:42:37.716Z (2 months ago)
- Topics: bukkit, coroutines, hacktoberfest, kotlin
- Language: Kotlin
- Homepage:
- Size: 271 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Bukkit Kotlin Coroutines
Interact with the bukkit scheduler in a very kotlin-y way:
```kotlin
@SpigotPlugin
class TestPlugin : JavaPlugin() {
@OptIn(ExperimentalTime::class)
override fun onEnable() {
logger.info("OnEnable | is primary thread: ${Bukkit.isPrimaryThread()}")
startCoroutineOnSameThread {
logger.info("Started Coroutine | is primary thread: ${Bukkit.isPrimaryThread()}")
switchToAsync()
logger.info("After switchToAsync | is primary thread: ${Bukkit.isPrimaryThread()}")
waitAndContinueInSameThread(Duration.seconds(3))
logger.info("After wait | is primary thread: ${Bukkit.isPrimaryThread()}")
switchToMain()
logger.info("After switchToMain | is primary thread: ${Bukkit.isPrimaryThread()}")
}
}
}
```would produce the following output:
```log
[23:21:38 INFO]: [bukkitcoroutines] Loading bukkitcoroutines v1.0.0
[23:21:42 INFO]: [bukkitcoroutines] Enabling bukkitcoroutines v1.0.0*
[23:21:42 INFO]: [bukkitcoroutines] OnEnable | is primary thread: true
[23:21:42 INFO]: [bukkitcoroutines] Started Coroutine | is primary thread: true
[23:21:42 INFO]: [bukkitcoroutines] After switchToAsync | is primary thread: false
[23:21:45 INFO]: [bukkitcoroutines] After wait | is primary thread: false
[23:21:45 INFO]: [bukkitcoroutines] After switchToMain | is primary thread: true
```## Documentation
Javadoc is available
on [Github Pages](https://romangraef.github.io/bukkitcoroutines/bukkitcoroutines/moe.nea89.bukkitcoroutines/index.html)## Installation
This code should be shaded into your plugin: ![[https://search.maven.org/artifact/moe.nea89/bukkitcoroutines](https://search.maven.org/artifact/moe.nea89/bukkitcoroutines)](https://img.shields.io/maven-central/v/moe.nea89/bukkitcoroutines)
```kotlin
implementation("moe.nea89:bukkitcoroutines:1.0.0")// If you want to be compatible with other plugins, make sure to relocate us:
shadowJar.relocate("moe.nea89.bukkitcoroutines", "yourpluginid.relocated.bukkitcoroutines")
```