Guest User

need help java eclipse

a guest
Apr 13th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. package me.rileys.easyhugs;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11.  
  12. public class Easyhugs extends JavaPlugin {
  13.  
  14. public void onEnable() {
  15.  
  16. ArrayList<Player> cooldown = new ArrayList<Player>();
  17.  
  18. Bukkit.getServer().getLogger().info("Easyhugs" + this.getDescription().getVersion() + " has been enabled!");
  19. }
  20.  
  21. public void onDisable() {
  22. Bukkit.getServer().getLogger().info("Easyhugs" + this.getDescription().getVersion() + " has been disabled!");
  23. }
  24.  
  25. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  26. if (cmd.getName().equalsIgnoreCase("hug")) {
  27. if (!sender.hasPermission("easyhugs.hug")) {
  28. sender.sendMessage(ChatColor.RED + "You are not permitted to do this!");
  29. return true;
  30. }
  31. Object p;
  32. if (cooldown.contains(p)) {
  33. p.sendMessage(ChatColor.DARK_RED + "Error: You cannot get another kit yet, Relog to be able to use this kit again!");
  34. return true;
  35. }
  36.  
  37. if (args.length == 0) {
  38. sender.sendMessage(ChatColor.LIGHT_PURPLE + "Please specify the Player you wish to Hug!");
  39. return true;
  40. }
  41. Player target = Bukkit.getServer().getPlayer(args[0]);
  42. if (target == null) {
  43. sender.sendMessage(ChatColor.RED + "Could not find player " + args[0] + ".");
  44. return true;
  45. }
  46. target.sendMessage(ChatColor.LIGHT_PURPLE + "You Have been Hugged by, " + ChatColor.AQUA.toString() + sender.getName());
  47. sender.sendMessage(ChatColor.GREEN + "You have Hugged, " + ChatColor.AQUA.toString() + target.getName() + ChatColor.LIGHT_PURPLE.toString() + ", Awwww.");
  48. cooldown.add(p);
  49. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
  50. public void run() {
  51. cooldown.remove(p);
  52. }
  53. }, 1000);
  54. return true;
  55. }
  56. else {
  57. p.sendMessage(ChatColor.DARK_RED + "Error: You cannot get a kit at this time.");
  58. return true;
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment