diff --git a/PartyArray.java b/PartyArray.java index 8d1ed62..edf77ea 100644 --- a/PartyArray.java +++ b/PartyArray.java @@ -8,28 +8,76 @@ public class PartyArray { private static Map m_PartyArray = new HashMap(); private static Map m_PartyNameList = new HashMap(); - public void CreateParty(UUID PartyUUID, String Name, UUID PlayerUUID){ - m_PartyArray.put(PartyUUID, new Party(Name, PlayerUUID)); - m_PartyNameList.put(Name, PartyUUID); + + 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 void SignUpParty(UUID PartyUUID, UUID PlayerUUID){ - Party m_Party = m_PartyArray.get(PartyUUID); - m_Party.SignUp(PlayerUUID); + 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 void ExpulsionParty(UUID PartyUUID, UUID PlayerUUID){ - Party m_Party = m_PartyArray.get(PartyUUID); - m_Party.Expulsion(PlayerUUID); + 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 List GetPartyMembers(UUID PartyUUID){ + 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); @@ -39,8 +87,17 @@ public class PartyArray { 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); + } + } diff --git a/PartyEventHandler.java b/PartyEventHandler.java index 14ce2be..3318819 100644 --- a/PartyEventHandler.java +++ b/PartyEventHandler.java @@ -28,7 +28,7 @@ public class PartyEventHandler implements CommandExecutor { m_UserInfoArray.setUserPartyUUID(p.getUniqueId(), tempUUID); p.sendMessage(args[1]+"파티가 생성되었습니다."); p.sendMessage("멤버 목록: "); - for (String Name: m_PartyArray.GetPartyMembers(tempUUID)){ + for (String Name: m_PartyArray.GetPartyMembersName(tempUUID)){ p.sendMessage(Name); } p.sendMessage("파티 목록:"); diff --git a/User_DB.java b/User_DB.java index 5f211dd..7ff3078 100644 --- a/User_DB.java +++ b/User_DB.java @@ -11,9 +11,8 @@ import java.sql.Statement; public final class User_DB extends JavaPlugin implements Listener { AccountArray m_AccountArrayInstance = new AccountArray(); - PartyArray m_PartyArrayInstance = new PartyArray(); UserInfoArray m_InfoArrayInstance = new UserInfoArray(); // UserInfo저장하는 Array instance 생성 - + PartyArray m_PartyArrayInstance = new PartyArray(m_InfoArrayInstance); DBUpdate Database_backup = new DBUpdate(m_InfoArrayInstance, m_AccountArrayInstance); @Override