Giter Club home page Giter Club logo

cursekt's Introduction

CurseKT Maven Central Maven Central Maven Central

License Discord Release Build Status Develop Build Status

Multiplatform Kotlin library to work with the Curse (CurseForge) API using Ktor.

Setup

  1. Add the lib to your project's dependencies by copying one of the following lines depending on the platform:
  • Groovy (replace $cursekt_version with the version you want):
 implementation "net.pearx.cursekt:cursekt-metadata:$cursekt_version" // for Common
 // or
 implementation "net.pearx.cursekt:cursekt-jvm:$cursekt_version" // for JVM
 // or
 implementation "net.pearx.cursekt:cursekt-js:$cursekt_version" // for JS
  • Kotlin (replace $cursektVersion with the version you want):
 implementation("net.pearx.cursekt:cursekt-metadata:$cursektVersion") // for Common
 // or
 implementation("net.pearx.cursekt:cursekt-jvm:$cursektVersion") // for JVM
 // or
 implementation("net.pearx.cursekt:cursekt-js:$cursektVersion") // for JS
  1. CurseKT uses coroutines! Ensure you've added kotlinx.coroutines as a dependency: https://github.com/Kotlin/kotlinx.coroutines#using-in-your-projects.

  2. Don't forget to declare the JCenter Maven repository to your build script (required by Ktor):

repositories {
    jcenter()
}
  1. Use the library and have fun!

How to Use the Library

You can get a brief example of how to work with the library at the Example Application section. To get all the methods available in CurseKT, take a look at the CurseClient.kt file.

Example Application

This application will search for Minecraft 1.15.2 mods matching the "just enough items" filter, sort by download count and print them.

import kotlinx.coroutines.runBlocking
import net.pearx.cursekt.client.CurseClient

fun main() {
    runBlocking {
        val curse = CurseClient() // create a new CurseClient instance
        val minecraftGame = curse.getGames(supportsAddons = true).first { it.slug == "minecraft" } // get Minecraft game
        val modsSection = minecraftGame.categorySections.first { it.name == "Mods" } // get Minecraft Mods section
        val addons = curse.searchAddons(gameId = minecraftGame.id, sectionId = modsSection.gameCategoryId, gameVersion = "1.15.2", searchFilter = "just enough items") // search for Minecraft 1.15.2 mods matching the "just enough items" filter
        val addonsSorted = addons.sortedByDescending { it.downloadCount } // sort search results by download count
        println(addonsSorted.joinToString(System.lineSeparator()) { "${it.name} - ${it.downloadCount.toInt()}" }) // print sorted search results
    }
}

cursekt's People

Contributors

mrapplexz avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.