Plugin API
Programmatic access to VotePipe from your plugin code
Overview
Add VotePipe as a dependency to access these methods from your own plugin. All methods return CompletableFuture for async operation.
groovy
dependencies {
compileOnly("com.mythlane:votepipe:1.0.0")
}Available Methods
| Method | Return | Description |
|---|---|---|
| claimForPlayer(String) | CompletableFuture<List<Vote>> | Claims all unclaimed votes for a player |
| getUnclaimedVotes() | CompletableFuture<List<Vote>> | Get all unclaimed votes |
| getLeaderboard() | CompletableFuture<Leaderboard> | Get global vote leaderboard |
| getLeaderboard(String) | CompletableFuture<Leaderboard> | Get leaderboard filtered by provider |
| getLeaderboard(Options) | CompletableFuture<Leaderboard> | Get leaderboard with custom options |
| getConnectionStatus() | ConnectionStatus | Current connection state |
| isConnected() | boolean | Quick check if connected |
Example: Claim on Player Join
Automatically claim any pending votes when a player joins:
java
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
VotePipe.claimForPlayer(player.getName())
.thenAccept(votes -> {
if (!votes.isEmpty()) {
for (Vote vote : votes) {
giveReward(player, vote);
}
player.sendMessage("You received " + votes.size() + " vote reward(s)!");
}
})
.exceptionally(error -> {
getLogger().warning("Failed to claim votes: " + error.getMessage());
return null;
});
}LeaderboardOptions
Customize leaderboard queries with these options:
| Field | Type | Default | Description |
|---|---|---|---|
| provider | String | null | Filter by provider (null = all) |
| period | Period | MONTHLY | DAILY, WEEKLY, MONTHLY, ALL_TIME |
| limit | int | 10 | Max entries (1-100) |
java
// Get weekly top 20 from Hytale-Servers.pro
LeaderboardOptions options = new LeaderboardOptions()
.provider("hytale-servers-pro")
.period(Period.WEEKLY)
.limit(20);
VotePipe.getLeaderboard(options)
.thenAccept(leaderboard -> {
for (LeaderboardEntry entry : leaderboard.getEntries()) {
System.out.println("#" + entry.getRank() + " " +
entry.getPlayerName() + " - " + entry.getVoteCount());
}
});Leaderboard Response
Leaderboard Object
| Field | Type | Description |
|---|---|---|
| entries | List<LeaderboardEntry> | Ranked list of players |
| period | String | Period used |
| provider | String | Provider filter (null if global) |
| generatedAt | Instant | When the leaderboard was generated |
LeaderboardEntry Object
| Field | Type | Description |
|---|---|---|
| rank | int | Position (1-based) |
| playerName | String | Player username |
| voteCount | int | Total votes in period |
Connection Status
java
if (VotePipe.isConnected()) {
sender.sendMessage("§aVotePipe is connected!");
} else {
ConnectionStatus status = VotePipe.getConnectionStatus();
sender.sendMessage("§cVotePipe is " + status.name().toLowerCase());
}Connection status values: CONNECTED,INTERMITTENT,DISCONNECTED,NEVER