package org.poopki.duckdns.user_db; import org.bukkit.Bukkit; import java.util.*; public class PartyArray { private static Map m_PartyArray = new HashMap(); private static Map m_PartyNameList = new HashMap(); UserInfoArray m_UserInfoArray; public PartyArray(UserInfoArray m_UIA){ m_UserInfoArray = m_UIA; } public boolean CreateParty(UUID PartyUUID, String Name, UUID PlayerUUID){ if(m_PartyNameList.containsKey(Name)){ return false; // Conflict } else{ m_PartyArray.put(PartyUUID, new Party(Name, PlayerUUID)); m_PartyNameList.put(Name, PartyUUID); return true; } } public boolean DeleteParty(UUID PartyUUID){ if(m_PartyArray.containsKey(PartyUUID)){ for(UUID key: GetPartyMembersUUID(PartyUUID)){ m_UserInfoArray.setUserPartyUUID(key, new UUID(0,0)); } m_PartyNameList.remove(GetPartyName(PartyUUID)); m_PartyArray.remove(PartyUUID); return true; } else{ return false; // Party is not exists. } } public Integer SignUpParty(UUID PartyUUID, UUID PlayerUUID){ if(m_PartyArray.containsKey(PartyUUID)){ if(isOffline(PlayerUUID)){ Party m_Party = m_PartyArray.get(PartyUUID); m_Party.SignUp(PlayerUUID); m_UserInfoArray.setUserPartyUUID(PlayerUUID,PartyUUID); return 1; // Success }else{ return 2; // Offline Player } } else{ return 3; // Wrong Party } } public boolean ExpulsionPartyPlayer(UUID PartyUUID, UUID PlayerUUID){ if(GetPartyMembersName(PartyUUID).contains(PlayerUUID)) { Party m_Party = m_PartyArray.get(PartyUUID); m_Party.Expulsion(PlayerUUID); return true; } else{ return false; // Wrong Player Name. FIXME{Need Checking function for a validate user name's } /* Player op = Bukkit.getPlayer(args[1]); if (op != null) { */ } } public List GetPartyMembersName(UUID PartyUUID){ List MembersName = new ArrayList<>(); for (UUID key : m_PartyArray.get(PartyUUID).getGroupMembers()){ MembersName.add(Bukkit.getPlayer(key).getDisplayName()); } return MembersName; } public List GetPartyMembersUUID(UUID PartyUUID){ return m_PartyArray.get(PartyUUID).getGroupMembers(); } public boolean isPartyMember(UUID PartyUUID, UUID PlayerUUID){ Party m_Party = m_PartyArray.get(PartyUUID); return m_Party.isMember(PlayerUUID); } public Set GetPartyNameList(){ return m_PartyNameList.keySet(); } public String GetPartyName(UUID PartyUUID){ Party m_Party = m_PartyArray.get(PartyUUID); return m_Party.getGroupName(); } public static boolean isOffline(UUID uuid){ return Bukkit.getPlayer(uuid).equals(null) && !Bukkit.getOfflinePlayer(uuid).equals(null); } private boolean isAvaliableParty(UUID PartyUUID){ return m_PartyArray.containsKey(PartyUUID); } }