From 7eb85447e0660a62b707da03c7e6a78161213288 Mon Sep 17 00:00:00 2001 From: "Ryan H. Code" <42245712+ryanhcode@users.noreply.github.com> Date: Sat, 5 Jun 2021 11:24:09 -0400 Subject: [PATCH 1/3] Create README.md --- README.md | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..9cb6661 --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +# KoPixel +Simple & flexible asynchronous Hypixel API for Kotlin +# KoPixel +[![](https://jitpack.io/v/ryanhcode/KoPixel.svg)](https://jitpack.io/#ryanhcode/KoPixel) + +KoPixel is a simple & flexible asynchronous Hypixel API for Kotlin + +## Installation + +Add the following to your build.gradle(.kts) + +```groovy +dependencies { + implementation 'com.github.ryanhcode:KoPixel:$kopixel_version' +} +``` +Or visit Jitpack and [select a version](https://jitpack.io/#ryanhcode/KoPixel/latest) + +## Usage + +In order to obtain a `KoPixelAPI` instance, use NewKoPixelAPI +If you plan on just using the library synchronously, you can use NewKoPixelAPI wherever you like. + +```kotlin +val hypixelAPIKey = "..." +val api = NewKoPixelAPI(hypixelAPIKey) +... +``` +However, if you are planning to use KoPixel asynchronously, the API must be created inside of a CoroutineScope, or inside of a block such as `runBlocking` which is recommended. +```kotlin +fun main() = runBlocking { + val hypixelAPIKey = "..." + val api = NewKoPixelAPI(hypixelAPIKey) + ... +} +``` + +KoPixel has both asynchronous and synchronous methods for all functions. + +Here you can see a method of synchronously obtaining if a player is online: +```kotlin +val online = api.getSync("skyf").online() +println("Online: $online") +``` +And here is a asynchronous method of obtaining if a player is online: +```kotlin +api.get("skyf").whenComplete { player-> + val online = player.online() + println("Online: $online") +} +``` +If you choose to use KoPixel asynchronously, you may also use error handling for all requests. +```kotlin +api.get("skyf").whenComplete { player-> + val online = player.online() + println("Online: $online") +}.catch { exception -> + println("woah! there was an error: $exception") +} +``` +Here you can see an example of utilizing KoPixel's asynchronous API to scan a player for Exotic Armor: +```kotlin +fun scan(uuid: UUID) { + // Grab the profiles of the player asynchronously + api.getSkyblockProfiles(uuid).whenComplete { profiles -> + profiles.forEach { profile -> + profile.scan { uuid, member, inv, item -> + if (item.colorable() && item.exotic()) + println("Exotic Found: \n\t${item.id()} \n\t${item.hexColor()} \n\t$uuid \n\t${inv.name}") + } + } + }.catch { exception -> println("Swallowing exception.") } +} +scan("cab60d114bd84d5fbcc46383ee8f6ed1".toUUID()) +``` +KoPixel currently supports a portion of the skyblock API and regular player API, although status, guild, auction, bazaar, and dungeon implementations are planned for the near future. + +## License +[MIT](https://choosealicense.com/licenses/mit/) From 15386d7d0782a3ec1364029d4242c1c6d58170e5 Mon Sep 17 00:00:00 2001 From: "Ryan H. Code" <42245712+ryanhcode@users.noreply.github.com> Date: Sat, 5 Jun 2021 11:30:29 -0400 Subject: [PATCH 2/3] Add version badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9cb6661..f187a07 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # KoPixel Simple & flexible asynchronous Hypixel API for Kotlin # KoPixel -[![](https://jitpack.io/v/ryanhcode/KoPixel.svg)](https://jitpack.io/#ryanhcode/KoPixel) +[![](https://jitpack.io/v/ryanhcode/KoPixel.svg)](https://jitpack.io/#ryanhcode/KoPixel) ![JitPack](https://img.shields.io/jitpack/v/github/ryanhcode/KoPixel) KoPixel is a simple & flexible asynchronous Hypixel API for Kotlin From b5fd9c85357b9483e38ccb14bd3e2bb990c31052 Mon Sep 17 00:00:00 2001 From: "Ryan H. Code" <42245712+ryanhcode@users.noreply.github.com> Date: Sat, 5 Jun 2021 11:31:43 -0400 Subject: [PATCH 3/3] Remove duplicate badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f187a07..9cb6661 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # KoPixel Simple & flexible asynchronous Hypixel API for Kotlin # KoPixel -[![](https://jitpack.io/v/ryanhcode/KoPixel.svg)](https://jitpack.io/#ryanhcode/KoPixel) ![JitPack](https://img.shields.io/jitpack/v/github/ryanhcode/KoPixel) +[![](https://jitpack.io/v/ryanhcode/KoPixel.svg)](https://jitpack.io/#ryanhcode/KoPixel) KoPixel is a simple & flexible asynchronous Hypixel API for Kotlin