From b3e5851b05d80b8b0beff16758a7cad2f953f840 Mon Sep 17 00:00:00 2001 From: poopki Date: Thu, 12 Jan 2023 02:43:57 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B6=84=EB=8C=80=20=EC=8B=9C=EC=8A=A4?= =?UTF-8?q?=ED=85=9C=20=EC=B6=94=EA=B0=80=20=EC=B4=88=EB=8C=80=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Array/AccountEventHandler.java | 140 +++++++-------- Array/FarmEventHandler.java | 301 ++++++++++++++++--------------- Array/GroupArray.java | 10 +- Array/NationEventHandler.java | 311 ++++++++++++++++++--------------- Array/Squad.java | 10 ++ Array/SquadArray.java | 9 + Array/SquadEventHandler.java | 292 +++++++++++++++++++++++++++++++ DB/DBUpdate.java | 130 ++++++++++++-- GUI/BaseGUI.java | 19 +- GUI/ItemManager.java | 3 +- GUI/OpenInv.java | 9 +- Invite/InviteMaster.java | 164 +++++++++++------ SquadEventHandler.java | 61 ------- UserInfo.java | 2 +- UserInfoArray.java | 4 +- User_DB.java | 16 +- 16 files changed, 976 insertions(+), 505 deletions(-) create mode 100644 Array/Squad.java create mode 100644 Array/SquadArray.java create mode 100644 Array/SquadEventHandler.java delete mode 100644 SquadEventHandler.java diff --git a/Array/AccountEventHandler.java b/Array/AccountEventHandler.java index d8184be..d548efb 100644 --- a/Array/AccountEventHandler.java +++ b/Array/AccountEventHandler.java @@ -12,7 +12,7 @@ import java.util.UUID; public class AccountEventHandler implements CommandExecutor { AccountArray m_AccountArray; UserInfoArray m_UserInfoArray; - public AccountEventHandler(AccountArray AA, UserInfoArray UIA){ + public AccountEventHandler(UserInfoArray UIA, AccountArray AA){ m_AccountArray = AA; m_UserInfoArray = UIA; } @@ -30,89 +30,85 @@ public class AccountEventHandler implements CommandExecutor { if (args.length != 0) { switch (args[0]) { - case "설정": { - if (p.isOp()) { - if (args.length > 1) { - if (args[1] != null) { - UUID op = m_UserInfoArray.getUserUUID(args[1]); + case "설정":{ + if (!p.isOp()) { + p.sendMessage("관리자만 실행 가능한 명령어입니다."); + return false; + } + if (args.length < 1) { + p.sendMessage("설정 대상이 지정되지 않았습니다."); + return false; + } + UUID op = m_UserInfoArray.getUserUUID(args[1]); + if (op == null) { + p.sendMessage("잘못된 계좌입니다."); + return false; + } + if (args.length < 2) { + p.sendMessage("설정 금액을 입력해주세요."); + return false; + } + if (!isStringDouble(args[2])) { + p.sendMessage("설정 금액은 숫자만 가능합니다."); + return false; + } + if(m_AccountArray.getAccountInfo(op)+Long.parseLong(args[2])>2147483647){ + p.sendMessage("최대 금액 이상으로 설정할 수 없습니다."); + return false; + } + m_AccountArray.setAccountInfo(m_UserInfoArray.getUserUUID(args[1]), Long.parseLong(args[2])); + p.sendMessage(args[1] + "님의 잔액을 " + Integer.parseInt(args[2]) + "원으로 설정하였습니다."); + break; + } - if (op != null) { - if (args.length > 2) { - if (isStringDouble(args[2])) { - if(m_AccountArray.setAccountInfo(m_UserInfoArray.getUserUUID(args[1]), Long.parseLong(args[2]))){ - p.sendMessage(args[1] + "님의 잔액을 " + Integer.parseInt(args[2]) + "원으로 설정하였습니다."); - } else{ - p.sendMessage("최대 금액 이상으로 설정할 수 없습니다."); - } - } else { - p.sendMessage("설정 금액은 숫자만 가능합니다."); - } - } else { - p.sendMessage("설정 금액을 입력해주세요."); - } - } else { - p.sendMessage("잘못된 계좌입니다."); - } - } - }else{ - p.sendMessage("설정 대상이 지정되지 않았습니다."); + case "입금": { + if (args.length < 1) { + p.sendMessage("이체 대상이 지정되지 않았습니다."); + return false; + } + UUID op = m_UserInfoArray.getUserUUID(args[1]); + if (op == null) { + p.sendMessage("잘못된 계좌입니다."); + return false; + } + if (args.length < 2) { + p.sendMessage("이체 금액을 입력해주세요."); + return false; + } + if (!isStringDouble(args[2])) { + p.sendMessage("이체 금액은 숫자만 가능합니다."); + return false; + } + if(p.getUniqueId() == op) { + p.sendMessage("자기 자신에게는 이체할 수 없습니다."); + return false; + } + switch(m_AccountArray.transfer(p.getUniqueId(), op, Long.parseLong(args[2]))) + { + case 1: { + p.sendMessage(args[1] + "농장에 " + Integer.parseInt(args[2]) + "원을 이체하였습니다."); + break; + } + case 2: { + p.sendMessage("잔액은 최대 금액을 초과할 수 없습니다."); + break; + } + case 3:{ + p.sendMessage("잔액이 부족합니다."); + break; } - } else { - p.sendMessage("관리자만 실행 가능한 명령어입니다."); } break; } + case "잔액": { p.sendMessage("==잔액: " + m_AccountArray.getAccountInfo(p.getUniqueId()) + "원=="); break; } - case "테스트": { - p.sendMessage("ㅅㅅㅅㅅㅅㅅ"); - break; - } - case "이체": { - if (args.length > 1) { - if(args.length > 2) { - UUID op = m_UserInfoArray.getUserUUID(args[1]); - p.sendMessage("이체"+args[1]+op); - if (op != null) { - if (isStringDouble(args[2])) { - if(p.getUniqueId() != op) { - switch(m_AccountArray.transfer(p.getUniqueId(), op, Long.parseLong(args[2]))) - { - case 1: { - p.sendMessage(args[1]+ "님에게 " + Integer.parseInt(args[2]) + "원을 이체하였습니다."); - break; - } - case 2: { - p.sendMessage("잔액은 최대 금액을 초과할 수 없습니다."); - break; - } - case 3:{ - p.sendMessage("잔액이 부족합니다."); - break; - } - } - } else{ - p.sendMessage("자기 자신에게는 이체할 수 없습니다."); - } - } else { - p.sendMessage("이체 금액은 숫자만 가능합니다."); - } - } else { - p.sendMessage("잘못된 계좌입니다."); - } - } else { - p.sendMessage("이체 금액을 입력해주세요."); - } - } else { - p.sendMessage("이체 대상이 지정되지 않았습니다."); - } - break; - } default: { p.sendMessage("잘못된 명령어"); } + } } else{ diff --git a/Array/FarmEventHandler.java b/Array/FarmEventHandler.java index 0537669..628f742 100644 --- a/Array/FarmEventHandler.java +++ b/Array/FarmEventHandler.java @@ -15,7 +15,7 @@ public class FarmEventHandler implements CommandExecutor { UserInfoArray m_UserInfoArray; AccountArray m_AccountArray; UUID ZERO_UUID = new UUID(0,0); - public FarmEventHandler(FarmArray GA, UserInfoArray UIA, AccountArray AA){ + public FarmEventHandler(UserInfoArray UIA, FarmArray GA, AccountArray AA){ m_FarmArray = GA; m_UserInfoArray = UIA; m_AccountArray = AA; @@ -36,34 +36,45 @@ public class FarmEventHandler implements CommandExecutor { switch (args[0]) { case "생성":{ UUID tempUUID = UUID.randomUUID(); - if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm").equals(ZERO_UUID)){ - if(m_FarmArray.CreateGroup(tempUUID, args[1], p.getUniqueId())){ - m_UserInfoArray.setUserGroupUUID("Farm",p.getUniqueId(), tempUUID); - m_AccountArray.putAccountInfo(tempUUID,0); - p.sendMessage(args[1]+"농장이 생성되었습니다."); - p.sendMessage("농장 멤버 목록: "); - for (String Name: m_FarmArray.GetGroupMembersName(tempUUID)){ - p.sendMessage(Name); - } - p.sendMessage("농장 목록:"); - for (String Name: m_FarmArray.GetGroupNameList()){ - p.sendMessage(Name); - } - } - else{ - p.sendMessage("이미 존재하는 농장 이름"); - } - } - else{ + if(!m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm").equals(ZERO_UUID)){ p.sendMessage("이미 농장을 소유중"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm")); + return false; + } + + if(!m_FarmArray.CreateGroup(tempUUID, args[1], p.getUniqueId())){ + p.sendMessage("이미 존재하는 농장 이름"); + return false; + } + + m_UserInfoArray.setUserGroupUUID("Farm",p.getUniqueId(), tempUUID); + m_AccountArray.putAccountInfo(tempUUID,0); + + for (UUID key: m_UserInfoArray.getKeySet()){ + p.sendMessage("------------"+p.getUniqueId()); + p.sendMessage(""+m_UserInfoArray.getUserGroupUUID(key,"Farm")); + } + + p.sendMessage(args[1]+"농장이 생성되었습니다."); + p.sendMessage("농장 멤버 목록: "); + + for (String Name: m_FarmArray.GetGroupMembersName(tempUUID)){ + p.sendMessage(Name); + } + + p.sendMessage("농장 목록:"); + + for (String Name: m_FarmArray.GetGroupNameList()){ + p.sendMessage(Name); } break; } + case "가입":{ p.sendMessage("플레이어 UUID:"+p.getUniqueId()+" 농장 UUID:"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm")); p.sendMessage("ZERO UUID:"+ZERO_UUID); if(!m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm").equals(ZERO_UUID)){ p.sendMessage("이미 가입한 농장이 존재"); + return false; } else{ p.sendMessage("가입 완료"); @@ -79,44 +90,46 @@ public class FarmEventHandler implements CommandExecutor { } break; } + case "초대":{ p.sendMessage("초대 테스트"); break; } + case "강퇴":{ - p.sendMessage("강퇴 테스트"); + p.sendMessage("강퇴 테스트"+args[1]); if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm").equals(ZERO_UUID)){ p.sendMessage("가입한 농장이 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm")); + return false; } - else{ - if(m_FarmArray.isOwner(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm"), p.getUniqueId())){ - if (args.length > 1) { - Player op = Bukkit.getPlayer(args[1]); - if (op != null) { - if(m_FarmArray.isGroupMember(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm"),op.getUniqueId())) { - m_FarmArray.ExpulsionGroupPlayer("Farm", m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm"), p.getUniqueId()); - } - else{ - p.sendMessage("농장에 가입되지 않은 유저"); - } - } - else{ - p.sendMessage("잘못된 대상"); - } - } - else{ - p.sendMessage("강퇴할 대상을 지정"); - } - } - else{ - p.sendMessage("농장주만 사용 가능한 명령어"+ p.getUniqueId()); - } + + if(!m_FarmArray.isOwner(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm"), p.getUniqueId())){ + p.sendMessage("농장주만 사용 가능한 명령어"+ p.getUniqueId()); + } + + if (args.length < 1) { + p.sendMessage("강퇴할 대상을 지정"); + return false; + } + + UUID op = m_UserInfoArray.getUserUUID(args[1]); + if (op == null) { + p.sendMessage("잘못된 대상"); + return false; } + + if(!m_FarmArray.isGroupMember(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm"),op)) { + p.sendMessage("농장에 가입되지 않은 유저"); + return false; + } + + m_FarmArray.ExpulsionGroupPlayer("Farm", m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm"), op); break; } case "탈퇴": { if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm").equals(ZERO_UUID)){ p.sendMessage("가입한 농장이 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm")); + return false; } else{ p.sendMessage("탈퇴 플레이어 UUID:"+p.getUniqueId()+" 농장 UUID:"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm")); @@ -126,7 +139,7 @@ public class FarmEventHandler implements CommandExecutor { break; } case "이름":{ - p.sendMessage("현재 파티 이름"+m_FarmArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Party"))); + p.sendMessage("현재 파티 이름"+m_FarmArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Farm"))); break; } case "정보": { @@ -139,113 +152,123 @@ public class FarmEventHandler implements CommandExecutor { } p.sendMessage("계좌 잔액:"+m_AccountArray.getAccountInfo(m_FarmArray.m_GroupNameList.get(Name))); } + break; } case "계좌설정":{ - if (p.isOp()) { - if (args.length > 1) { - if (args[1] != null) { - UUID op = m_FarmArray.m_GroupNameList.get(args[1]); - if (op != null) { - if (args.length > 2) { - if (isStringDouble(args[2])) { - if(m_AccountArray.setAccountInfo(op, Long.parseLong(args[2]))){ - p.sendMessage(args[1] + "님의 잔액을 " + Integer.parseInt(args[2]) + "원으로 설정하였습니다."); - } else{ - p.sendMessage("최대 금액 이상으로 설정할 수 없습니다."); - } - } else { - p.sendMessage("설정 금액은 숫자만 가능합니다."); - } - } else { - p.sendMessage("설정 금액을 입력해주세요."); - } - } else { - p.sendMessage("잘못된 계좌입니다."); - } - } - }else{ - p.sendMessage("설정 대상이 지정되지 않았습니다."); - } - } else { + if (!p.isOp()) { p.sendMessage("관리자만 실행 가능한 명령어입니다."); + return false; + } + if (args.length < 1) { + p.sendMessage("설정 대상이 지정되지 않았습니다."); + return false; + } + UUID op = m_FarmArray.m_GroupNameList.get(args[1]); + if (op == null) { + p.sendMessage("잘못된 계좌입니다."); + return false; + } + if (args.length < 2) { + p.sendMessage("설정 금액을 입력해주세요."); + return false; + } + if (!isStringDouble(args[2])) { + p.sendMessage("설정 금액은 숫자만 가능합니다."); + return false; } + if(m_AccountArray.getAccountInfo(op)+Long.parseLong(args[2])>2147483647){ + p.sendMessage("최대 금액 이상으로 설정할 수 없습니다."); + return false; + } + m_AccountArray.setAccountInfo(op, Long.parseLong(args[2])); + p.sendMessage(args[1] + "님의 잔액을 " + Integer.parseInt(args[2]) + "원으로 설정하였습니다."); break; } + case "입금": { - if (args.length > 1) { - if(args.length > 2) { - UUID op = m_FarmArray.m_GroupNameList.get(args[1]); - if (op != null) { - if (isStringDouble(args[2])) { - if(p.getUniqueId() != op) { - switch(m_AccountArray.transfer(p.getUniqueId(), op, Long.parseLong(args[2]))) - { - case 1: { - p.sendMessage(args[1] + "농장에 " + Integer.parseInt(args[2]) + "원을 이체하였습니다."); - break; - } - case 2: { - p.sendMessage("잔액은 최대 금액을 초과할 수 없습니다."); - break; - } - case 3:{ - p.sendMessage("잔액이 부족합니다."); - break; - } - } - } else{ - p.sendMessage("자기 자신에게는 이체할 수 없습니다."); - } - } else { - p.sendMessage("이체 금액은 숫자만 가능합니다."); - } - } else { - p.sendMessage("잘못된 계좌입니다."); - } - } else { - p.sendMessage("이체 금액을 입력해주세요."); - } - } else { + if (args.length < 1) { + p.sendMessage("이체 대상이 지정되지 않았습니다."); + return false; + } + if (args[1] == null) { p.sendMessage("이체 대상이 지정되지 않았습니다."); + return false; + } + UUID op = m_FarmArray.m_GroupNameList.get(args[1]); + if (op == null) { + p.sendMessage("잘못된 계좌입니다."); + return false; + } + if (args.length < 2) { + p.sendMessage("이체 금액을 입력해주세요."); + return false; + } + if (!isStringDouble(args[2])) { + p.sendMessage("이체 금액은 숫자만 가능합니다."); + return false; + } + if(p.getUniqueId() == op) { + p.sendMessage("자기 자신에게는 이체할 수 없습니다."); + return false; + } + switch(m_AccountArray.transfer(p.getUniqueId(), op, Long.parseLong(args[2]))) + { + case 1: { + p.sendMessage(args[1] + "농장에 " + Integer.parseInt(args[2]) + "원을 이체하였습니다."); + break; + } + case 2: { + p.sendMessage("잔액은 최대 금액을 초과할 수 없습니다."); + break; + } + case 3:{ + p.sendMessage("잔액이 부족합니다."); + break; + } } break; } + case "출금": { - if (args.length > 1) { - if(args.length > 2) { - UUID op = m_FarmArray.m_GroupNameList.get(args[1]); - if (op != null) { - if (isStringDouble(args[2])) { - if(p.getUniqueId() != op) { - switch(m_AccountArray.transfer(op,p.getUniqueId(), Long.parseLong(args[2]))) - { - case 1: { - p.sendMessage(args[1] + "농장에서 " + Integer.parseInt(args[2]) + "원을 출금하였습니다."); - break; - } - case 2: { - p.sendMessage("잔액은 최대 금액을 초과할 수 없습니다."); - break; - } - case 3:{ - p.sendMessage("잔액이 부족합니다."); - break; - } - } - } else{ - p.sendMessage("자기 자신에게는 이체할 수 없습니다."); - } - } else { - p.sendMessage("이체 금액은 숫자만 가능합니다."); - } - } else { - p.sendMessage("잘못된 계좌입니다."); - } - } else { - p.sendMessage("이체 금액을 입력해주세요."); + if (args.length < 1) { + p.sendMessage("출금 대상이 지정되지 않았습니다."); + return false; + } + if (args[1] == null) { + p.sendMessage("출금 대상이 지정되지 않았습니다."); + return false; + } + UUID op = m_FarmArray.m_GroupNameList.get(args[1]); + if (op == null) { + p.sendMessage("잘못된 계좌입니다."); + return false; + } + if (args.length < 2) { + p.sendMessage("출금 금액을 입력해주세요."); + return false; + } + if (!isStringDouble(args[2])) { + p.sendMessage("출금 금액은 숫자만 가능합니다."); + return false; + } + if(p.getUniqueId() == op) { + p.sendMessage("자기 자신에게는 출금할 수 없습니다."); + return false; + } + switch(m_AccountArray.transfer(op, p.getUniqueId(), Long.parseLong(args[2]))) + { + case 1: { + p.sendMessage(args[1] + "농장에 " + Integer.parseInt(args[2]) + "원을 출금하였습니다."); + break; + } + case 2: { + p.sendMessage("잔액은 최대 금액을 초과할 수 없습니다."); + break; + } + case 3:{ + p.sendMessage("잔액이 부족합니다."); + break; } - } else { - p.sendMessage("이체 대상이 지정되지 않았습니다."); } break; } diff --git a/Array/GroupArray.java b/Array/GroupArray.java index 52beba6..a093047 100644 --- a/Array/GroupArray.java +++ b/Array/GroupArray.java @@ -83,17 +83,15 @@ public class GroupArray { } - public Integer SignUpGroup(String GroupType, UUID GroupUUID, UUID PlayerUUID){ - if(m_GroupArray.containsKey(GroupUUID) & !m_UserInfoArray.getUserGroupUUID(PlayerUUID, GroupType).equals(ZERO_UUID)){ - + public String SignUpGroup(String GroupType, UUID GroupUUID, UUID PlayerUUID){ + if(m_GroupArray.containsKey(GroupUUID) && m_UserInfoArray.getUserGroupUUID(PlayerUUID, GroupType).equals(ZERO_UUID)){ Group m_Group = m_GroupArray.get(GroupUUID); m_Group.SignUp(PlayerUUID); m_UserInfoArray.setUserGroupUUID(GroupType,PlayerUUID,GroupUUID); - + return ""; } else{ - return 3; // Wrong Group + return "다른 그룹에 가입되어있습니다."; // Wrong Group } - return 0; } public boolean ExpulsionGroupPlayer(String GroupType, UUID GroupUUID, UUID PlayerUUID){ diff --git a/Array/NationEventHandler.java b/Array/NationEventHandler.java index 24c4b9f..c7f2a7a 100644 --- a/Array/NationEventHandler.java +++ b/Array/NationEventHandler.java @@ -15,7 +15,7 @@ public class NationEventHandler implements CommandExecutor { UserInfoArray m_UserInfoArray; AccountArray m_AccountArray; UUID ZERO_UUID = new UUID(0,0); - public NationEventHandler(NationArray GA, UserInfoArray UIA, AccountArray AA){ + public NationEventHandler(UserInfoArray UIA, NationArray GA, AccountArray AA){ m_NationArray = GA; m_UserInfoArray = UIA; m_AccountArray = AA; @@ -36,34 +36,45 @@ public class NationEventHandler implements CommandExecutor { switch (args[0]) { case "생성":{ UUID tempUUID = UUID.randomUUID(); - if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation").equals(ZERO_UUID)){ - if(m_NationArray.CreateGroup(tempUUID, args[1], p.getUniqueId())){ - m_UserInfoArray.setUserGroupUUID("Nation",p.getUniqueId(), tempUUID); - m_AccountArray.putAccountInfo(tempUUID,0); - p.sendMessage(args[1]+"국가 생성되었습니다."); - p.sendMessage("국가 멤버 목록: "); - for (String Name: m_NationArray.GetGroupMembersName(tempUUID)){ - p.sendMessage(Name); - } - p.sendMessage("국가 목록:"); - for (String Name: m_NationArray.GetGroupNameList()){ - p.sendMessage(Name); - } - } - else{ - p.sendMessage("이미 존재하는 국가 이름"); - } + if(!m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation").equals(ZERO_UUID)){ + p.sendMessage("이미 국가을 소유중"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation")); + return false; } - else{ - p.sendMessage("이미 국가 소유중"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation")); + + if(!m_NationArray.CreateGroup(tempUUID, args[1], p.getUniqueId())){ + p.sendMessage("이미 존재하는 국가 이름"); + return false; + } + + m_UserInfoArray.setUserGroupUUID("Nation",p.getUniqueId(), tempUUID); + m_AccountArray.putAccountInfo(tempUUID,0); + + for (UUID key: m_UserInfoArray.getKeySet()){ + p.sendMessage("------------"+p.getUniqueId()); + p.sendMessage(""+m_UserInfoArray.getUserGroupUUID(key,"Nation")); + } + + p.sendMessage(args[1]+"국가이 생성되었습니다."); + p.sendMessage("국가 멤버 목록: "); + + for (String Name: m_NationArray.GetGroupMembersName(tempUUID)){ + p.sendMessage(Name); + } + + p.sendMessage("국가 목록:"); + + for (String Name: m_NationArray.GetGroupNameList()){ + p.sendMessage(Name); } break; } + case "가입":{ p.sendMessage("플레이어 UUID:"+p.getUniqueId()+" 국가 UUID:"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation")); p.sendMessage("ZERO UUID:"+ZERO_UUID); if(!m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation").equals(ZERO_UUID)){ - p.sendMessage("이미 가입한 국가 존재"); + p.sendMessage("이미 가입한 국가가 존재"); + return false; } else{ p.sendMessage("가입 완료"); @@ -79,44 +90,46 @@ public class NationEventHandler implements CommandExecutor { } break; } + case "초대":{ p.sendMessage("초대 테스트"); break; } + case "강퇴":{ - p.sendMessage("강퇴 테스트"); + p.sendMessage("강퇴 테스트"+args[1]); if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation").equals(ZERO_UUID)){ - p.sendMessage("가입한 국가 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation")); + p.sendMessage("가입한 국가이 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation")); + return false; } - else{ - if(m_NationArray.isOwner(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation"), p.getUniqueId())){ - if (args.length > 1) { - Player op = Bukkit.getPlayer(args[1]); - if (op != null) { - if(m_NationArray.isGroupMember(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation"),op.getUniqueId())) { - m_NationArray.ExpulsionGroupPlayer("Nation", m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation"), p.getUniqueId()); - } - else{ - p.sendMessage("국가 가입되지 않은 유저"); - } - } - else{ - p.sendMessage("잘못된 대상"); - } - } - else{ - p.sendMessage("강퇴할 대상을 지정"); - } - } - else{ - p.sendMessage("국가주만 사용 가능한 명령어"+ p.getUniqueId()); - } + + if(!m_NationArray.isOwner(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation"), p.getUniqueId())){ + p.sendMessage("국가 대표만 사용 가능한 명령어"+ p.getUniqueId()); + } + + if (args.length < 1) { + p.sendMessage("강퇴할 대상을 지정"); + return false; + } + + UUID op = m_UserInfoArray.getUserUUID(args[1]); + if (op == null) { + p.sendMessage("잘못된 대상"); + return false; + } + + if(!m_NationArray.isGroupMember(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation"),op)) { + p.sendMessage("국가에 가입되지 않은 유저"); + return false; } + + m_NationArray.ExpulsionGroupPlayer("Nation", m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation"), op); break; } case "탈퇴": { if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation").equals(ZERO_UUID)){ - p.sendMessage("가입한 국가 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation")); + p.sendMessage("가입한 국가이 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation")); + return false; } else{ p.sendMessage("탈퇴 플레이어 UUID:"+p.getUniqueId()+" 국가 UUID:"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation")); @@ -126,7 +139,7 @@ public class NationEventHandler implements CommandExecutor { break; } case "이름":{ - p.sendMessage("현재 파티 이름"+m_NationArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Party"))); + p.sendMessage("현재 파티 이름"+m_NationArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Nation"))); break; } case "정보": { @@ -139,113 +152,127 @@ public class NationEventHandler implements CommandExecutor { } p.sendMessage("계좌 잔액:"+m_AccountArray.getAccountInfo(m_NationArray.m_GroupNameList.get(Name))); } + break; } case "계좌설정":{ - if (p.isOp()) { - if (args.length > 1) { - if (args[1] != null) { - UUID op = m_NationArray.m_GroupNameList.get(args[1]); - if (op != null) { - if (args.length > 2) { - if (isStringDouble(args[2])) { - if(m_AccountArray.setAccountInfo(op, Long.parseLong(args[2]))){ - p.sendMessage(args[1] + "님의 잔액을 " + Integer.parseInt(args[2]) + "원으로 설정하였습니다."); - } else{ - p.sendMessage("최대 금액 이상으로 설정할 수 없습니다."); - } - } else { - p.sendMessage("설정 금액은 숫자만 가능합니다."); - } - } else { - p.sendMessage("설정 금액을 입력해주세요."); - } - } else { - p.sendMessage("잘못된 계좌입니다."); - } - } - }else{ - p.sendMessage("설정 대상이 지정되지 않았습니다."); - } - } else { + if (!p.isOp()) { p.sendMessage("관리자만 실행 가능한 명령어입니다."); + return false; + } + if (args.length < 1) { + p.sendMessage("설정 대상이 지정되지 않았습니다."); + return false; + } + if (args[1] == null) { + p.sendMessage("설정 대상이 지정되지 않았습니다."); + return false; + } + UUID op = m_NationArray.m_GroupNameList.get(args[1]); + if (op == null) { + p.sendMessage("잘못된 계좌입니다."); + return false; + } + if (args.length < 2) { + p.sendMessage("설정 금액을 입력해주세요."); + return false; + } + if (!isStringDouble(args[2])) { + p.sendMessage("설정 금액은 숫자만 가능합니다."); + return false; } + if(m_AccountArray.getAccountInfo(op)+Long.parseLong(args[2])>2147483647){ + p.sendMessage("최대 금액 이상으로 설정할 수 없습니다."); + return false; + } + m_AccountArray.setAccountInfo(op, Long.parseLong(args[2])); + p.sendMessage(args[1] + "님의 잔액을 " + Integer.parseInt(args[2]) + "원으로 설정하였습니다."); break; } + case "입금": { - if (args.length > 1) { - if(args.length > 2) { - UUID op = m_NationArray.m_GroupNameList.get(args[1]); - if (op != null) { - if (isStringDouble(args[2])) { - if(p.getUniqueId() != op) { - switch(m_AccountArray.transfer(p.getUniqueId(), op, Long.parseLong(args[2]))) - { - case 1: { - p.sendMessage(args[1] + "국가 " + Integer.parseInt(args[2]) + "원을 이체하였습니다."); - break; - } - case 2: { - p.sendMessage("잔액은 최대 금액을 초과할 수 없습니다."); - break; - } - case 3:{ - p.sendMessage("잔액이 부족합니다."); - break; - } - } - } else{ - p.sendMessage("자기 자신에게는 이체할 수 없습니다."); - } - } else { - p.sendMessage("이체 금액은 숫자만 가능합니다."); - } - } else { - p.sendMessage("잘못된 계좌입니다."); - } - } else { - p.sendMessage("이체 금액을 입력해주세요."); - } - } else { + if (args.length < 1) { + p.sendMessage("이체 대상이 지정되지 않았습니다."); + return false; + } + if (args[1] == null) { p.sendMessage("이체 대상이 지정되지 않았습니다."); + return false; + } + UUID op = m_NationArray.m_GroupNameList.get(args[1]); + if (op == null) { + p.sendMessage("잘못된 계좌입니다."); + return false; + } + if (args.length < 2) { + p.sendMessage("이체 금액을 입력해주세요."); + return false; + } + if (!isStringDouble(args[2])) { + p.sendMessage("이체 금액은 숫자만 가능합니다."); + return false; + } + if(p.getUniqueId() == op) { + p.sendMessage("자기 자신에게는 이체할 수 없습니다."); + return false; + } + switch(m_AccountArray.transfer(p.getUniqueId(), op, Long.parseLong(args[2]))) + { + case 1: { + p.sendMessage(args[1] + "국가에 " + Integer.parseInt(args[2]) + "원을 이체하였습니다."); + break; + } + case 2: { + p.sendMessage("잔액은 최대 금액을 초과할 수 없습니다."); + break; + } + case 3:{ + p.sendMessage("잔액이 부족합니다."); + break; + } } break; } + case "출금": { - if (args.length > 1) { - if(args.length > 2) { - UUID op = m_NationArray.m_GroupNameList.get(args[1]); - if (op != null) { - if (isStringDouble(args[2])) { - if(p.getUniqueId() != op) { - switch(m_AccountArray.transfer(op,p.getUniqueId(), Long.parseLong(args[2]))) - { - case 1: { - p.sendMessage(args[1] + "국가 " + Integer.parseInt(args[2]) + "원을 출금하였습니다."); - break; - } - case 2: { - p.sendMessage("잔액은 최대 금액을 초과할 수 없습니다."); - break; - } - case 3:{ - p.sendMessage("잔액이 부족합니다."); - break; - } - } - } else{ - p.sendMessage("자기 자신에게는 이체할 수 없습니다."); - } - } else { - p.sendMessage("이체 금액은 숫자만 가능합니다."); - } - } else { - p.sendMessage("잘못된 계좌입니다."); - } - } else { - p.sendMessage("이체 금액을 입력해주세요."); + if (args.length < 1) { + p.sendMessage("출금 대상이 지정되지 않았습니다."); + return false; + } + if (args[1] == null) { + p.sendMessage("출금 대상이 지정되지 않았습니다."); + return false; + } + UUID op = m_NationArray.m_GroupNameList.get(args[1]); + if (op == null) { + p.sendMessage("잘못된 계좌입니다."); + return false; + } + if (args.length < 2) { + p.sendMessage("출금 금액을 입력해주세요."); + return false; + } + if (!isStringDouble(args[2])) { + p.sendMessage("출금 금액은 숫자만 가능합니다."); + return false; + } + if(p.getUniqueId() == op) { + p.sendMessage("자기 자신에게는 출금할 수 없습니다."); + return false; + } + switch(m_AccountArray.transfer(op, p.getUniqueId(), Long.parseLong(args[2]))) + { + case 1: { + p.sendMessage(args[1] + "국가에 " + Integer.parseInt(args[2]) + "원을 출금하였습니다."); + break; + } + case 2: { + p.sendMessage("잔액은 최대 금액을 초과할 수 없습니다."); + break; + } + case 3:{ + p.sendMessage("잔액이 부족합니다."); + break; } - } else { - p.sendMessage("이체 대상이 지정되지 않았습니다."); } break; } diff --git a/Array/Squad.java b/Array/Squad.java new file mode 100644 index 0000000..bad9881 --- /dev/null +++ b/Array/Squad.java @@ -0,0 +1,10 @@ +package org.poopki.duckdns.user_db.Array; + +import java.util.List; +import java.util.UUID; + +public class Squad extends Group{ + public Squad(String Name, List uuid_list){ + super(Name, uuid_list); + } +} diff --git a/Array/SquadArray.java b/Array/SquadArray.java new file mode 100644 index 0000000..32a72cb --- /dev/null +++ b/Array/SquadArray.java @@ -0,0 +1,9 @@ +package org.poopki.duckdns.user_db.Array; + +import org.poopki.duckdns.user_db.UserInfoArray; + +public class SquadArray extends GroupArray{ + public SquadArray(UserInfoArray m_UIA){ + super(m_UIA, 8); + } +} diff --git a/Array/SquadEventHandler.java b/Array/SquadEventHandler.java new file mode 100644 index 0000000..9b9ed9e --- /dev/null +++ b/Array/SquadEventHandler.java @@ -0,0 +1,292 @@ +package org.poopki.duckdns.user_db.Array; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.poopki.duckdns.user_db.UserInfoArray; + +import java.util.UUID; + +public class SquadEventHandler implements CommandExecutor { + + SquadArray m_SquadArray; + UserInfoArray m_UserInfoArray; + AccountArray m_AccountArray; + UUID ZERO_UUID = new UUID(0,0); + public SquadEventHandler(UserInfoArray UIA, SquadArray GA, AccountArray AA){ + m_SquadArray = GA; + m_UserInfoArray = UIA; + m_AccountArray = AA; + } + public static boolean isStringDouble(String s) { + try { + Double.parseDouble(s); + return true; + } catch (NumberFormatException e) { + return false; + } + } + @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(); + if(!m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Squad").equals(ZERO_UUID)){ + p.sendMessage("이미 분대를 소유중"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Squad")); + return false; + } + + if(!m_SquadArray.CreateGroup(tempUUID, args[1], p.getUniqueId())){ + p.sendMessage("이미 존재하는 분대 이름"); + return false; + } + + m_UserInfoArray.setUserGroupUUID("Squad",p.getUniqueId(), tempUUID); + m_AccountArray.putAccountInfo(tempUUID,0); + + for (UUID key: m_UserInfoArray.getKeySet()){ + p.sendMessage("------------"+p.getUniqueId()); + p.sendMessage(""+m_UserInfoArray.getUserGroupUUID(key,"Squad")); + } + + p.sendMessage(args[1]+"분대이 생성되었습니다."); + p.sendMessage("분대 멤버 목록: "); + + for (String Name: m_SquadArray.GetGroupMembersName(tempUUID)){ + p.sendMessage(Name); + } + + p.sendMessage("분대 목록:"); + + for (String Name: m_SquadArray.GetGroupNameList()){ + p.sendMessage(Name); + } + break; + } + + case "가입":{ + p.sendMessage("플레이어 UUID:"+p.getUniqueId()+" 분대 UUID:"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Squad")); + p.sendMessage("ZERO UUID:"+ZERO_UUID); + if(!m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Squad").equals(ZERO_UUID)){ + p.sendMessage("이미 가입한 분대가 존재"); + return false; + } + else{ + p.sendMessage("가입 완료"); + m_SquadArray.SignUpGroup("Squad",m_SquadArray.m_GroupNameList.get(args[1]),p.getUniqueId()); + p.sendMessage("분대 멤버 목록: "); + for (String Name: m_SquadArray.GetGroupMembersName(m_SquadArray.m_GroupNameList.get(args[1]))){ + p.sendMessage(Name); + } + p.sendMessage("분대 목록:"); + for (String Name: m_SquadArray.GetGroupNameList()){ + p.sendMessage(Name); + } + } + break; + } + + case "초대":{ + p.sendMessage("초대 테스트"); + break; + } + + case "강퇴":{ + p.sendMessage("강퇴 테스트"+args[1]); + if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Squad").equals(ZERO_UUID)){ + p.sendMessage("가입한 분대이 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Squad")); + return false; + } + + if(!m_SquadArray.isOwner(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Squad"), p.getUniqueId())){ + p.sendMessage("분대장만 사용 가능한 명령어"+ p.getUniqueId()); + } + + if (args.length < 1) { + p.sendMessage("강퇴할 대상을 지정"); + return false; + } + + UUID op = m_UserInfoArray.getUserUUID(args[1]); + if (op == null) { + p.sendMessage("잘못된 대상"); + return false; + } + + if(!m_SquadArray.isGroupMember(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Squad"),op)) { + p.sendMessage("분대에 가입되지 않은 유저"); + return false; + } + + m_SquadArray.ExpulsionGroupPlayer("Squad", m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Squad"), op); + break; + } + case "탈퇴": { + if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Squad").equals(ZERO_UUID)){ + p.sendMessage("가입한 분대이 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Squad")); + return false; + } + else{ + p.sendMessage("탈퇴 플레이어 UUID:"+p.getUniqueId()+" 분대 UUID:"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Squad")); + m_SquadArray.ExpulsionGroupPlayer("Squad",m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Squad"),p.getUniqueId()); + + } + break; + } + case "이름":{ + //p.sendMessage("현재 파티 이름"+m_SquadArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Squad"))); + p.sendMessage("현재 파티 이름"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Squad")); + p.sendMessage(""+m_SquadArray.getKeySet()); + break; + } + case "정보": { + p.sendMessage("분대 이름:"); + for (String Name: m_SquadArray.GetGroupNameList()){ + p.sendMessage("분대 이름:"); + p.sendMessage(Name); + p.sendMessage("인원 목록"); + for (String Name2: m_SquadArray.GetGroupMembersName(m_SquadArray.m_GroupNameList.get(Name))) { + p.sendMessage(Name2); + } + p.sendMessage("계좌 잔액:"+m_AccountArray.getAccountInfo(m_SquadArray.m_GroupNameList.get(Name))); + } + break; + } + case "계좌설정":{ + if (!p.isOp()) { + p.sendMessage("관리자만 실행 가능한 명령어입니다."); + return false; + } + if (args.length < 1) { + p.sendMessage("설정 대상이 지정되지 않았습니다."); + return false; + } + if (args[1] == null) { + p.sendMessage("설정 대상이 지정되지 않았습니다."); + return false; + } + UUID op = m_SquadArray.m_GroupNameList.get(args[1]); + if (op == null) { + p.sendMessage("잘못된 계좌입니다."); + return false; + } + if (args.length < 2) { + p.sendMessage("설정 금액을 입력해주세요."); + return false; + } + if (!isStringDouble(args[2])) { + p.sendMessage("설정 금액은 숫자만 가능합니다."); + return false; + } + if(m_AccountArray.getAccountInfo(op)+Long.parseLong(args[2])>2147483647){ + p.sendMessage("최대 금액 이상으로 설정할 수 없습니다."); + return false; + } + m_AccountArray.setAccountInfo(op, Long.parseLong(args[2])); + p.sendMessage(args[1] + "님의 잔액을 " + Integer.parseInt(args[2]) + "원으로 설정하였습니다."); + break; + } + + case "입금": { + if (args.length < 1) { + p.sendMessage("이체 대상이 지정되지 않았습니다."); + return false; + } + if (args[1] == null) { + p.sendMessage("이체 대상이 지정되지 않았습니다."); + return false; + } + UUID op = m_SquadArray.m_GroupNameList.get(args[1]); + if (op == null) { + p.sendMessage("잘못된 계좌입니다."); + return false; + } + if (args.length < 2) { + p.sendMessage("이체 금액을 입력해주세요."); + return false; + } + if (!isStringDouble(args[2])) { + p.sendMessage("이체 금액은 숫자만 가능합니다."); + return false; + } + if(p.getUniqueId() == op) { + p.sendMessage("자기 자신에게는 이체할 수 없습니다."); + return false; + } + switch(m_AccountArray.transfer(p.getUniqueId(), op, Long.parseLong(args[2]))) + { + case 1: { + p.sendMessage(args[1] + "분대에 " + Integer.parseInt(args[2]) + "원을 이체하였습니다."); + break; + } + case 2: { + p.sendMessage("잔액은 최대 금액을 초과할 수 없습니다."); + break; + } + case 3:{ + p.sendMessage("잔액이 부족합니다."); + break; + } + } + break; + } + + case "출금": { + if (args.length < 1) { + p.sendMessage("출금 대상이 지정되지 않았습니다."); + return false; + } + if (args[1] == null) { + p.sendMessage("출금 대상이 지정되지 않았습니다."); + return false; + } + UUID op = m_SquadArray.m_GroupNameList.get(args[1]); + if (op == null) { + p.sendMessage("잘못된 계좌입니다."); + return false; + } + if (args.length < 2) { + p.sendMessage("출금 금액을 입력해주세요."); + return false; + } + if (!isStringDouble(args[2])) { + p.sendMessage("출금 금액은 숫자만 가능합니다."); + return false; + } + if(p.getUniqueId() == op) { + p.sendMessage("자기 자신에게는 출금할 수 없습니다."); + return false; + } + switch(m_AccountArray.transfer(op, p.getUniqueId(), Long.parseLong(args[2]))) + { + case 1: { + p.sendMessage(args[1] + "분대에 " + Integer.parseInt(args[2]) + "원을 출금하였습니다."); + break; + } + case 2: { + p.sendMessage("잔액은 최대 금액을 초과할 수 없습니다."); + break; + } + case 3:{ + p.sendMessage("잔액이 부족합니다."); + break; + } + } + break; + } + case "잔액": { + p.sendMessage("==잔액: " + m_AccountArray.getAccountInfo(m_SquadArray.GetUUID(args[1]))+ "원=="); + break; + } + default: { + p.sendMessage("잘못된 명령어"); + } + } + } + return true; + } +} diff --git a/DB/DBUpdate.java b/DB/DBUpdate.java index 6345b47..afb18d7 100644 --- a/DB/DBUpdate.java +++ b/DB/DBUpdate.java @@ -4,6 +4,7 @@ import org.poopki.duckdns.user_db.*; import org.poopki.duckdns.user_db.Array.AccountArray; import org.poopki.duckdns.user_db.Array.FarmArray; import org.poopki.duckdns.user_db.Array.NationArray; +import org.poopki.duckdns.user_db.Array.SquadArray; import java.sql.*; import java.util.ArrayList; @@ -11,25 +12,26 @@ import java.util.List; import java.util.UUID; public class DBUpdate { - private static final String DB_DRIVER_CLASS = "org.mariadb.jdbc.Driver"; - private static final String DB_URL = "jdbc:mariadb://poopki.duckdns.org:3307/mc_dev"; - private static final String DB_USERNAME = "mc_dev"; - private static final String DB_PASSWORD = "!Rkdalsrn1027"; - private static UserInfoArray m_InfoArrayInstance; - private static AccountArray m_AccountArray; - - private static FarmArray m_FarmArray; - private static NationArray m_NationArray; + private final String DB_DRIVER_CLASS = "org.mariadb.jdbc.Driver"; + private final String DB_URL = "jdbc:mariadb://poopki.duckdns.org:3307/mc_dev"; + private final String DB_USERNAME = "mc_dev"; + private final String DB_PASSWORD = "!Rkdalsrn1027"; + private UserInfoArray m_InfoArrayInstance; + private AccountArray m_AccountArray; + private SquadArray m_SquadArray; + private FarmArray m_FarmArray; + private NationArray m_NationArray; UUID ZERO_UUID = new UUID(0,0); static int MAX_FARM_NUM = 13; - public DBUpdate(UserInfoArray UIA, AccountArray AA, FarmArray FA, NationArray NA){ + public DBUpdate(UserInfoArray UIA, FarmArray FA, NationArray NA, SquadArray SA ,AccountArray AA){ m_InfoArrayInstance = UIA; m_AccountArray = AA; m_FarmArray = FA; m_NationArray = NA; + m_SquadArray = SA; } - public static void InitDB() throws SQLException { // 플러그인 초기 사용 시 테이블 생성 + public void InitDB() throws SQLException { // 플러그인 초기 사용 시 테이블 생성 Connection conn = null; Statement stmt; @@ -68,7 +70,7 @@ public class DBUpdate { } } } - public static void LoadDB() throws SQLException { //서버 초기 구동 시 DB 로드 + public void LoadDB() throws SQLException { //서버 초기 구동 시 DB 로드 Connection conn = null; Statement stmt; try { @@ -176,6 +178,43 @@ public class DBUpdate { conn.close(); } } + + + try { + Class.forName("org.mariadb.jdbc.Driver"); + + conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD); + System.out.println("Connection success"); + stmt = conn.createStatement(); + String sql = "SELECT * FROM Squad"; + ResultSet rs = stmt.executeQuery(sql); + + while(rs.next()){ + List m_MemberList = new ArrayList<>(); + + for(int index = 4; index<11; index++){ + if(rs.getString(index) != null){ + m_MemberList.add(index-4,UUID.fromString(rs.getString(index))); + } + } + m_SquadArray.PutGroup(UUID.fromString(rs.getString(1)), + rs.getString(2), + m_MemberList); + m_AccountArray.putAccountInfo(UUID.fromString(rs.getString(1)),Integer.parseInt(rs.getString(3))); + } + + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + catch (SQLException e) { + // TODO Auto-generated catch block + System.err.println("에러 내용 :" + e.getMessage()); + System.out.println("DB Connection fail"); + }finally{ + if(conn != null && !conn.isClosed()){ + conn.close(); + } + } } @@ -360,5 +399,72 @@ public class DBUpdate { conn.close(); } } + + try{ + Class.forName("org.mariadb.jdbc.Driver"); + conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD); + + for (UUID key : m_SquadArray.getKeySet()) { + + String sql = "REPLACE INTO Squad VALUES (?,?,?,?,?,?,?,?,?,?,?)"; + pstmt = conn.prepareStatement(sql); + pstmt.setString(1, String.valueOf(key.toString())); + pstmt.setString(2, String.valueOf(m_SquadArray.GetGroupName(key))); + pstmt.setString(3, String.valueOf(m_AccountArray.getAccountInfo(key))); + int index = 4; + for (UUID MemUUID : m_SquadArray.GetGroupMembersUUID(key)){ + pstmt.setString(index, String.valueOf(MemUUID.toString())); + index++; + } + for(; index<=11;index++){ + pstmt.setString(index, null); + } + + int cnt = pstmt.executeUpdate(); + if( cnt == 0 ){ + System.out.println("데이터 입력 실패"); + } + else{ + System.out.println("데이터 입력 성공"); + } + + } + } + catch(ClassNotFoundException e){ + e.printStackTrace(); + } + catch(SQLException e){ + System.err.println("에러 내용 :" + e.getMessage()); + System.out.println("DB Connection fail"); + } + finally { + if( conn != null && !conn.isClosed()){ + conn.close(); + } + } + + try{ + Class.forName("org.mariadb.jdbc.Driver"); + conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD); + for (UUID key: m_SquadArray.m_DeleteQueue){ + String sql = "DELETE FROM Squad WHERE FARM_UUID=?"; + pstmt = conn.prepareStatement(sql); + pstmt.setString(1, String.valueOf(key.toString())); + int cnt = pstmt.executeUpdate(); + m_SquadArray.m_DeleteQueue.remove(key); + } + } + catch(ClassNotFoundException e){ + e.printStackTrace(); + } + catch(SQLException e){ + System.err.println("에러 내용 :" + e.getMessage()); + System.out.println("DB Connection fail"); + } + finally { + if( conn != null && !conn.isClosed()){ + conn.close(); + } + } } } \ No newline at end of file diff --git a/GUI/BaseGUI.java b/GUI/BaseGUI.java index a05da83..a085eae 100644 --- a/GUI/BaseGUI.java +++ b/GUI/BaseGUI.java @@ -13,6 +13,7 @@ import org.bukkit.inventory.ItemStack; import org.poopki.duckdns.user_db.Array.AccountArray; import org.poopki.duckdns.user_db.Array.FarmArray; import org.poopki.duckdns.user_db.Array.NationArray; +import org.poopki.duckdns.user_db.Array.SquadArray; import org.poopki.duckdns.user_db.UserInfoArray; import java.util.UUID; @@ -25,21 +26,23 @@ public class BaseGUI implements Listener{ UserInfoArray m_UIA; FarmArray m_FA; NationArray m_NA; - public BaseGUI(AccountArray AA, UserInfoArray UIA, FarmArray FA, NationArray NA, UUID uuid, InventoryClickEvent e) { + SquadArray m_SA; + public BaseGUI(AccountArray AA, UserInfoArray UIA, FarmArray FA, NationArray NA, SquadArray SA, UUID uuid, InventoryClickEvent e) { m_uuid=uuid; this.inv = Bukkit.createInventory(null,27,"TESTGUI"); - m_AA=AA; - m_UIA=UIA; - m_FA=FA; - m_NA=NA; + m_AA = AA; + m_UIA = UIA; + m_FA = FA; + m_NA = NA; + m_SA = SA; initItemSetting(); } private void initItemSetting() { - inv.setItem(0,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_uuid, "User")); - inv.setItem(1,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_uuid, "Nation")); - inv.setItem(2,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_uuid, "Farm")); + inv.setItem(0,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_SA,m_uuid, "User")); + inv.setItem(1,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_SA,m_uuid, "Nation")); + inv.setItem(2,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_SA,m_uuid, "Farm")); inv.setItem(9, m_ItemManager.btn1); inv.setItem(18, m_ItemManager.btn2); diff --git a/GUI/ItemManager.java b/GUI/ItemManager.java index ab302b8..8d162b8 100644 --- a/GUI/ItemManager.java +++ b/GUI/ItemManager.java @@ -7,6 +7,7 @@ import org.bukkit.inventory.meta.ItemMeta; import org.poopki.duckdns.user_db.Array.AccountArray; import org.poopki.duckdns.user_db.Array.FarmArray; import org.poopki.duckdns.user_db.Array.NationArray; +import org.poopki.duckdns.user_db.Array.SquadArray; import org.poopki.duckdns.user_db.UserInfoArray; import java.util.Arrays; @@ -28,7 +29,7 @@ public class ItemManager { stack.setItemMeta(meta); return stack; } - public ItemStack GetBalance(AccountArray AA, UserInfoArray UIA, FarmArray FA, NationArray NA, UUID m_uuid, String Type){ + public ItemStack GetBalance(AccountArray AA, UserInfoArray UIA, FarmArray FA, NationArray NA, SquadArray SA, UUID m_uuid, String Type){ ItemStack dia = null; switch (Type){ diff --git a/GUI/OpenInv.java b/GUI/OpenInv.java index bae87e9..4e4ee98 100644 --- a/GUI/OpenInv.java +++ b/GUI/OpenInv.java @@ -10,6 +10,7 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.poopki.duckdns.user_db.Array.AccountArray; import org.poopki.duckdns.user_db.Array.FarmArray; import org.poopki.duckdns.user_db.Array.NationArray; +import org.poopki.duckdns.user_db.Array.SquadArray; import org.poopki.duckdns.user_db.UserInfoArray; public class OpenInv implements Listener,CommandExecutor { @@ -17,18 +18,20 @@ public class OpenInv implements Listener,CommandExecutor { UserInfoArray m_UserInfoArray; FarmArray m_FarmArray; NationArray m_NationArray; - public OpenInv(AccountArray AA, UserInfoArray m_UIA, FarmArray FA, NationArray NA){ + SquadArray m_SquadArray; + public OpenInv(UserInfoArray m_UIA, FarmArray FA, NationArray NA, SquadArray SA, AccountArray AA){ m_UserInfoArray = m_UIA; m_AccountArray = AA; m_FarmArray = FA; m_NationArray = NA; + m_SquadArray = SA; } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(sender instanceof Player){ Player player = (Player) sender; player.sendMessage("이벤트 발생"); - BaseGUI inv = new BaseGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, ((Player) sender).getUniqueId(), null); + BaseGUI inv = new BaseGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray,((Player) sender).getUniqueId(), null); inv.open(player); } return false; @@ -37,7 +40,7 @@ public class OpenInv implements Listener,CommandExecutor { public void inven2(InventoryClickEvent e){ Player player = (Player) e.getWhoClicked();; player.sendMessage("이벤트 발생"); - BaseGUI inv = new BaseGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, player.getUniqueId(), e); + BaseGUI inv = new BaseGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e); inv.inven(e); } diff --git a/Invite/InviteMaster.java b/Invite/InviteMaster.java index b38bc34..ce5d2b1 100644 --- a/Invite/InviteMaster.java +++ b/Invite/InviteMaster.java @@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.poopki.duckdns.user_db.Array.FarmArray; import org.poopki.duckdns.user_db.Array.NationArray; +import org.poopki.duckdns.user_db.Array.SquadArray; import org.poopki.duckdns.user_db.UserInfoArray; import java.util.HashMap; @@ -18,65 +19,93 @@ public class InviteMaster implements CommandExecutor { UserInfoArray m_UserInfoArray; FarmArray m_FarmArray; NationArray m_NationArray; - - public InviteMaster(UserInfoArray UIA, FarmArray FA, NationArray NA){ + SquadArray m_SquadArray; + public InviteMaster(UserInfoArray UIA, FarmArray FA, NationArray NA, SquadArray SA){ m_UserInfoArray = UIA; m_FarmArray = FA; m_NationArray = NA; + m_SquadArray = SA; } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player p = (Player)sender; + + if (args.length == 0){ + p.sendMessage("명령어를 확인해주세요."); + return false; + } switch (args[0]) { - case "발송": { - if (args.length > 1) { - if (args.length > 2) { - UUID op = m_UserInfoArray.getUserUUID(args[2]); - if (op != null) { - if (p.getUniqueId().equals(op)) { - p.sendMessage("자기 자신에게 초대를 보낼 수 없습니다."); - } else { - sendInvite(p, Bukkit.getPlayer(args[2]), m_UserInfoArray, m_FarmArray, m_NationArray, args[1]); - } - } else { - p.sendMessage("잘못된 대상입니다."); - } - } else { - p.sendMessage("초대 대상을 입력해주세요."); - } + case "국가": { + if (args.length == 1) { + p.sendMessage("초대 대상을 입력해주세요."); + return false; + + } + UUID op = m_UserInfoArray.getUserUUID(args[1]); + if (op == null) { + p.sendMessage("잘못된 대상입니다."); + return false; + } + if (p.getUniqueId().equals(op)) { + p.sendMessage("자기 자신에게 초대를 보낼 수 없습니다."); } else { - p.sendMessage("국가/농장이 지정되지 않았습니다."); + p.sendMessage(args[1]+"님께 초대를 발송하였습니다."); + sendInvite(p, Bukkit.getPlayer(args[1]), m_UserInfoArray, m_FarmArray, m_NationArray, m_SquadArray,"국가"); } break; } - case "응답": { - if (args.length > 1) { - if (args.length > 2) { - switch (args[2]) { - case "수락": - replyInvite(p, m_UserInfoArray, m_FarmArray, m_NationArray, args[1], true); - p.sendMessage("수락하였습니다."); - break; - case "거절": - replyInvite(p, m_UserInfoArray, m_FarmArray, m_NationArray, args[1], false); - p.sendMessage("거절하였습니다."); - break; - default: - p.sendMessage("/초대 응답 국가|농장 수락|거절"); - } - - } else { - p.sendMessage("초대 대상을 입력해주세요."); - } + case "농장": { + if (args.length < 1) { + p.sendMessage("초대 대상을 입력해주세요."); + return false; + } + UUID op = m_UserInfoArray.getUserUUID(args[1]); + if (op == null) { + p.sendMessage("잘못된 대상입니다."); + return false; + } + if (p.getUniqueId().equals(op)) { + p.sendMessage("자기 자신에게 초대를 보낼 수 없습니다."); } else { - p.sendMessage("국가/농장이 지정되지 않았습니다."); + p.sendMessage(args[1]+"님께 초대를 발송하였습니다."); + sendInvite(p, Bukkit.getPlayer(args[1]), m_UserInfoArray, m_FarmArray, m_NationArray, m_SquadArray,"농장"); + } + break; + } + case "분대": { + if (args.length < 1) { + p.sendMessage("초대 대상을 입력해주세요."); + return false; } + UUID op = m_UserInfoArray.getUserUUID(args[1]); + if (op == null) { + p.sendMessage("잘못된 대상입니다."); + return false; + } + if (p.getUniqueId().equals(op)) { + p.sendMessage("자기 자신에게 초대를 보낼 수 없습니다."); + } else { + p.sendMessage(args[1]+"님께 초대를 발송하였습니다."); + sendInvite(p, Bukkit.getPlayer(args[1]), m_UserInfoArray, m_FarmArray, m_NationArray, m_SquadArray,"분대"); + } + break; + } + case "수락": { + replyInvite(p, m_UserInfoArray, m_FarmArray, m_NationArray, m_SquadArray,true); break; } + case "거절": { + replyInvite(p, m_UserInfoArray, m_FarmArray, m_NationArray, m_SquadArray,false); + break; + } + default: { + p.sendMessage("명령어를 확인해주세요."); + return false; + } } return true; } - public boolean sendInvite(Player sender, Player receiver, UserInfoArray UIA, FarmArray FA, NationArray NA, String Type){ + public boolean sendInvite(Player sender, Player receiver, UserInfoArray UIA, FarmArray FA, NationArray NA, SquadArray SA, String Type){ if(!isExpired(receiver.getUniqueId())){ sender.sendMessage("응답 대기중"); return false; @@ -89,9 +118,9 @@ public class InviteMaster implements CommandExecutor { return false; } else{ - m_InviteQueue.put(receiver.getUniqueId(), new Invitation(System.currentTimeMillis(), "Farm", UIA.getUserGroupUUID(sender.getUniqueId(),"Farm"), sender, receiver)); + m_InviteQueue.put(receiver.getUniqueId(), new Invitation(System.currentTimeMillis(), "농장", UIA.getUserGroupUUID(sender.getUniqueId(),"Farm"), sender, receiver)); receiver.sendMessage(sender.getDisplayName()+"님의 "+FA.GetGroupName(UIA.getUserGroupUUID(sender.getUniqueId(),"Farm"))+"에 초대되었습니다."); - receiver.sendMessage("제한시간(5분)내 /농장 수락 혹은 /농장 거절 입력해주시기 바랍니다."); + receiver.sendMessage("제한시간(5분)내 /초대 수락 혹은 /초대 거절 입력해주시기 바랍니다."); } break; case "국가": @@ -100,44 +129,60 @@ public class InviteMaster implements CommandExecutor { return false; } else{ - m_InviteQueue.put(receiver.getUniqueId(), new Invitation(System.currentTimeMillis(), "Nation", UIA.getUserGroupUUID(sender.getUniqueId(),"Nation"), sender, receiver)); + m_InviteQueue.put(receiver.getUniqueId(), new Invitation(System.currentTimeMillis(), "국가", UIA.getUserGroupUUID(sender.getUniqueId(),"Nation"), sender, receiver)); receiver.sendMessage(sender.getDisplayName()+"님의 "+NA.GetGroupName(UIA.getUserGroupUUID(sender.getUniqueId(),"Nation"))+"에 초대되었습니다."); - receiver.sendMessage("제한시간(5분)내 /국가 수락 혹은 /국가 거절 입력해주시기 바랍니다."+receiver.getUniqueId()); + receiver.sendMessage("제한시간(5분)내 /초대 수락 혹은 /초대 수락 입력해주시기 바랍니다."+receiver.getUniqueId()); + } + break; + case "분대": + if(SA.GetGroupMemNUM(UIA.getUserGroupUUID(sender.getUniqueId(),"Squad"))>SA.GetGroupMemMaxNum(UIA.getUserGroupUUID(sender.getUniqueId(),"Squad"))){ + sender.sendMessage("인원이 초과되었습니다."); + return false; + } + else{ + m_InviteQueue.put(receiver.getUniqueId(), new Invitation(System.currentTimeMillis(), "분대", UIA.getUserGroupUUID(sender.getUniqueId(),"Squad"), sender, receiver)); + receiver.sendMessage(sender.getDisplayName()+"님의 "+SA.GetGroupName(UIA.getUserGroupUUID(sender.getUniqueId(),"Squad"))+"에 초대되었습니다."); + receiver.sendMessage("제한시간(5분)내 /초대 수락 혹은 /초대 수락 입력해주시기 바랍니다."+receiver.getUniqueId()); } break; } return true; } - public boolean replyInvite(Player receiver, UserInfoArray UIA, FarmArray FA, NationArray NA, String Type, boolean accept){ - Player sender = m_InviteQueue.get(receiver.getUniqueId()).getSender(); + public boolean replyInvite(Player receiver, UserInfoArray UIA, FarmArray FA, NationArray NA, SquadArray SA, boolean accept){ + if(isExpired(receiver.getUniqueId())){ m_InviteQueue.remove(receiver.getUniqueId()); receiver.sendMessage("수신 받은 초대가 없거나, 초대가 만료되었습니다."); return false; } + Player sender = m_InviteQueue.get(receiver.getUniqueId()).getSender(); if(!accept){ - sender.sendMessage("초대를 거절하였습니다."); + sender.sendMessage(receiver.getDisplayName()+"님께서 초대를 거절하였습니다."); receiver.sendMessage("초대를 거절하였습니다."); m_InviteQueue.remove(receiver.getUniqueId()); return false; } + + String Type = m_InviteQueue.get(receiver.getUniqueId()).getType(); switch (Type){ case "농장": - if(FA.GetGroupMemNUM(m_InviteQueue.get(sender.getUniqueId()).getUUID())>FA.GetGroupMemMaxNum(m_InviteQueue.get(sender.getUniqueId()).getUUID())){ + if(FA.GetGroupMemNUM(m_InviteQueue.get(receiver.getUniqueId()).getUUID())>FA.GetGroupMemMaxNum(m_InviteQueue.get(receiver.getUniqueId()).getUUID())){ sender.sendMessage("인원이 초과되었습니다."); receiver.sendMessage("인원이 초과되었습니다.."); m_InviteQueue.remove(receiver.getUniqueId()); return false; } else{ - FA.SignUpGroup("Farm", m_InviteQueue.get(receiver.getUniqueId()).getUUID(), m_InviteQueue.get(receiver.getUniqueId()).getReceiver().getUniqueId()); + sender.sendMessage(receiver.getDisplayName()+"님께서 초대를 수락하였습니다."); + receiver.sendMessage("가입되었습니다. "+ m_InviteQueue.get(receiver.getUniqueId()).getUUID()+" "+ receiver.getUniqueId()); + receiver.sendMessage(""+FA.SignUpGroup("Farm", m_InviteQueue.get(receiver.getUniqueId()).getUUID(), receiver.getUniqueId())); m_InviteQueue.remove(receiver.getUniqueId()); } break; case "국가": - if(NA.GetGroupMemNUM(m_InviteQueue.get(sender.getUniqueId()).getUUID())>NA.GetGroupMemMaxNum(m_InviteQueue.get(sender.getUniqueId()).getUUID())){ + if(NA.GetGroupMemNUM(m_InviteQueue.get(receiver.getUniqueId()).getUUID())>NA.GetGroupMemMaxNum(m_InviteQueue.get(receiver.getUniqueId()).getUUID())){ sender.sendMessage("인원이 초과되었습니다."); receiver.sendMessage("인원이 초과되었습니다."); m_InviteQueue.remove(receiver.getUniqueId()); @@ -145,11 +190,28 @@ public class InviteMaster implements CommandExecutor { } else{ receiver.sendMessage("가입되었습니다."+m_InviteQueue.get(receiver.getUniqueId()).getUUID()+ " "+ m_InviteQueue.get(receiver.getUniqueId()).getReceiver()); - NA.SignUpGroup("Nation", m_InviteQueue.get(receiver.getUniqueId()).getUUID(), m_InviteQueue.get(receiver.getUniqueId()).getReceiver().getUniqueId()); + NA.SignUpGroup("Nation", m_InviteQueue.get(receiver.getUniqueId()).getUUID(), receiver.getUniqueId()); m_InviteQueue.remove(receiver.getUniqueId()); } break; + case "분대": + if(SA.GetGroupMemNUM(m_InviteQueue.get(receiver.getUniqueId()).getUUID())>SA.GetGroupMemMaxNum(m_InviteQueue.get(receiver.getUniqueId()).getUUID())){ + sender.sendMessage("인원이 초과되었습니다."); + receiver.sendMessage("인원이 초과되었습니다."); + m_InviteQueue.remove(receiver.getUniqueId()); + return false; + } + else{ + receiver.sendMessage("가입되었습니다."+m_InviteQueue.get(receiver.getUniqueId()).getUUID()+ " "+ m_InviteQueue.get(receiver.getUniqueId()).getReceiver()); + SA.SignUpGroup("Squad", m_InviteQueue.get(receiver.getUniqueId()).getUUID(), receiver.getUniqueId()); + m_InviteQueue.remove(receiver.getUniqueId()); + } + break; + default: + receiver.sendMessage("다시 입력"); + break; } + return true; } private boolean isExpired(UUID uuid){ diff --git a/SquadEventHandler.java b/SquadEventHandler.java deleted file mode 100644 index b689cb6..0000000 --- a/SquadEventHandler.java +++ /dev/null @@ -1,61 +0,0 @@ -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 org.poopki.duckdns.user_db.Array.GroupArray; - -import java.util.UUID; - -public class SquadEventHandler implements CommandExecutor { - - GroupArray m_GroupArray; - UserInfoArray m_UserInfoArray; - - public SquadEventHandler(GroupArray GA, UserInfoArray UIA){ - m_GroupArray = GA; - 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_GroupArray.CreateGroup(tempUUID, args[1], p.getUniqueId()); - m_UserInfoArray.setUserGroupUUID("Party",p.getUniqueId(), tempUUID); - p.sendMessage(args[1]+"파티가 생성되었습니다."); - p.sendMessage("멤버 목록: "); - for (String Name: m_GroupArray.GetGroupMembersName(tempUUID)){ - p.sendMessage(Name); - } - p.sendMessage("파티 목록:"); - for (String Name: m_GroupArray.GetGroupNameList()){ - p.sendMessage(Name); - } - break; - } - case "가입":{ - p.sendMessage("가입 테스트"); - break; - } - case "초대":{ - p.sendMessage("초대 테스트"); - break; - } - case "강퇴":{ - p.sendMessage("강퇴 테스트"); - break; - } - case "이름":{ - p.sendMessage("현재 파티 이름"+m_GroupArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Party"))); - break; - } - } - } - return true; - } -} diff --git a/UserInfo.java b/UserInfo.java index 338ac51..c29e0fe 100644 --- a/UserInfo.java +++ b/UserInfo.java @@ -6,7 +6,7 @@ public class UserInfo extends Status { private UUID m_UUID; private String m_Name; - private static Map m_GroupUUID = new HashMap(); + private Map m_GroupUUID = new HashMap(); public UserInfo(UUID uuid, String Name, UUID Nation, UUID Squad, UUID Farm, UUID Party){ //UserInfo 초기화 super(100,100,1,10,10,10,10); //HP, MP, LEV, STR, DEX, INT, LUK m_UUID = uuid; diff --git a/UserInfoArray.java b/UserInfoArray.java index 35609f6..7ed3d72 100644 --- a/UserInfoArray.java +++ b/UserInfoArray.java @@ -6,8 +6,8 @@ import java.util.Set; import java.util.UUID; public class UserInfoArray { - private static Map m_UserInfoArray = new HashMap(); - private static Map m_UserNameUUID = new HashMap(); + private Map m_UserInfoArray = new HashMap(); + private Map m_UserNameUUID = new HashMap(); public String getUserName(UUID uuid){ // 유저 이름 return return m_UserInfoArray.get(uuid).getUserName(); } diff --git a/User_DB.java b/User_DB.java index a765c0d..70ef881 100644 --- a/User_DB.java +++ b/User_DB.java @@ -15,7 +15,8 @@ public final class User_DB extends JavaPlugin implements Listener { UserInfoArray m_InfoArrayInstance = new UserInfoArray(); // UserInfo 저장하는 Array instance 생성 FarmArray m_FarmArrayInstance = new FarmArray(m_InfoArrayInstance); NationArray m_NationArrayInstance = new NationArray(m_InfoArrayInstance); - DBUpdate Database_backup = new DBUpdate(m_InfoArrayInstance, m_AccountArrayInstance, m_FarmArrayInstance, m_NationArrayInstance); + SquadArray m_SquadArrayInstance = new SquadArray(m_InfoArrayInstance); + DBUpdate Database_backup = new DBUpdate(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance); @Override public void onEnable() { @@ -26,13 +27,14 @@ public final class User_DB extends JavaPlugin implements Listener { } catch (SQLException e) { throw new RuntimeException(e); } - getCommand("계좌").setExecutor(new AccountEventHandler(m_AccountArrayInstance,m_InfoArrayInstance)); - getCommand("농장").setExecutor(new FarmEventHandler(m_FarmArrayInstance, m_InfoArrayInstance, m_AccountArrayInstance)); - getCommand("국가").setExecutor(new NationEventHandler(m_NationArrayInstance, m_InfoArrayInstance, m_AccountArrayInstance)); - getCommand("opitem").setExecutor(new OpenInv(m_AccountArrayInstance, m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance)); - getCommand("초대").setExecutor(new InviteMaster(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance)); + getCommand("계좌").setExecutor(new AccountEventHandler(m_InfoArrayInstance, m_AccountArrayInstance)); + getCommand("농장").setExecutor(new FarmEventHandler(m_InfoArrayInstance, m_FarmArrayInstance, m_AccountArrayInstance)); + getCommand("국가").setExecutor(new NationEventHandler(m_InfoArrayInstance, m_NationArrayInstance, m_AccountArrayInstance)); + getCommand("분대").setExecutor(new SquadEventHandler(m_InfoArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance)); + getCommand("opitem").setExecutor(new OpenInv(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance)); + getCommand("초대").setExecutor(new InviteMaster(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance)); getServer().getPluginManager().registerEvents(new UserJoin(m_InfoArrayInstance, m_AccountArrayInstance),this); - getServer().getPluginManager().registerEvents(new OpenInv(m_AccountArrayInstance, m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance), this); + getServer().getPluginManager().registerEvents(new OpenInv( m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance), this);