You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.3 KiB

package org.poopki.duckdns.user_db;
import org.bukkit.Bukkit;
import java.util.*;
public class PartyArray {
private static Map<UUID, Party> m_PartyArray = new HashMap<UUID, Party>();
private static Map<String, UUID> m_PartyNameList = new HashMap<String, UUID>();
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("Party",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("Party",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<String> GetPartyMembersName(UUID PartyUUID){
List<String> MembersName = new ArrayList<>();
for (UUID key : m_PartyArray.get(PartyUUID).getGroupMembers()){
MembersName.add(Bukkit.getPlayer(key).getDisplayName());
}
return MembersName;
}
public List<UUID> 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<String> 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);
}
}