diff --git a/Group.java b/Group.java new file mode 100644 index 0000000..38f7b7e --- /dev/null +++ b/Group.java @@ -0,0 +1,38 @@ +package org.poopki.duckdns.user_db; + +import java.util.List; +import java.util.ArrayList; +import java.util.UUID; + +public class Group { + private String m_Name; + private List m_MemberList = new ArrayList<>(); + + public Group(String Name, UUID uuid){ + m_MemberList.add(0, uuid); + m_Name = Name; + } + + public void SignUp(UUID uuid){ + m_MemberList.add(uuid); + } + + public void Expulsion(UUID uuid){ + m_MemberList.remove(uuid); + } + + public boolean isMember(UUID uuid){ + return m_MemberList.contains(uuid); + } + + public List getGroupMembers(){ return m_MemberList;} + public String getGroupName(){ return m_Name; } + + public boolean isOwner(UUID uuid){ + if(m_MemberList.get(0)==uuid){ + return true; + }else{ + return false; + } + } +} diff --git a/Party.java b/Party.java new file mode 100644 index 0000000..81f8a6c --- /dev/null +++ b/Party.java @@ -0,0 +1,11 @@ +package org.poopki.duckdns.user_db; + +import java.util.UUID; + +public class Party extends Group{ + + public Party(String Name, UUID uuid) { + super(Name, uuid); + } + +} diff --git a/PartyArray.java b/PartyArray.java new file mode 100644 index 0000000..8d1ed62 --- /dev/null +++ b/PartyArray.java @@ -0,0 +1,46 @@ +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(); + public void CreateParty(UUID PartyUUID, String Name, UUID PlayerUUID){ + m_PartyArray.put(PartyUUID, new Party(Name, PlayerUUID)); + m_PartyNameList.put(Name, PartyUUID); + } + + public void SignUpParty(UUID PartyUUID, UUID PlayerUUID){ + Party m_Party = m_PartyArray.get(PartyUUID); + m_Party.SignUp(PlayerUUID); + } + + public void ExpulsionParty(UUID PartyUUID, UUID PlayerUUID){ + Party m_Party = m_PartyArray.get(PartyUUID); + m_Party.Expulsion(PlayerUUID); + } + + public List GetPartyMembers(UUID PartyUUID){ + List MembersName = new ArrayList<>(); + for (UUID key : m_PartyArray.get(PartyUUID).getGroupMembers()){ + MembersName.add(Bukkit.getPlayer(key).getDisplayName()); + } + return MembersName; + } + 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(); + } +} diff --git a/PartyEventHandler.java b/PartyEventHandler.java new file mode 100644 index 0000000..14ce2be --- /dev/null +++ b/PartyEventHandler.java @@ -0,0 +1,59 @@ +package org.poopki.duckdns.user_db; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.UUID; + +public class PartyEventHandler implements CommandExecutor { + + PartyArray m_PartyArray; + UserInfoArray m_UserInfoArray; + + public PartyEventHandler(PartyArray PA, UserInfoArray UIA){ + m_PartyArray = PA; + m_UserInfoArray = UIA; + } + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + Player p = (Player) sender; + + if (args.length != 0) { + switch (args[0]) { + case "생성":{ + UUID tempUUID = UUID.randomUUID(); + m_PartyArray.CreateParty(tempUUID, args[1], p.getUniqueId()); + m_UserInfoArray.setUserPartyUUID(p.getUniqueId(), tempUUID); + p.sendMessage(args[1]+"파티가 생성되었습니다."); + p.sendMessage("멤버 목록: "); + for (String Name: m_PartyArray.GetPartyMembers(tempUUID)){ + p.sendMessage(Name); + } + p.sendMessage("파티 목록:"); + for (String Name: m_PartyArray.GetPartyNameList()){ + p.sendMessage(Name); + } + break; + } + /* case "가입":{ + + break; + } + case "초대":{ + break; + } + case "강퇴":{ + + break; + } +*/ case "이름":{ + p.sendMessage("현재 파티 이름"+m_PartyArray.GetPartyName(m_UserInfoArray.getUserPartyUUID(p.getUniqueId()))); + break; + } + } + } + return true; + } +} diff --git a/Status.java b/Status.java index 0ff7531..90e8c60 100644 --- a/Status.java +++ b/Status.java @@ -26,4 +26,6 @@ public class Status { m_INT = INT; m_LUK = LUK; } + + public int GetHP(){return m_HP;} } diff --git a/UserInfo.java b/UserInfo.java index 9930e9e..7519067 100644 --- a/UserInfo.java +++ b/UserInfo.java @@ -14,6 +14,8 @@ public class UserInfo extends Status { private int m_Squad; private int m_Farm; + private UUID m_Party; + public UserInfo(UUID uuid, String Name, int Nation, int Squad, int Farm){ //UserInfo 초기화 super(100,100,1,10,10,10,10); m_UUID = uuid; @@ -32,6 +34,7 @@ public class UserInfo extends Status { } public UUID getUserUUID(){ return m_UUID; } - + public UUID getPartyUUID(){ return m_Party; } + public void setPartyUUID(UUID uuid){ m_Party = uuid; } } diff --git a/UserInfoArray.java b/UserInfoArray.java index b374685..dafa328 100644 --- a/UserInfoArray.java +++ b/UserInfoArray.java @@ -17,7 +17,15 @@ public class UserInfoArray { public Set getKeySet(){ // 유저 목록 return return m_UserInfoArray.keySet(); } + public UUID getUserPartyUUID(UUID uuid){ + return m_UserInfoArray.get(uuid).getPartyUUID(); + } + + public void setUserPartyUUID(UUID PlayerUUID, UUID PartyUUID){ + m_UserInfoArray.get(PlayerUUID).setPartyUUID(PartyUUID); + } public void putUserInfo(UUID uuid,String Name, int Nation, int Squad, int Farm) { // UserInfoArray entry 입력 m_UserInfoArray.put(uuid, new UserInfo(uuid,Name, Nation, Squad, Farm)); } + } \ No newline at end of file diff --git a/User_DB.java b/User_DB.java index 6bdbed9..5f211dd 100644 --- a/User_DB.java +++ b/User_DB.java @@ -11,6 +11,7 @@ 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 생성 @@ -25,6 +26,7 @@ public final class User_DB extends JavaPlugin implements Listener { throw new RuntimeException(e); } getCommand("계좌").setExecutor(new AccountEventHandler(m_AccountArrayInstance)); + getCommand("파티").setExecutor(new PartyEventHandler(m_PartyArrayInstance, m_InfoArrayInstance)); getServer().getPluginManager().registerEvents(new UserJoin(m_InfoArrayInstance, m_AccountArrayInstance),this); }