CedMod Api
The CedMod Api
integration provides easy interaction and data handling of the api of https://cedmod.nl/
Usage
All functions for the CedMod Api
are located in the io.github.vxrpenter.cedmod.Cedmod
class, and can easily imported with one line:
import io.github.vxrpenter.cedmod.Cedmod
The Cedmod
class has to be supplied with the servers api-key
and it's instance-url
before making any requests. This is a short representation of correct Cedmod
invocation:
import io.github.vxrpenter.cedmod.Cedmod
val api = "API_KEY"
val instanceUrl = "https://myservername.cmod.app"
val cedmod = Cedmod(api, instanceUrl)
Exceptions
All functions that are contained in the Cedmod
class throw a CallFailureException
inherited from a CedmodException
when a call to the api fails for any reason. You can could catch it like this:
try {
val cedmod = Cedmod(api, instanceUrl).changelogGet()
} catch (e: Exception) {
println("An error has occured during an cedmod api call")
return
}
Examples
Issuing a ban for a user, using the CedMod Api
. This returns a status code of the interaction
import io.github.vxrpenter.cedmod.Cedmod
fun main() {
// The api key of the server. This can only be obtained after asking cedmod staff to active it for the specific instance
val api = "API_KEY"
// Url of the instance being normally https://myservername.cmod.app
val instanceUrl = "INSTANCE_URL"
// Issues a ban to the cedmod api. The userId is typically steam/discord id with @steam or @discord attached.
Cedmod(api, instanceUrl).banPostIssue(userId = "USER_ID@steam", reason = "REASON", duration = 1, appealable = true, banlists = listOf(1111))
}
Fetching a player and their stats using the CedMod Api
. This returns a Player
object
import io.github.vxrpenter.cedmod.Cedmod
fun main() {
// The api key of the server. This can only be obtained after asking cedmod staff to active it for the specific instance
val api = "API_KEY"
// Url of the instance being normally https://myservername.cmod.app
val instanceUrl = "INSTANCE_URL"
val steamId = "USER_ID"
// Returns a player object with stats like playtime, kills etc.
val player = (api, instanceUrl).playerQuery(q = "$steamId@steam", activityMin = 365, basicStats = true)
}
Last updated