Skip to content
Ben edited this page Jul 2, 2022 · 27 revisions

Want to hook into my plugin? Here's a basic overview on the API. This is useful if you want to make a addon or an extend the features of my plugin. More API to come! Feel free to request API if needed.

JavaDoc available here

VotingPluginHooks - Class to make getting into the api a bit easier

  • VotingPluginHooks.getInstance()
  • Method to get main class
  • Method to get user manager
  • Method to inject into reward api

User object:

  • I use a user object to handle most things with a user
  • Creating object (plugin is main class):
    • plugin.getVotingPluginUserManager().getVotingPlugin(playerName);
    • plugin.getVotingPluginUserManager().getVotingPlugin(player);
    • plugin.getVotingPluginUserManager().getVotingPlugin(new UUID(uuid));
  • Using Examples:
    • Get user points: user.getPoints();
    • Set user points: user.setPoints(int);

VoteSite object:

  • Similary, I use a votesite object to handle stuff with vote sites
  • The class ConfigVoteSites that handles the file reading/editing
  • Create object:
    plugin.getVoteSite(name);
  • Using object:
    • Give vote site rewards: voteSite.giveRewards(user); // user is user object

Adding commands into /v or /av

  • With my command system, you can add your own custom commands in /vote or /adminvote, with tab complete support

  • Define what arguments to add ("(player)","(sitename)","(string)","(number)","(reward)","(list)","(boolean)" are ones the plugin will add tab support and for example, check if argument is a number)

  • Also use & to define multiple possible args (E.g. "Help&?")

  • Examples (plugin is my Main plugin class, either add a CommandHandler to voteCommand or adminVoteCommand):

      plugin.voteCommand.add(new CommandHandler(new String[] { "Next",
      		"(player)" }, "Permission", "Help message for /v help or /av help") {
      	@Override
      	public void execute(CommandSender sender, String[] args) {
                          // code to run when command is executed, if player has perms and
                          // args like number is met, plugin will check if it should be a number and check if args match
                          // no need to add it here
      	}
      });
    
  • See my CommandLoader class for more examples

PlayerVoteEvent:

  • When a player votes, it will trigger a PlayerVoteEvent
  • You can use this to cancel a vote, or whatever you want to do with it

PlayerRewardEvent:

  • When a player is given a reward, it will trigger a PlayerRewardEvent
  • You can use this to cancel a reward, or whatever you want to do with it
Clone this wiki locally