Guest User

Untitled

a guest
May 31st, 2022
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. package netcore.netcore.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. import java.util.ArrayList;
  11.  
  12. public class FlyCommand implements CommandExecutor {
  13.  
  14. private ArrayList<Player> list_of_flying_players = new ArrayList<>();
  15.  
  16.  
  17. @Override
  18. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  19. if (args.length == 0){
  20. if (sender instanceof Player){
  21. Player player = (Player) sender;
  22. if(player.hasPermission("netcore.fly"));
  23. if (list_of_flying_players.contains(player)){
  24. list_of_flying_players.remove(player);
  25. player.setAllowFlight(false);
  26. player.sendMessage(ChatColor.GREEN + "NetCore: " + ChatColor.WHITE + "Flight is turned " + ChatColor.RED + "off!");
  27. }else if (!list_of_flying_players.contains(player)) {
  28. list_of_flying_players.add(player);
  29. player.setAllowFlight(true);
  30. player.sendMessage(ChatColor.GREEN + "NetCore: " + ChatColor.WHITE + "Flight is turned on!");
  31.  
  32. }
  33. }
  34.  
  35. }else if (args.length == 1){
  36. Player target = Bukkit.getPlayer(args[0]);
  37. if (sender instanceof Player){
  38. Player player = (Player) sender;
  39. if(player.hasPermission("netcore.fly"));
  40. if (list_of_flying_players.contains(player)){
  41. list_of_flying_players.remove(player);
  42. player.setAllowFlight(false);
  43. player.sendMessage(ChatColor.GREEN + "NetCore: " + ChatColor.WHITE + "Flight is turned " + ChatColor.RED + "off!");
  44. }else if (!list_of_flying_players.contains(player)) {
  45. list_of_flying_players.add(player);
  46. player.setAllowFlight(true);
  47. player.sendMessage(ChatColor.GREEN + "NetCore: " + ChatColor.WHITE + "Flight is turned on!");
  48.  
  49. }
  50. }
  51. }
  52.  
  53. return true;
  54. }
  55.  
  56. private void Flymethod(Player player){
  57. if (sender instanceof Player){
  58. player = (Player) sender;
  59. if(player.hasPermission("netcore.fly"));
  60. if (list_of_flying_players.contains(player)){
  61. list_of_flying_players.remove(player);
  62. player.setAllowFlight(false);
  63. player.sendMessage(ChatColor.GREEN + "NetCore: " + ChatColor.WHITE + "Flight is turned " + ChatColor.RED + "off!");
  64. }else if (!list_of_flying_players.contains(player)) {
  65. list_of_flying_players.add(player);
  66. player.setAllowFlight(true);
  67. player.sendMessage(ChatColor.GREEN + "NetCore: " + ChatColor.WHITE + "Flight is turned on!");
  68.  
  69. }
  70. } }
  71. }
  72.  
  73.  
Advertisement
Add Comment
Please, Sign In to add comment