UserInfo와 UserInfoArray에서 Group 관련 호출 method 변경 To Do: 1. UserInfoArray *UserPartyUUID -> *UserGroupUUID 변경 2. GroupArray, PartyArray, PartyEventHandler 호출 method 이름 변경Group_System
parent
6bbf4c8713
commit
b26bb99496
5 changed files with 128 additions and 31 deletions
@ -0,0 +1,103 @@ |
||||
package org.poopki.duckdns.user_db; |
||||
|
||||
import org.bukkit.Bukkit; |
||||
|
||||
import java.util.*; |
||||
|
||||
public class GroupArray { |
||||
private static Map<UUID, Group> m_GroupArray = new HashMap<UUID, Group>(); |
||||
|
||||
private static Map<String, UUID> m_GroupNameList = new HashMap<String, UUID>(); |
||||
|
||||
UserInfoArray m_UserInfoArray; |
||||
|
||||
public GroupArray(UserInfoArray m_UIA){ |
||||
m_UserInfoArray = m_UIA; |
||||
} |
||||
public boolean CreateGroup(UUID GroupUUID, String Name, UUID PlayerUUID){ |
||||
if(m_GroupNameList.containsKey(Name)){ |
||||
return false; // Conflict
|
||||
} else{ |
||||
m_GroupArray.put(GroupUUID, new Group(Name, PlayerUUID)); |
||||
m_GroupNameList.put(Name, GroupUUID); |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public boolean DeleteGroup(UUID GroupUUID){ |
||||
if(m_GroupArray.containsKey(GroupUUID)){ |
||||
for(UUID key: GetGroupMembersUUID(GroupUUID)){ |
||||
m_UserInfoArray.setUserPartyUUID(key, new UUID(0,0)); |
||||
} |
||||
|
||||
m_GroupNameList.remove(GetGroupName(GroupUUID)); |
||||
m_GroupArray.remove(GroupUUID); |
||||
return true; |
||||
} |
||||
else{ |
||||
return false; // Group is not exists.
|
||||
} |
||||
|
||||
} |
||||
|
||||
public Integer SignUpGroup(UUID GroupUUID, UUID PlayerUUID){ |
||||
if(m_GroupArray.containsKey(GroupUUID)){ |
||||
if(isOffline(PlayerUUID)){ |
||||
Group m_Group = m_GroupArray.get(GroupUUID); |
||||
m_Group.SignUp(PlayerUUID); |
||||
m_UserInfoArray.setUserPartyUUID(PlayerUUID,GroupUUID); |
||||
return 1; // Success
|
||||
}else{ |
||||
return 2; // Offline Player
|
||||
} |
||||
} else{ |
||||
return 3; // Wrong Group
|
||||
} |
||||
} |
||||
|
||||
public boolean ExpulsionGroupPlayer(UUID GroupUUID, UUID PlayerUUID){ |
||||
if(GetGroupMembersName(GroupUUID).contains(PlayerUUID)) { |
||||
Group m_Group = m_GroupArray.get(GroupUUID); |
||||
m_Group.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> GetGroupMembersName(UUID GroupUUID){ |
||||
List<String> MembersName = new ArrayList<>(); |
||||
for (UUID key : m_GroupArray.get(GroupUUID).getGroupMembers()){ |
||||
MembersName.add(Bukkit.getPlayer(key).getDisplayName()); |
||||
} |
||||
return MembersName; |
||||
} |
||||
public List<UUID> GetGroupMembersUUID(UUID GroupUUID){ |
||||
return m_GroupArray.get(GroupUUID).getGroupMembers(); |
||||
} |
||||
public boolean isGroupMember(UUID GroupUUID, UUID PlayerUUID){ |
||||
Group m_Group = m_GroupArray.get(GroupUUID); |
||||
return m_Group.isMember(PlayerUUID); |
||||
} |
||||
|
||||
public Set<String> GetGroupNameList(){ |
||||
return m_GroupNameList.keySet(); |
||||
} |
||||
|
||||
|
||||
public String GetGroupName(UUID GroupUUID){ |
||||
Group m_Group = m_GroupArray.get(GroupUUID); |
||||
return m_Group.getGroupName(); |
||||
} |
||||
public static boolean isOffline(UUID uuid){ |
||||
return Bukkit.getPlayer(uuid).equals(null) && !Bukkit.getOfflinePlayer(uuid).equals(null); |
||||
} |
||||
|
||||
private boolean isAvaliableGroup(UUID GroupUUID){ |
||||
return m_GroupArray.containsKey(GroupUUID); |
||||
} |
||||
|
||||
} |
@ -1,40 +1,29 @@ |
||||
package org.poopki.duckdns.user_db; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import java.util.UUID; |
||||
import java.util.*; |
||||
|
||||
public class UserInfo extends Status { |
||||
private UUID m_UUID; |
||||
private String m_Name; |
||||
|
||||
private static Map<String, Integer> m_status = new HashMap<String, Integer>(); |
||||
|
||||
private int m_Nation; |
||||
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 초기화
|
||||
private static Map<String, UUID> m_GroupUUID = new HashMap<String, UUID>(); |
||||
public UserInfo(UUID uuid, String Name, UUID Nation, UUID Squad, UUID Farm, UUID Party){ //UserInfo 초기화
|
||||
super(100,100,1,10,10,10,10); |
||||
m_UUID = uuid; |
||||
m_Name = Name; |
||||
m_Nation = Nation; |
||||
m_Squad = Squad; |
||||
m_Farm = Farm; |
||||
} |
||||
|
||||
public void JoinNation(int Nation) { m_Nation = Nation; } |
||||
public void JoinSquad(int Squad) { m_Squad = Squad; } |
||||
public void JoinFarm(int Farm) { m_Farm = Farm; } |
||||
m_GroupUUID.put("Nation", Nation); |
||||
m_GroupUUID.put("Squad", Squad); |
||||
m_GroupUUID.put("Farm", Farm); |
||||
m_GroupUUID.put("Party", Party); |
||||
} |
||||
|
||||
public void SetGroupUUID(String GroupType, UUID m_UUID){ m_GroupUUID.put(GroupType, m_UUID); } |
||||
public UUID GetGroupUUID(String GroupType){ return m_GroupUUID.get(GroupType); } |
||||
public String getUserName(){ |
||||
return m_Name; |
||||
} |
||||
|
||||
public UUID getUserUUID(){ return m_UUID; } |
||||
public UUID getPartyUUID(){ return m_Party; } |
||||
public void setPartyUUID(UUID uuid){ m_Party = uuid; } |
||||
|
||||
} |
||||
|
Loading…
Reference in new issue