VotingPlugin Developer API
Release baseline: The signatures and source links on this page target VotingPlugin 7.1.1. The hosted Javadocs and
mastersource can include unreleased 7.1.2-SNAPSHOT changes. VotingPlugin 7.1.1 requires Java 21.
VotingPlugin exposes user, vote-site, command, reward-extension, and event APIs for Bukkit plugins.
Add VotingPlugin as a dependency or soft dependency in your plugin metadata before accessing it.
Getting the plugin and hooks
VotingPluginMain plugin = (VotingPluginMain) Bukkit.getPluginManager()
.getPlugin("VotingPlugin");
if (plugin == null || !plugin.isEnabled()) {
return;
}
VotingPluginHooks hooks = VotingPluginHooks.getInstance();
UserManager userManager = hooks.getUserManager();
Release 7.1.1 VotingPluginHooks methods include:
| Method | Purpose |
|---|---|
getMainClass() |
Returns the current VotingPluginMain instance |
getUserManager() |
Returns VotingPlugin's user manager |
backgroundUpdate(Player) |
Runs the user's vote/offline-reward update |
addCustomReward(RewardInject) |
Registers a custom AdvancedCore reward |
addCustomRequirement(RequirementInject) |
Registers a custom reward requirement |
See VotingPluginHooks.java at 7.1.1 for the released contract.
User objects
VotingPluginUser byPlayer = plugin.getVotingPluginUserManager()
.getVotingPluginUser(player);
VotingPluginUser byName = plugin.getVotingPluginUserManager()
.getVotingPluginUser("BenCodez");
VotingPluginUser byUuid = plugin.getVotingPluginUserManager()
.getVotingPluginUser(uuid);
Common point operations include:
int points = byPlayer.getPoints();
byPlayer.setPoints(100);
byPlayer.addPoints(10);
byPlayer.removePoints(5);
Do not perform blocking database work on the Bukkit main thread. Use the plugin's existing APIs and scheduler expectations when working with uncached users.
Vote sites
VoteSite is in com.bencodez.votingplugin.votesites.
VoteSite site = plugin.getVoteSite("ExampleSite", true);
if (site != null && site.isEnabled()) {
site.giveRewards(user, user.isOnline(), false);
}
The second getVoteSite argument requests enabled-site filtering. In release
7.1.1, a direct key or display-name lookup can still return a disabled site,
so also check site.isEnabled() as shown above. Reward delivery also needs the
correct online and proxy/Bungee context; do not blindly copy the example when
processing a real vote.
Adding a subcommand
VotingPlugin uses AdvancedCore's CommandHandler. Pass the plugin instance to the released constructor:
plugin.getVoteCommand().add(new CommandHandler(
plugin,
new String[] { "Example", "(player)" },
"myplugin.command.example",
"Run the example command"
) {
@Override
public void execute(CommandSender sender, String[] args) {
if (args.length < 2) {
return;
}
sender.sendMessage("Example command for " + args[1]);
}
});
Use plugin.getAdminVoteCommand() to add an /adminvote (/av) subcommand. For production code, validate argument counts, console access, permissions, and player lookup behavior.
Released examples are available in CommandLoader.java at 7.1.1.
VotingPlugin events
Register listeners through Bukkit's normal event system:
@EventHandler
public void onVote(PlayerPostVoteEvent event) {
getLogger().info(event.getPlayerName() + " voted on " + event.getService());
}
VotingPlugin 7.1.1 event classes include:
| Event | When it is used |
|---|---|
PlayerVoteEvent |
A vote enters VotingPlugin processing; exposes vote, total, broadcast, and cancellation controls |
PlayerPostVoteEvent |
Vote processing has reached the post-vote stage |
PlayerReceivePointsEvent |
Vote points are about to be applied; exposes points and cancellation controls |
PlayerSpecialRewardEvent |
A VotingPlugin special reward is processed |
PlayerVoteCoolDownEndEvent |
A player's overall voting cooldown becomes available |
PlayerVoteSiteCoolDownEndEvent |
A specific vote site's cooldown becomes available |
VotePartyEvent |
A vote party is triggered |
VoteMilestoneRewardEvent |
A VoteMilestone reward completes successfully |
VoteShopPurchaseEvent |
A player attempts a VoteShop purchase |
Use the 7.1.1 events source directory as the release-authoritative list. AdvancedCore also publishes reward and lifecycle events; check the exact dependency version before depending on one.
Compatibility guidance
- Compile against the VotingPlugin and AdvancedCore versions you support.
- Treat source and Javadocs for that exact version as authoritative.
- Use soft dependency handling if your plugin can operate without VotingPlugin.
- Avoid reflection when a public API is available.
- Test integrations with both cached/offline votes and normal online votes.