help/CustomCommands

Custom Commands

This will probably not be used by the majority of users, but custom commands are by far the most powerful tool of this plugin. You can make custom commands, and on top of that pass parameters to those commands. The pre-made commands will show you how to make custom commands to an extent, but this is going to be a full and thorough breakdown of how custom commands work.

The Config.yml

The holder of all that is holy, this contains the commands list, and lets you make, delete, edit any command my plugin (or any plugin for that matter) executes.

The Explanation

Here's the list of all the options, and how they work: kick:
Description: 'Kick player'
ArgumentCount: 1
InsufficientArgumentsError: '&CIncorrect arguments! You need to do /Vote kick PlayerName where PlayerName is the players name'
VoteStartText: '&A[%1] has started a vote to kick &C[%0]&A! Type &6/vote yes &Aor &6/vote no &Ato vote'
TimeoutSeconds: 60
VoteOnCooldownText: '&CA player has been kicked too recently!'
VoteSuccessText: '&AVote succeeded! &C[%0] &Ahas been kicked'
VoteSuccessCommandDelaySeconds: 3
VoteSuccessCommands:
- FINDPLAYER[%0]
- VERIFYPLAYERONLINE [%0]
- vote setvalue kick [%0]
CooldownMinutesToSuccessRevote: 1
VoteFailText: '&AVote to kick &C[%0] &Afailed!'
VoteFailCommandDelaySeconds: 0
VoteFailCommands: []
CooldownMinutesToFailRevote: 30
MinimumVotes: 1
PercentToSucceed: 70
IgnoreUnvotedPlayers: true
IsConsoleCommand: true
LastSuccessfulVote: 0
LastFailedVote: 0 Here's an explanation for every single one of these commands:
  • kick: - This is the name of the command. If we change this to punt, a player would have to do /vote punt, and not /vote kick.
  • ArgumentCount - This one's a bit tricky. It tells the plugin the minimum number of arguments needed. For something like /vote day, you don't need any arguments, so this is set to 0. But for kicking and banning, you need to have the target players name, so this needs to be 1. For however many arguments the commands need, this needs to reflect that. If you need 3 arguments, this needs to be 3.
  • InsufficientArgumentsError - If a player attempts to start a vote with the wrong number of arguments, this gets sent to them.
  • VoteStartText - Pretty easy to figure out. This text is displayed when a player starts the vote. This parameter can convert arguments to text.
  • TimeoutSeconds - This is how long the vote will stay open until it times out. The default is 60 seconds.
  • VoteOnCooldownText - If a player tries to start a vote that's still on cooldown (the cooldown minutes aren't up yet), this text will be sent to them. This parameter can convert arguments to text.
  • VoteSuccessText - On a successful vote completion, this text is displayed to everyone. If someone vote kicked me, it would look like "Vote succeeded! RabidCrab has been kicked". This parameter can convert arguments to text.
  • VoteSuccessCommandDelaySeconds - The exact same as VoteFailCommandDelaySeconds, but for a successful vote result. I put a 3 second delay on kick and ban so the kicked/banned player has time to read that he just got owned.
  • Description - When you get a list of votes, this description displays to the right of the command name. For the kick vote, it shows "Kick - Kick player".
  • VoteSuccessCommands - The list of commands to execute when a successful vote completes. You can add any number of commands here, and the Vote plugin has its own list of commands, available here.
  • CooldownMinutesToSuccessRevote - For some commands, like /vote day, you don't want them to keep voting over and over for it, so you put this to something like 12 so they have to wait 12 minutes before they can start another vote for day.
  • VoteFailText - Just like VoteSuccessText, but for a failed vote.
  • VoteFailCommandDelaySeconds - This is how long after the vote fails the listed commands should be executed. Imagine that after a failed vote, the vote starter gets struck by lightning. You wouldn't want it to be instant, otherwise they wouldn't know what hit them, so you'd put a few second delay to get ready for the incoming lightning strike.
  • VoteFailCommands - Just like VoteSuccessCommands, but for a failed vote. I don't ever use this, but someone may need it for whatever reason.
  • CooldownMinutesToFailRevote - Just like CooldownMinutesToSuccessRevote, but for a failed vote.
  • MinimumVotes - This is the minimum number of people required for the vote to succeed. If there's only 2 people online, a vote that requires 3 votes won't succeed.
  • PercentToSucceed - Another very important parameter. This one is the percentage of yes votes the vote needs to win. At 70, 70% of the logged in players need to vote yes for the vote to pass.
  • IgnoreUnvotedPlayers - Yet another very important parameter. If true, at the end of the vote the unvoting players do not count. So let's say you vote for daylight, and there's 10 people online. 3 vote for daylight, and 1 votes no. If this is set to true, it means that there's a 75% approval, and the vote succeeds. But if this is false, that means those who didn't vote count as no votes. So it would be 3 votes yes, and 7 votes no, making it only 33%, which fails.
  • IsConsoleCommand - This is by far the most controversial part of this plugin, and for me the most frustrating thing I've ever had to make. When this is true, that means my plugin will attempt to execute the commands as the console. This is great for commands that aren't player specific, such as kicks, jails, bans, etc. It works for the vast majority of plugins, and should be kept to true. If your commands are failing, try setting this to false. When set to false, my plugin will execute the command through the op account Notch. This is the only reason why Notch is opped for my plugin, and if all the other plugin developers had good coding practices, I wouldn't have to do this at all.
  • LastSuccessfulVote - Don't worry about this one, it's for the plugin.
  • LastFailedVote - This is for the plugin as well, you can ignore it.



For the next chapter, I recommend reading about how to use Arguments in my plugin.

Comments

Posts Quoted:
Reply
Clear All Quotes