Advertisement
EthanGarey

Untitled

Aug 27th, 2022
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1.  
  2. package Commands;
  3.  
  4. import net.md_5.bungee.api.ChatColor;
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10.  
  11. public class Fly implements CommandExecutor {
  12.  
  13. @Override
  14. public boolean onCommand(CommandSender sender, Command command, String label, String [] args){
  15. if (!(sender instanceof Player)) {
  16. sender.sendMessage("Only players can execute this command!");
  17. return true;
  18. }
  19.  
  20. Player player = (Player) sender;
  21. if (args.length == 0) {
  22. Player target = Bukkit.getServer().getPlayer(args[0]);
  23.  
  24. if (target.getAllowFlight()) {
  25. target.setAllowFlight(false);
  26. target.sendMessage(ChatColor.BOLD + "Flight is now " + ChatColor.RED + ChatColor.BOLD + "Disabled " + ChatColor.YELLOW + ChatColor.BOLD + "For " + args[0] + ".");
  27. return true;
  28. } else {
  29. target.setAllowFlight(true);
  30. target.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Flight is now" + ChatColor.GREEN + ChatColor.BOLD + " Enabled. " + ChatColor.YELLOW + ChatColor.BOLD + "For " + args[0] + ".");
  31. return true;
  32. }
  33. }
  34. else{
  35. if (player.getAllowFlight()) {
  36. player.setAllowFlight(false);
  37. player.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Flight is now" + ChatColor.RED + ChatColor.BOLD + " Disabled.");
  38. return true;
  39. }
  40. else {
  41. player.setAllowFlight(true);
  42. player.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Flight is now" + ChatColor.GREEN + ChatColor.BOLD + " Enabled.");
  43. return true;
  44. }
  45.  
  46. }
  47.  
  48. }
  49.  
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement