Coder Social home page Coder Social logo

hylin's Introduction

Hylin

Hylin is a simple & flexible asynchronous Hypixel API wrapper for Kotlin

Installation

Add the following to your build.gradle(.kts)

dependencies {
    implementation("com.github.Skytils:Hylin:$hylin_version")
}

Or visit Jitpack and select a version

Usage

In order to obtain a HylinAPI instance, use createHylinAPI If you plan on just using the library synchronously, you can use createHylinAPI wherever you like.

val hypixelAPIKey = "..."
val api = createHylinAPI(hypixelAPIKey)
...

However, if you are planning to use Hylin asynchronously, the API must be created inside of a CoroutineScope, or inside of a block such as runBlocking which is recommended.

fun main() = runBlocking {
    val hypixelAPIKey = "..."
    val api = createHylinAPI(hypixelAPIKey)
    ...
}

Hylin has both asynchronous and synchronous methods for all functions.

Here you can see a method of synchronously obtaining if a player is online:

val online = api.getSync("skyf").online()
println("Online: $online")

And here is a asynchronous method of obtaining if a player is online:

api.get("skyf").whenComplete { player->
    val online = player.online()
    println("Online: $online")
}

If you choose to use Hylin asynchronously, you may also use error handling for all requests.

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 Hylin's asynchronous API to scan a player for Exotic Armor:

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())

Hylin currently supports a large portion of the skyblock API and regular player API, although resource, auction, bazaar, and dungeon implementations are planned for the near future.

License

GNU AGPL 3.0

Original Project & License

ryanhcode's KoPixel

MIT

hylin's People

Contributors

dependabot[bot] avatar my-name-is-jeff avatar ryanhcode avatar sychic avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

unexdev

hylin's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.