Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
/ clashJ Public archive

ClashJ is a Kotlin library designed as an asynchronous API wrapper for Clash of Clans

License

Notifications You must be signed in to change notification settings

MaicolAntali/clashJ

Repository files navigation

ClashJ

Release KDocs

License Build Validation

ClashJ is a fully asynchronous Clash of Clans API wrapper, written in Kotlin.

🔑 Key points

  • Fully asynchronous library
  • Support the login with the Email and Password
  • 100% Clash of Clans API
  • Events

ℹ️ Getting started

The library required Java 17 or higher versions.

Download with Gradle

  1. Add it in your root build.gradlee at the end of repositories:

    repositories {
       // ...
       maven { url 'https://jitpack.io' }
    }
  2. Add the dependency

    dependencies {
       implementation 'com.github.MaicolAntali:clashJ:1.0.4'
    }

Download with Maven

  1. Add it in your root pom.xml at the end of repositories:

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
  2. Add the dependency

    <dependency>
        <groupId>com.github.MaicolAntali</groupId>
        <artifactId>clashJ</artifactId>
        <version>1.0.4</version>
    </dependency>

Usage Example

Simple Usage Example

fun main() = runBlocking {
    // Build a client with the default option 
    val client = Client("email", "pwd")
   
   // Login into the Clash of Clans developer website
   client.login()

    // Retrive player info
    val player = client.getPlayer("#tag").await()
    println("Name: ${player.name}, TH lvl: ${player.townHallLevel}")

    // Retrive clan info
    val clan = client.getClan("#tag").await()
    println("Name: ${clan.name}, Tag: ${clan.tag}")
}

Event Usage Example

fun main() = runBlocking {
    val eventClient = EventClient("email", "pwd")

    // Add player and clan to monitored events
    eventClient.addPlayerToMonitoredEvent("#playerTag")
    eventClient.addClanToMonitoredEvent("#clanTag")

    // Register a callback for the "JoinClan" event
    eventClient.registerPlayerCallback(MonitoredEvent.PlayerEvents.JoinClan) { _, current ->
        println("${current.name} has joined a clan.")
    }

    // Register a callback for the "MemberJoin" event
    eventClient.registerClanCallback(MonitoredEvent.ClanEvents.MemberJoin) { _, current, member ->
        println("${member.name} has joined the clan ${current.name}.")
    }

    // Login and start polling for events
    eventClient.login()
    eventClient.startPolling()
}

🔗Links

✅ Contributing

Thank you for considering contributing to clashJ!

Here's how you can contribute:

  1. Check for Issues: See if there's an existing issue or feature request related to your contribution. If not, create a new one, so we can discuss it.
  2. Fork & Branch: Fork the repository and create a new branch for your changes.
  3. Code: Write your code following the Kotlin coding standards.
  4. Tests are Awesome: If you're adding new features, don't forget to include tests.
  5. Pull Request: Submit a pull request with a brief description of your changes.

Disclaimer

This content is not affiliated with, endorsed, sponsored, or specifically approved by Supercell and Supercell is not responsible for it. For more information, see Supercell's Fan Content Policy.

About

ClashJ is a Kotlin library designed as an asynchronous API wrapper for Clash of Clans

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages