parent
fb2661d9f8
commit
71a5aa8e8c
8 changed files with 170 additions and 1 deletions
@ -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<UUID> 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<UUID> 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; |
||||
} |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,46 @@ |
||||
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>(); |
||||
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<String> GetPartyMembers(UUID PartyUUID){ |
||||
List<String> 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<String> GetPartyNameList(){ |
||||
return m_PartyNameList.keySet(); |
||||
} |
||||
|
||||
public String GetPartyName(UUID PartyUUID){ |
||||
Party m_Party = m_PartyArray.get(PartyUUID); |
||||
return m_Party.getGroupName(); |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
Loading…
Reference in new issue