From 6bbf4c87138ad8d69229b36a4572a959a96f6975 Mon Sep 17 00:00:00 2001 From: poopki Date: Tue, 19 Jul 2022 00:17:29 +0900 Subject: [PATCH] =?UTF-8?q?To=20Do:=20PartyArray=EB=A5=BC=20GroupArray?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20=ED=9B=84=20=EC=83=81=EC=86=8D?= =?UTF-8?q?=ED=95=98=EC=97=AC=20=EC=82=AC=EC=9A=A9=ED=95=98=EA=B2=8C?= =?UTF-8?q?=EB=81=94=20=EB=B3=80=EA=B2=BD=20=ED=95=84=EC=9A=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PartyArray.java | 77 ++++++++++++++++++++++++++++++++++++------ PartyEventHandler.java | 2 +- User_DB.java | 3 +- 3 files changed, 69 insertions(+), 13 deletions(-) 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