Votifier client library for server lists written in Kotlin
- Votifier protocol V1 (legacy)
- Votifier protocol V2 (nuVotifier)
MCVotifierLib is published to Github Packages for usage in Maven or Gradle.
Github Packages' Maven registry requires authentication, so it is recommended to generate a Personal Access Token with packages:read
scope.
See Authenticating to GitHub Packages for more information on authenticating to GitHub Package Maven registry. Below is an example build.gradle.kts
utilizing the net.saliman.properties
plugin
plugins {
// ...
id("net.saliman.properties") version "1.5.2"
}
repositories {
mavenCentral()
// ...other repositories
maven("https://maven.pkg.github.com/dotRun/MCVotifierLib") {
name = "GithubPackages"
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GPR_USER")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GPR_KEY")
}
}
}
// ...
The MCVotifierLib library is very small. In order to use it you must first construct a VoteSender
(V1 or V2) for a given votifier server. That VoteSender
can then be used to send Vote
s.
Here's an example of using the library running on the kotlin-interactive-shell. It assumes a locally-running Minecraft server using Votifier V2 on port 8192
❯ ki
ki-shell 0.5.2/1.7.0
type :h for help
[0] :repository https://maven.pkg.github.com/dotRun/MCVotifierLib mc-votifier-lib-repo.properties
[1] :dependsOn io.dotrun:mc-votifier-lib:0.2.0
[2] import java.net.InetSocketAddress
[3] import io.dotrun.mcvotifierlib.V2VoteSender
[4] import io.dotrun.mcvotifierlib.Vote
[5] val address = InetSocketAddress("localhost", 8192) // server address -- NOTE This is the votifier port, NOT the Minecraft port
[6] val token = "<*sensitive*>" // v2 votifier token
[7] val voteSender = V2VoteSender(address, token)
[8] val vote = Vote(serviceName = "test-service", username = "testuser", address = "127.0.0.1")
[9] voteSender.sendVote(vote)
This results in the following log line on the server, showing that the vote was received:
[21:08:48 INFO]: [Votifier] Got a protocol v2 vote record from /172.17.0.1:54098 -> Vote (from:test-service username:testuser address:127.0.0.1 timeStamp:1670101716542 additionalData:null)