Advertisement
Brord

bukkit cmd example

Jul 28th, 2014
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. @Override
  2. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  3.     if (cmd.getName().equalsIgnoreCase("basic")) { // If the player typed /basic then do the following...
  4.         //check the amount of values in the array
  5.                 if (args.length == 0){
  6.             //no arguments
  7.             return false;
  8.         }
  9.        
  10.         //send the first value from the array
  11.         sender.sendMessage("First argument: " + args[0]);
  12.         return true;
  13.     } else if (cmd.getName().equalsIgnoreCase("basic2")) {
  14.         //command is now the same as the  one checked ^ (basic2)
  15.         String command = cmd.getName();
  16.  
  17.         //for every argument, add it to the command
  18.         for (String arg : args){
  19.             command += " " + arg;
  20.         }
  21.  
  22.         //send entire command as message
  23.         sender.sendMessage("Entire command: " + command);
  24.         return true;
  25.     }
  26.     return false;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement