ClashJ is a fully asynchronous Clash of Clans API wrapper, written in Kotlin.
- Fully asynchronous library
- Support the login with the
Email
andPassword
- 100% Clash of Clans API
- Events
The library required Java 17 or higher versions.
-
Add it in your root
build.gradle
e at the end of repositories:repositories { // ... maven { url 'https://jitpack.io' } }
-
Add the dependency
dependencies { implementation 'com.github.MaicolAntali:clashJ:1.0.4' }
-
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>
-
Add the dependency
<dependency> <groupId>com.github.MaicolAntali</groupId> <artifactId>clashJ</artifactId> <version>1.0.4</version> </dependency>
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}")
}
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()
}
Thank you for considering contributing to clashJ!
Here's how you can contribute:
- 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.
- Fork & Branch: Fork the repository and create a new branch for your changes.
- Code: Write your code following the Kotlin coding standards.
- Tests are Awesome: If you're adding new features, don't forget to include tests.
- Pull Request: Submit a pull request with a brief description of your changes.
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.