Advertisement
Guest User

Multiple args

a guest
Apr 25th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1.     public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
  2.         if (sender instanceof Player) {
  3.             Player player = (Player) sender;
  4.            
  5.         if (player.hasPermission("ve.gamemode")) {
  6.            
  7.         if (args.length == 1) {
  8.        
  9.         if (args[0].equals("0")) {
  10.             player.setGameMode(GameMode.SURVIVAL);
  11.             player.sendMessage(ChatColor.GRAY + "Modified your current gamemode to " + ChatColor.YELLOW + "survival.");
  12.         }
  13.         else if (args[0].equals("1")) {
  14.             player.setGameMode(GameMode.CREATIVE);
  15.             player.sendMessage(ChatColor.GRAY + "Modified your current gamemode to " + ChatColor.YELLOW + "creative.");
  16.         }
  17.         else if (args[0].equals("2")) {
  18.             player.setGameMode(GameMode.ADVENTURE);
  19.             player.sendMessage(ChatColor.GRAY + "Modified your current gamemode to " + ChatColor.YELLOW + "adventure.");
  20.         }
  21.         else if (args[0].equals("3")) {
  22.             player.setGameMode(GameMode.SPECTATOR);
  23.             player.sendMessage(ChatColor.GRAY + "Modified your current gamemode to " + ChatColor.YELLOW + "spectator.");
  24.         }
  25.         }
  26.         else player.sendMessage(ChatColor.RED + "You did not enter the correct arguments.");
  27.         return true;
  28.         }
  29.         else player.sendMessage(ChatColor.RED + "You do not have the right permission.");
  30.         return true;
  31.         }
  32.         else sender.sendMessage(ChatColor.RED + "You cannot execute this command in console.");
  33.         return true;
  34.     }
  35.    
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement