Advertisement
EthanGarey

Untitled

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