Skip to content
github-actions[bot] edited this page Aug 16, 2026 · 6 revisions

VotingPlugin Developer API

Release baseline: The signatures and source links on this page target VotingPlugin 7.1.1. The hosted Javadocs and master source 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

VotingPluginMainplugin = (VotingPluginMain) Bukkit.getPluginManager()
.getPlugin("VotingPlugin");
if (plugin == null || !plugin.isEnabled()) {
return;
}
VotingPluginHookshooks = VotingPluginHooks.getInstance();
UserManageruserManager = hooks.getUserManager();

Release 7.1.1 VotingPluginHooks methods include:

MethodPurpose
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

VotingPluginUserbyPlayer = plugin.getVotingPluginUserManager()
.getVotingPluginUser(player);
VotingPluginUserbyName = plugin.getVotingPluginUserManager()
.getVotingPluginUser("BenCodez");
VotingPluginUserbyUuid = plugin.getVotingPluginUserManager()
.getVotingPluginUser(uuid);

Common point operations include:

intpoints = 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.

VoteSitesite = plugin.getVoteSite("ExampleSite", true);
if (site != null) {
site.giveRewards(user, user.isOnline(), false);
}

The second getVoteSite argument controls whether disabled sites are filtered out. 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(newCommandHandler(
plugin,
newString[] { "Example", "(player)" },
"myplugin.command.example",
"Run the example command"
) {
@Overridepublicvoidexecute(CommandSendersender, 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:

@EventHandlerpublicvoidonVote(PlayerPostVoteEventevent) {
getLogger().info(event.getPlayerName() + " voted on " + event.getService());
}

VotingPlugin 7.1.1 event classes include:

EventWhen it is used
PlayerVoteEventA vote enters VotingPlugin processing; exposes vote, total, broadcast, and cancellation controls
PlayerPostVoteEventVote processing has reached the post-vote stage
PlayerReceivePointsEventVote points are about to be applied; exposes points and cancellation controls
PlayerSpecialRewardEventA VotingPlugin special reward is processed
PlayerVoteCoolDownEndEventA player's overall voting cooldown becomes available
PlayerVoteSiteCoolDownEndEventA specific vote site's cooldown becomes available
VotePartyEventA vote party is triggered
VoteMilestoneRewardEventA VoteMilestone reward completes successfully
VoteShopPurchaseEventA 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.

Clone this wiki locally