Advertisement
Guest User

SkyBurn fly

a guest
Oct 10th, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. package net.skyburn.global.command;
  2.  
  3. import net.skyburn.skyblock.SkyBlock;
  4.  
  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. /**
  12. * Created by Philipp on 07.10.2015
  13. */
  14. public class C_Fliegen implements CommandExecutor {
  15.  
  16. private SkyBlock plugin;
  17.  
  18. public C_Fliegen(SkyBlock plugin) {
  19. this.plugin = plugin;
  20. }
  21.  
  22. @Override
  23. public boolean onCommand(CommandSender sender, Command cmd, String label,
  24. String[] args) {
  25. if (cmd.getName().equalsIgnoreCase("fliegen")) {
  26. if (sender instanceof Player) {
  27. Player p = (Player) sender;
  28. if (p.hasPermission("skyblock.fliegen")) {
  29. if (args.length == 0) {
  30. if (p.getAllowFlight() == true) {
  31. p.setFlying(false);
  32. p.setAllowFlight(false);
  33. p.sendMessage(plugin.skyburn
  34. + "Du kannst nun nicht mehr Fliegen.");
  35. } else if (p.getAllowFlight() == false) {
  36. p.setAllowFlight(true);
  37. p.sendMessage(plugin.skyburn
  38. + "Du kannst nun Fliegen.");
  39. }
  40. } else if (args.length == 1) {
  41. Player target = (Player) Bukkit.getServer().getPlayer(
  42. args[0]);
  43. try {
  44. if (target != null) {
  45. if (p.hasPermission("skyblock.fliegen.andere")) {
  46. if (target.getAllowFlight() == true) {
  47. target.setFlying(false);
  48. target.setAllowFlight(false);
  49. target.sendMessage(plugin.skyburn
  50. + "Du kannst nun nicht mehr Fliegen.");
  51. p.sendMessage(plugin.skyburn
  52. + "Der Spieler §c"
  53. + target.getDisplayName()
  54. + " §7kann nun nicht mehr Fliegen.");
  55. } else if (target.getAllowFlight() == false) {
  56. target.setAllowFlight(true);
  57. target.sendMessage(plugin.skyburn
  58. + "Du kannst nun Fliegen.");
  59. p.sendMessage(plugin.skyburn
  60. + "Der Spieler §c"
  61. + target.getDisplayName()
  62. + " §7kann nun Fliegen.");
  63. }
  64. } else {
  65. p.sendMessage(plugin.no_perm);
  66. }
  67. } else {
  68. p.sendMessage(plugin.no_target);
  69. }
  70. } catch (NullPointerException ex) {
  71. ex.printStackTrace();
  72. }
  73. } else {
  74. p.sendMessage(plugin.wrong_syntax);
  75. }
  76. } else {
  77. p.sendMessage(plugin.no_perm);
  78. }
  79. }
  80. return true;
  81. }
  82. return false;
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement