Skip to main content

🗳️ EventVoteService API

EventVoteService is the public API for EventForge's manual event voting system.

Use it to check vote state, start votes, cast votes, cancel votes, confirm pending winners and send vote status output.

Manual votes use EventForge's normal winner start flow. This means winning events still respect EventForge event checks, cooldowns, conditions and manual queue settings.


Getting the service

if (!EventForgeAPI.isAvailable()) {
return;
}

EventVoteService voteService = EventForgeAPI.getEventVoteService();

Check if voting is enabled

boolean enabled = voteService.isVotingEnabled();

This reads EventForge's voting config.

If voting is disabled in config.yml, vote-starting calls will not start a vote.


Check if a vote is active

boolean active = voteService.isVoteActive();

This returns true when a vote is active or when a winner is pending confirmation.


Read the current vote

voteService.getActiveVote().ifPresent(vote -> {
long secondsLeft = vote.getSecondsLeft();
int totalVotes = vote.getTotalVotes();

for (String optionId : vote.getOptionIds()) {
String display = vote.getDisplayName(optionId);
int count = vote.getVoteCount(optionId);
}
});

EventVoteInfo is an immutable snapshot. It is safe to read, but it does not let addons mutate EventForge's internal vote state.


EventVoteInfo methods

Useful methods:

vote.getOptionIds();
vote.getDisplayNames();
vote.getVoteCounts();
vote.getDisplayName("mining_rush");
vote.getVoteCount("mining_rush");
vote.hasOption("mining_rush");
vote.getTotalVotes();
vote.getSecondsLeft();
vote.hasEnded();
vote.getWinnerId();
vote.hasWinner();

Get active vote option IDs

List<String> optionIds = voteService.getActiveVoteOptionIds();

This returns an immutable list of current vote option IDs.

If no vote is active, it returns an empty list.


Start a vote

boolean started = voteService.startVote(
sender,
List.of("mining_rush", "mob_hunt", "fishing_frenzy")
);

The event IDs are validated against loaded EventForge templates.

Duplicate IDs are ignored internally.

If the vote starts, EventForge broadcasts the normal clickable vote options to players.


Cast a vote

boolean accepted = voteService.castVote(player, "mining_rush");

This uses the same rules as /events vote <event>.

The result depends on the current vote state, selected option and whether vote changes are allowed.


Cancel a vote

boolean cancelled = voteService.cancelVote(sender);

This cancels the current active vote or pending winner state.


Confirm a pending winner

boolean confirmed = voteService.confirmWinner(sender);

Use this when voting is configured with:

voting:
start-winner-automatically: false

If a vote ends with a winner, EventForge stores the winner until an admin or addon confirms it.


Send vote status output

voteService.sendStatus(sender);

This sends EventForge's normal vote status output to a command sender.

It is useful for custom admin commands.


Manual queue integration

If the winning event uses:

participation:
mode: MANUAL

then the winner opens a manual queue instead of starting instantly.

This happens automatically because voting uses EventForge's normal event start flow.

Your addon does not need to start the queue manually.


Safe Discord announcement example

voteService.getActiveVote().ifPresent(vote -> {
StringBuilder message = new StringBuilder("Event vote is active!\n");

for (String optionId : vote.getOptionIds()) {
message.append("- ")
.append(vote.getDisplayName(optionId))
.append(": ")
.append(vote.getVoteCount(optionId))
.append(" votes\n");
}

// Send message to your Discord bridge here.
});

Notes

EventVoteService does not expose EventForge's internal vote session.

It only exposes safe methods and immutable EventVoteInfo snapshots.

For vote Bukkit events, see the Bukkit Events page.