Advertisement
Guest User

Untitled

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