Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ColourCommand implements CommandExecutor
- {
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
- {
- //Say for example we are making a command like this /colour <type>
- //First we check if the sender is a player (sender can also be the server console or a command block).
- if (!(sender instanceof Player))
- return false;
- //You have to make sure you checking there are the right number of arguments. In this case we are only looking for one, "<type>".
- if (args.length == 1)
- {
- switch (args[0].toLowerCase())
- {
- case "blue":
- //The command must be /colour blue
- break;
- case "red":
- //The command must be /colour red
- break;
- default:
- //The first argument is not a colour
- return false;
- }
- }
- //Return true for successful commands, and vice versa.
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement