Advertisement
Guest User

TempFly source

a guest
Aug 23rd, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. package me.Da_Pepsi_Monster.TempFly;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9. import org.bukkit.potion.PotionEffect;
  10. import org.bukkit.potion.PotionEffectType;
  11.  
  12. public class main extends JavaPlugin
  13. {
  14. public boolean onCommand(CommandSender theSender, Command cmd, String commandLabel, String[] args)
  15. {
  16. if(theSender instanceof Player)
  17. {
  18. final Player player = (Player) theSender;
  19.  
  20. if(commandLabel.equalsIgnoreCase("tempfly"))
  21. {
  22. try
  23. {
  24. if(args[0].equalsIgnoreCase("version"))
  25. {
  26. player.sendMessage(ChatColor.GOLD + " TempFly " + ChatColor.GREEN + "v1.0 " + ChatColor.GRAY + "plugin developed by " + ChatColor.GREEN + "Da_Pepsi_Monster");
  27. }
  28. else if(args[0].equalsIgnoreCase("ver"))
  29. {
  30. player.sendMessage(ChatColor.GOLD + " TempFly " + ChatColor.GREEN + "v1.0 " + ChatColor.GRAY + "plugin developed by " + ChatColor.GREEN + "Da_Pepsi_Monster");
  31. }
  32. else if(args[0].equalsIgnoreCase("use"))
  33. {
  34. if(player.hasPermission("tempfly.use"))
  35. {
  36. player.sendMessage(ChatColor.AQUA + "You have been given flight for 15 seconds!");
  37. player.setAllowFlight(true);
  38. player.setFlying(true);
  39. player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 30, 5));
  40. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  41. {
  42. public void run()
  43. {
  44. player.sendMessage(ChatColor.AQUA + "Flight disabled! You have 15 seconds to land safely.");
  45. player.setAllowFlight(false);
  46. player.setFlying(false);
  47. }
  48. }, 20 * 15);
  49. }
  50. else player.sendMessage(ChatColor.RED + "You do not have permission: " + ChatColor.WHITE + "tempfly.use");
  51. }
  52. }
  53. catch (Exception exception)
  54. {
  55. player.sendMessage(ChatColor.RED + " Invalid Argument");
  56. }
  57. }
  58. }
  59. return true;
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement