Advertisement
Guest User

Untitled

a guest
Aug 6th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. package me.eml.phl.utils;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.UUID;
  7.  
  8. import org.bukkit.ChatColor;
  9. import org.bukkit.entity.Player;
  10.  
  11. public class HitlistManager {
  12. public HashMap<UUID, List<UUID>> hitlistMap = new HashMap<UUID, List<UUID>>();
  13. private String prefix = ChatColor.GOLD + "[PHL] ";
  14.  
  15. public void addToHitlist(Player playerAdding, Player playerAdded) {
  16. if (playerAdded.isOnline()) {
  17. UUID uuidOfAdding = playerAdding.getUniqueId();
  18. UUID uuidOfAdded = playerAdded.getUniqueId();
  19.  
  20. if (!hitlistMap.containsKey(uuidOfAdding)) {
  21. hitlistMap.put(uuidOfAdding, new ArrayList<UUID>());
  22. hitlistMap.get(uuidOfAdding).add(uuidOfAdded);
  23. playerAdding.sendMessage(prefix + ChatColor.GREEN
  24. + playerAdded.getDisplayName()
  25. + " has been added to your hitlist!");
  26. } else {
  27. playerAdding.sendMessage(prefix + ChatColor.GREEN
  28. + playerAdded.getDisplayName()
  29. + " is already on your hitlist!");
  30. }
  31. }
  32. }
  33.  
  34. public void removeFromHitlist(Player playerRemoving, Player playerRemoved) {
  35. if (playerRemoved.isOnline()) {
  36. UUID uuidOfRemoving = playerRemoving.getUniqueId();
  37. UUID uuidOfRemoved = playerRemoved.getUniqueId();
  38.  
  39. if (hitlistMap.containsKey(uuidOfRemoving)) {
  40. if (hitlistMap.get(uuidOfRemoving).contains(uuidOfRemoved))
  41. hitlistMap.get(uuidOfRemoving).remove(uuidOfRemoved);
  42. playerRemoving.sendMessage(prefix + ChatColor.GREEN
  43. + playerRemoved.getDisplayName()
  44. + " has been removed from your hitlist.");
  45. } else {
  46. playerRemoving.sendMessage(prefix + ChatColor.GREEN
  47. + playerRemoved.getDisplayName()
  48. + " is not on your hitlist.");
  49. }
  50. }
  51. }
  52.  
  53. public void listPlayersOnHitlist(Player playerChecking) {
  54. UUID uuidOfPlayerChecking = playerChecking.getUniqueId();
  55. playerChecking.sendMessage(prefix + ChatColor.GREEN
  56. + hitlistMap.get(uuidOfPlayerChecking));
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement