PartyArray를 GroupArray로 변경 완료

UserInfo와 UserInfoArray에서 Group 관련 호출 method 변경
To Do:
1. UserInfoArray *UserPartyUUID -> *UserGroupUUID 변경
2. GroupArray, PartyArray, PartyEventHandler 호출 method 이름 변경
Group_System
poopki 3 years ago
parent 6bbf4c8713
commit b26bb99496
  1. 7
      DB/DBUpdate.java
  2. 103
      GroupArray.java
  3. 31
      UserInfo.java
  4. 14
      UserInfoArray.java
  5. 4
      UserJoin.java

@ -73,9 +73,10 @@ public class DBUpdate {
while(rs.next()){
m_InfoArrayInstance.putUserInfo(UUID.fromString(rs.getString(1)),
rs.getString(2),
Integer.parseInt(rs.getString(3)),
Integer.parseInt(rs.getString(4)),
Integer.parseInt(rs.getString(5)));
UUID.fromString(rs.getString(3)),
UUID.fromString(rs.getString(4)),
UUID.fromString(rs.getString(5)),
new UUID(0,0));
m_AccountArray.putAccountInfo(UUID.fromString(rs.getString(1)),Integer.parseInt(rs.getString(6)));
}

@ -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; }
}

@ -17,15 +17,17 @@ public class UserInfoArray {
public Set<UUID> getKeySet(){ // 유저 목록 return
return m_UserInfoArray.keySet();
}
public UUID getUserPartyUUID(UUID uuid){
return m_UserInfoArray.get(uuid).getPartyUUID();
public UUID getUserPartyUUID(UUID PlayerUUID, String GroupType){
return m_UserInfoArray.get(PlayerUUID).GetGroupUUID(GroupType);
}
public void setUserPartyUUID(UUID PlayerUUID, UUID PartyUUID){
m_UserInfoArray.get(PlayerUUID).setPartyUUID(PartyUUID);
public void setUserPartyUUID(String GroupType, UUID PlayerUUID, UUID PartyUUID){
m_UserInfoArray.get(PlayerUUID).SetGroupUUID(GroupType,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));
public void putUserInfo(UUID uuid,String Name, UUID Nation, UUID Squad, UUID Farm, UUID Party) { // UserInfoArray entry 입력
m_UserInfoArray.put(uuid, new UserInfo(uuid,Name, Nation, Squad, Farm, Party));
}
}

@ -4,6 +4,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.UUID;
public class UserJoin implements Listener {
private UserInfoArray m_InfoArrayInstance;
private AccountArray m_AccountArray;
@ -15,7 +17,7 @@ public class UserJoin implements Listener {
public void PlayerLogin(PlayerJoinEvent e) {
Player p = e.getPlayer();
if(!m_InfoArrayInstance.checkNewUser(p.getUniqueId())){ //새로운 user인 경우 array에 등록
m_InfoArrayInstance.putUserInfo(p.getUniqueId(), p.getName(), 0, 0, 0);
m_InfoArrayInstance.putUserInfo(p.getUniqueId(), p.getName(), new UUID(0,0), new UUID(0,0), new UUID(0,0), new UUID(0,0));
m_AccountArray.putAccountInfo(p.getUniqueId(), 0);
}
}

Loading…
Cancel
Save