Skip to content
Ben edited this page Jul 20, 2016 · 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!

JavaDoc available here

####User object:

  • I use a user object to handle most things with a user, there is a Data class that actually handles the file reading/editing
  • Creating object:
    new User(playerName);
    new User(new UUID(uuid)); // uuid as string
    new User(player); // player = Player object
  • Using Examples:
    • Get total votes: user.getTotalVotes();
    • Get user points: user.getPoints();
    • Set user points: user.setPoints(int);

####VoteSite object:

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

####Reward object

  • Similar to vote sites, there is a reward object that handles the actual reward giving
  • The class ConfigRewards handles editing/reading reward files
  • Creating object: ConfigRewards.getInstance().getReward(reward)
  • Using object:
    • Run reward: reward.giveReward(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 he 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

####PlayerVote Event:

  • 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
Clone this wiki locally