You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importcom.hytalist.hyvote.event.VoteReceivedEventoverridefunsetup() {
eventRegistry.registerGlobal(VoteReceivedEvent::class.java) { event ->val vote = event.vote
val player = vote.username
val service = vote.serviceName
logger.info("$player voted on $service!")
// Cancel to prevent HyVote's default rewards// event.setCancelled(true)
}
}
Querying Vote Data (since 1.6.0)
Java
importcom.hytalist.hyvote.api.HyVoteAPI;
importcom.hytalist.hyvote.api.HyVoteAPI.VoterInfo;
importkotlin.Pair;
importjava.util.List;
importjava.util.UUID;
// Get the API instanceHyVoteAPIapi = HyVoteAPI.get();
// Get vote countsinttotalVotes = api.getPlayerVotes(playerUuid); // All-time totalintthisMonth = api.getPlayerVotesThisMonth(playerUuid); // Current monthintlastMonth = api.getPlayerVotesPreviousMonth(playerUuid); // Previous monthintjan2025 = api.getPlayerVotesForMonth(playerUuid, 2025, 1); // Specific month// Get player rankings (returns null if player hasn't voted)Pair<Integer, Integer> rank = api.getPlayerRankAllTime(playerUuid);
if (rank != null) {
intposition = rank.getFirst(); // Rank position (1 = first place)intvotes = rank.getSecond(); // Vote count
}
// Get top votersList<VoterInfo> topVoters = api.getTopVotersThisMonth(10);
for (VoterInfovoter : topVoters) {
UUIDuuid = voter.getUuid();
Stringusername = voter.getUsername();
intvotes = voter.getVotes();
}
// Get last vote time (epoch milliseconds, null if never voted)LonglastVoteTime = api.getLastVoteTime(playerUuid);
Kotlin
importcom.hytalist.hyvote.api.HyVoteAPI// Get the API instanceval api =HyVoteAPI.get()
// Get vote countsval totalVotes = api.getPlayerVotes(playerUuid) // All-time totalval thisMonth = api.getPlayerVotesThisMonth(playerUuid) // Current monthval lastMonth = api.getPlayerVotesPreviousMonth(playerUuid) // Previous monthval jan2025 = api.getPlayerVotesForMonth(playerUuid, 2025, 1) // Specific month// Get player rankings (returns null if player hasn't voted)val rank = api.getPlayerRankAllTime(playerUuid)
if (rank !=null) {
val (position, votes) = rank // Destructuring
}
// Get top votersval topVoters = api.getTopVotersThisMonth(10)
for (voter in topVoters) {
val uuid = voter.uuid
val username = voter.username
val votes = voter.votes
}
// Get last vote time (epoch milliseconds, null if never voted)val lastVoteTime = api.getLastVoteTime(playerUuid)
API Reference
VoteReceivedEvent
Method
Return Type
Description
getVote()
Vote
Get the vote data
isCancelled()
boolean
Check if event is cancelled
setCancelled(boolean)
void
Cancel to prevent default rewards
Vote
Method
Return Type
Description
getUsername()
String
Player who voted
getServiceName()
String
Voting service name
getAddress()
String
Voter's IP address
getTimestamp()
String
Vote timestamp
HyVoteAPI (since 1.6.0)
Get the API instance with HyVoteAPI.get(). Throws IllegalStateException if HyVote is not loaded.