Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.eml.phl.utils;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.UUID;
- import org.bukkit.ChatColor;
- import org.bukkit.entity.Player;
- public class HitlistManager {
- public Map<UUID, List<UUID>> hitlistMap = new HashMap<UUID, List<UUID>>();
- private String prefix = ChatColor.GOLD + "[PHL] ";
- public void addToHitlist(Player playerAdding, Player playerAdded) {
- if (playerAdded.isOnline()) {
- UUID uuidOfAdding = playerAdding.getUniqueId();
- UUID uuidOfAdded = playerAdded.getUniqueId();
- List<UUID> uuidList = hitlistMap.get(uuidOfAdding);
- if (uuidList == null || (!uuidList.contains(uuidOfAdded))) {
- List<UUID> newUuidList = new ArrayList<UUID>();
- newUuidList.add(uuidOfAdded);
- hitlistMap.remove(uuidOfAdding);
- hitlistMap.put(uuidOfAdding, newUuidList);
- playerAdding.sendMessage(prefix + ChatColor.GREEN
- + playerAdded.getDisplayName()
- + " has been added to your hitlist!");
- } else {
- playerAdding.sendMessage(prefix + ChatColor.RED
- + playerAdded.getDisplayName()
- + " is already on your hitlist!");
- }
- }
- }
- public void removeFromHitlist(Player playerRemoving, Player playerRemoved) {
- if (playerRemoved.isOnline()) {
- UUID uuidOfRemoving = playerRemoving.getUniqueId();
- UUID uuidOfRemoved = playerRemoved.getUniqueId();
- List<UUID> uuidList = hitlistMap.get(uuidOfRemoving);
- if (uuidList == null || (!uuidList.contains(uuidOfRemoved))) {
- List<UUID> newUuidList = new ArrayList<UUID>();
- newUuidList.add(uuidOfRemoved);
- hitlistMap.remove(uuidOfRemoving);
- hitlistMap.put(uuidOfRemoving, newUuidList);
- playerRemoving.sendMessage(prefix + ChatColor.GREEN
- + playerRemoved.getDisplayName()
- + " has been removed from your hitlist!");
- } else {
- playerRemoving.sendMessage(prefix + ChatColor.RED
- + playerRemoved.getDisplayName()
- + " is not on your hitlist!");
- }
- }
- }
- public void listPlayersOnHitlist(Player playerChecking) {
- UUID uuidOfPlayerChecking = playerChecking.getUniqueId();
- List<UUID> uuidList = hitlistMap.get(uuidOfPlayerChecking);
- playerChecking.sendMessage(prefix + ChatColor.GREEN + uuidList);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement