__Immortality__

Untitled

Oct 25th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. package com.immortal.commands;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandExecutor;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.Player;
  9.  
  10. public class PushCommand implements CommandExecutor
  11. {
  12. @Override
  13. public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
  14. {
  15. if (!(sender instanceof Player))
  16. {
  17. sender.sendMessage(ChatColor.RED + "The Command is Players Only!");
  18. return true;
  19. }
  20.  
  21. Player player = (Player) sender;
  22.  
  23. if (!(player.hasPermission("KitPVP.push")))
  24. {
  25. player.sendMessage(ChatColor.DARK_RED + "You do not have permission to do this command!");
  26. }
  27.  
  28. if (!(args.length >= 1))
  29. {
  30. player.setVelocity(player.getLocation().getDirection().multiply(2).setY(2));
  31.  
  32. player.sendMessage(ChatColor.GREEN + "Pushed!");
  33. return true;
  34. }
  35.  
  36. Player target = Bukkit.getServer().getPlayer(args[0]);
  37.  
  38. if (target == null)
  39. {
  40. player.sendMessage(ChatColor.YELLOW + args[0] + ChatColor.RED + " was not found on the server!");
  41. return true;
  42. } else {
  43. target.setVelocity(target.getLocation().getDirection().multiply(2).setY(2));
  44. player.sendMessage(ChatColor.GREEN + "Pushed " + ChatColor.YELLOW + target.getName() +
  45. ChatColor.GREEN + "!");
  46. return true;
  47. }
  48. }
  49. }
Add Comment
Please, Sign In to add comment