Compare commits

...

23 Commits

Author SHA1 Message Date
poopki b3e5851b05 분대 시스템 추가 2 years ago
poopki d464d5a77d 그룹 초대 시스템 구현 2 years ago
poopki de6b3de02f Group Event Handler 분리 2 years ago
poopki 8295f06691 Group Event Handler 분리 2 years ago
poopki 6037d17087 Farm 이벤트 헨들러 구현 2 years ago
poopki 7ae1f2c1e6 Group Event Handler 분리 2 years ago
poopki 012f82b805 Fix minor bug 2 years ago
poopki 93c37e2d12 코드 최적화 2 years ago
poopki dbc6dc05fd 이름 수정 2 years ago
poopki 7f011904ce 이름 수정 2 years ago
poopki 29567fd793 이름 수정 2 years ago
poopki 5f7c4b2904 Fix minor bug 3 years ago
poopki fe9efa748b test 3 years ago
poopki b26bb99496 PartyArray를 GroupArray로 변경 완료 3 years ago
poopki 6bbf4c8713 To Do: PartyArray를 GroupArray로 변경 후 상속하여 사용하게끔 변경 필요. 3 years ago
poopki 71a5aa8e8c Group Base System 3 years ago
poopki fb2661d9f8 ArrayEvent handler - Overflow bug fix 3 years ago
poopki 31306337f2 ArrayEvent handler - Overflow bug fix 3 years ago
poopki 278829747a ArrayEvent handler - minor bug FIX 3 years ago
poopki 099d8e74eb ArrayEvent handler - minor bug FIX 3 years ago
poopki bdebf993bd ArrayEvent handler - minor bug clear 3 years ago
poopki 1b76db907b ArrayEvent handler 생성 3 years ago
poopki c88d55d93f Command 처리 테스트 코드 3 years ago
  1. 3
      .idea/.gitignore
  2. 6
      .idea/misc.xml
  3. 8
      .idea/modules.xml
  4. 6
      .idea/vcs.xml
  5. 21
      Account.java
  6. 34
      Array/Account.java
  7. 22
      Array/AccountArray.java
  8. 119
      Array/AccountEventHandler.java
  9. 11
      Array/Farm.java
  10. 12
      Array/FarmArray.java
  11. 286
      Array/FarmEventHandler.java
  12. 52
      Array/Group.java
  13. 170
      Array/GroupArray.java
  14. 268
      Array/GroupEventHandler.java
  15. 11
      Array/Nation.java
  16. 9
      Array/NationArray.java
  17. 290
      Array/NationEventHandler.java
  18. 10
      Array/Squad.java
  19. 9
      Array/SquadArray.java
  20. 292
      Array/SquadEventHandler.java
  21. 40
      CustomItem_test.java
  22. 376
      DB/DBUpdate.java
  23. 110
      GUI/BaseGUI.java
  24. 60
      GUI/ItemManager.java
  25. 50
      GUI/OpenInv.java
  26. BIN
      IMG/BG.png
  27. BIN
      IMG/UIA.png
  28. BIN
      IMG/logo.png
  29. 40
      Invite/Invitation.java
  30. 220
      Invite/InviteMaster.java
  31. 11
      Project.The_SEED.iml
  32. 1
      README.md
  33. 93
      Status.java
  34. 31
      UserInfo.java
  35. 21
      UserInfoArray.java
  36. 5
      UserJoin.java
  37. 24
      User_DB.java

3
.idea/.gitignore vendored

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Project.The_SEED.iml" filepath="$PROJECT_DIR$/Project.The_SEED.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -1,21 +0,0 @@
package org.poopki.duckdns.user_db;
public class Account {
private int m_Balance;
public Account(int Balance){ // Account Balance 초기화
m_Balance = Balance;
}
public int getBalance(){ return m_Balance; } //잔액 return
public void credit(int Amount){ // 입금
m_Balance +=Amount;
}
public boolean withdraw(int Amount){ // 출금
if(m_Balance >= Amount){
m_Balance -= Amount;
return true;
}
return false;
}
}

@ -0,0 +1,34 @@
package org.poopki.duckdns.user_db.Array;
public class Account {
private int m_Balance;
private int MAX_BALANCE = 2147483647;
public Account(int Balance){ // Account Balance 초기화
m_Balance = Balance;
}
public boolean setBalance(Long Amount){
if(Amount<MAX_BALANCE) {
m_Balance = Amount.intValue();
return true;
}else{
return false;
}
}
public int getBalance(){ return m_Balance; } //잔액 return
public boolean credit(Long Amount){ // 입금
if(m_Balance+Amount < MAX_BALANCE) {
m_Balance += Amount.intValue();
return true;
}
else{
return false;
}
}
public boolean withdraw(Long Amount){ // 출금
if(m_Balance >= Amount){
m_Balance -= Amount.intValue();
return true;
}
return false;
}
}

@ -1,4 +1,4 @@
package org.poopki.duckdns.user_db;
package org.poopki.duckdns.user_db.Array;
import java.util.HashMap;
import java.util.Map;
@ -7,15 +7,26 @@ import java.util.UUID;
public class AccountArray {
private static Map<UUID, Account> m_AccountArray = new HashMap<UUID, Account>();
public void transfer(UUID Src, UUID Des, int Amount){ // 송금 method
public int transfer(UUID Src, UUID Des, Long Amount){ // 송금 method
Account m_Src = m_AccountArray.get(Src);
Account m_Des = m_AccountArray.get(Des);
if(m_Src.withdraw(Amount)){ //인출 성공시 입금
m_Des.credit(Amount);
if(m_Des.credit(Amount))
{
return 1;
}
else{
m_Src.credit(Amount);
return 2;
}
}
else {
return 3;
}
}
public int getAccountInfo(UUID uuid) { // DB backup시 account 정보 접근 method
Account m_Account = m_AccountArray.get(uuid);
return m_Account.getBalance();
@ -24,4 +35,9 @@ public class AccountArray {
public void putAccountInfo(UUID uuid, int Amount) { //AccountArray 생성
m_AccountArray.put(uuid, new Account(Amount));
}
public boolean setAccountInfo(UUID uuid, Long Amount) {
Account m_Account = m_AccountArray.get(uuid);
return m_Account.setBalance(Amount);
}
}

@ -0,0 +1,119 @@
package org.poopki.duckdns.user_db.Array;
import org.bukkit.Bukkit;
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 AccountEventHandler implements CommandExecutor {
AccountArray m_AccountArray;
UserInfoArray m_UserInfoArray;
public AccountEventHandler(UserInfoArray UIA, AccountArray AA){
m_AccountArray = AA;
m_UserInfoArray = UIA;
}
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 "설정":{
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;
}
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;
}
}
break;
}
case "잔액": {
p.sendMessage("==잔액: " + m_AccountArray.getAccountInfo(p.getUniqueId()) + "원==");
break;
}
default: {
p.sendMessage("잘못된 명령어");
}
}
}
else{
p.sendMessage("명령어를 입력하세요(잔액 | 이체)");
}
return true;
}
}

@ -0,0 +1,11 @@
package org.poopki.duckdns.user_db.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class Farm extends Group{
public Farm(String Name, List<UUID> uuid_list){
super(Name, uuid_list);
}
}

@ -0,0 +1,12 @@
package org.poopki.duckdns.user_db.Array;
import org.bukkit.Bukkit;
import org.poopki.duckdns.user_db.UserInfoArray;
import java.util.*;
public class FarmArray extends GroupArray{
public FarmArray(UserInfoArray m_UIA){
super(m_UIA, 10);
}
}

@ -0,0 +1,286 @@
package org.poopki.duckdns.user_db.Array;
import org.bukkit.Bukkit;
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 FarmEventHandler implements CommandExecutor {
FarmArray m_FarmArray;
UserInfoArray m_UserInfoArray;
AccountArray m_AccountArray;
UUID ZERO_UUID = new UUID(0,0);
public FarmEventHandler(UserInfoArray UIA, FarmArray GA, AccountArray AA){
m_FarmArray = 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(), "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("가입 완료");
m_FarmArray.SignUpGroup("Farm",m_FarmArray.m_GroupNameList.get(args[1]),p.getUniqueId());
p.sendMessage("농장 멤버 목록: ");
for (String Name: m_FarmArray.GetGroupMembersName(m_FarmArray.m_GroupNameList.get(args[1]))){
p.sendMessage(Name);
}
p.sendMessage("농장 목록:");
for (String Name: m_FarmArray.GetGroupNameList()){
p.sendMessage(Name);
}
}
break;
}
case "초대":{
p.sendMessage("초대 테스트");
break;
}
case "강퇴":{
p.sendMessage("강퇴 테스트"+args[1]);
if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm").equals(ZERO_UUID)){
p.sendMessage("가입한 농장이 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Farm"));
return false;
}
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"));
m_FarmArray.ExpulsionGroupPlayer("Farm",m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Farm"),p.getUniqueId());
}
break;
}
case "이름":{
p.sendMessage("현재 파티 이름"+m_FarmArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Farm")));
break;
}
case "정보": {
for (String Name: m_FarmArray.GetGroupNameList()){
p.sendMessage("농장 이름:");
p.sendMessage(Name);
p.sendMessage("인원 목록");
for (String Name2: m_FarmArray.GetGroupMembersName(m_FarmArray.m_GroupNameList.get(Name))) {
p.sendMessage(Name2);
}
p.sendMessage("계좌 잔액:"+m_AccountArray.getAccountInfo(m_FarmArray.m_GroupNameList.get(Name)));
}
break;
}
case "계좌설정":{
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) {
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) {
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;
}
}
break;
}
case "잔액": {
p.sendMessage("==잔액: " + m_AccountArray.getAccountInfo(m_FarmArray.GetUUID(args[1]))+ "원==");
break;
}
default: {
p.sendMessage("잘못된 명령어");
}
}
}
return true;
}
}

@ -0,0 +1,52 @@
package org.poopki.duckdns.user_db.Array;
import java.util.Collections;
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<>();
UUID ZERO_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
int MAX_FARM_NUM = 10;
public Group(String Name, List<UUID> uuid_list){
int index = 0;
for(UUID key: uuid_list){
m_MemberList.add(index,key);
index++;
}
m_Name = Name;
}
public void SignUp(UUID uuid){
m_MemberList.add((UUID)uuid);
}
public void Expulsion(UUID uuid){
m_MemberList.remove(uuid);
}
public boolean isMember(UUID uuid){
return m_MemberList.contains(uuid);
}
public int getMemMaxNUM(){
return MAX_FARM_NUM;
}
public List<UUID> getGroupMembers(){ return m_MemberList;}
public int getMemNUM(){
int num = m_MemberList.size();
return num;
}
public String getGroupName(){ return m_Name; }
public int isEmpty(){return m_MemberList.size();}
public boolean isOwner(UUID uuid){
if(m_MemberList.get(0).equals(uuid)){
return true;
}else{
return false;
}
}
}

@ -0,0 +1,170 @@
package org.poopki.duckdns.user_db.Array;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.poopki.duckdns.user_db.UserInfoArray;
import java.util.*;
public class GroupArray {
protected Map<UUID, Group> m_GroupArray;
protected Map<String, UUID> m_GroupNameList;
public List<UUID> m_DeleteQueue = new ArrayList<>();
UserInfoArray m_UserInfoArray;
UUID ZERO_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
int MAX_GROUP_NUM = 10;
public GroupArray(UserInfoArray m_UIA, int num){
m_UserInfoArray = m_UIA;
m_GroupArray = new HashMap<UUID, Group>();
m_GroupNameList = new HashMap<String, UUID>();
MAX_GROUP_NUM = num;
}
public boolean CreateGroup(UUID GroupUUID, String Name, UUID PlayerUUID){
if(m_GroupNameList.containsKey(Name)){
return false; // Conflict
} else{
List<UUID> m_MemberList = new ArrayList<>();
m_MemberList.add(PlayerUUID);
m_GroupArray.put(GroupUUID, new Group(Name, m_MemberList));
m_GroupNameList.put(Name, GroupUUID);
return true;
}
}
public boolean PutGroup(UUID GroupUUID, String Name,List<UUID> PlayerUUID){
List<UUID> m_MemberList = new ArrayList<>();
Iterator <UUID> it = PlayerUUID.iterator();
while(it.hasNext()){
m_MemberList.add(it.next());
}
m_GroupArray.put(GroupUUID, new Group(Name, m_MemberList));
m_GroupNameList.put(Name,GroupUUID);
return true;
}
public boolean CheckGroup(String GroupType, String Name){
return m_GroupArray.containsKey(m_GroupNameList.get(Name));
}
public static <K, V> K getKey(Map<K, V> map, V value) {
for (K key : map.keySet()) {
if (value.equals(map.get(key))) {
return key;
}
}
return null;
}
public UUID GetUUID(String name){
return m_GroupNameList.get(name);
}
public boolean DeleteGroup(UUID GroupUUID, String GroupType){
if(m_GroupArray.containsKey(GroupUUID)){
for(UUID key: GetGroupMembersUUID(GroupUUID)){
m_UserInfoArray.setUserGroupUUID(GroupType,key,new UUID(0,0));
}
m_GroupNameList.remove(GetGroupName(GroupUUID));
m_GroupArray.remove(GroupUUID);
return true;
}
else{
return false; // Group is not exists.
}
}
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 "다른 그룹에 가입되어있습니다."; // Wrong Group
}
}
public boolean ExpulsionGroupPlayer(String GroupType, UUID GroupUUID, UUID PlayerUUID){
if(m_GroupArray.get(GroupUUID).isMember(PlayerUUID)) {
Group m_Group = m_GroupArray.get(GroupUUID);
m_Group.Expulsion(PlayerUUID);
m_UserInfoArray.setUserGroupUUID(GroupType,PlayerUUID,ZERO_UUID);
int temp = m_GroupArray.get(GroupUUID).getMemNUM();
if(temp==0){
m_GroupNameList.remove(m_Group.getGroupName());
m_GroupArray.remove(GroupUUID);
m_DeleteQueue.add(GroupUUID);
Bukkit.getPlayer(PlayerUUID).sendMessage(""+temp+" "+m_DeleteQueue);
}
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()){
try {
MembersName.add(Bukkit.getPlayer(key).getDisplayName());
}
catch(NullPointerException e){
}
}
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 int GetGroupMemNUM(UUID GroupUUID){
Group m_Group = m_GroupArray.get(GroupUUID);
return m_Group.getMemNUM();
}
public Set<String> GetGroupNameList(){
return m_GroupNameList.keySet();
}
public Set<UUID> getKeySet(){ // 유저 목록 return
return m_GroupArray.keySet();
}
public Set<String> getNameSet() { return m_GroupNameList.keySet(); }
public String GetGroupName(UUID GroupUUID){
Group m_Group = m_GroupArray.get(GroupUUID);
return m_Group.getGroupName();
}
public int GetGroupMemMaxNum(UUID GroupUUID){
Group m_Group = m_GroupArray.get(GroupUUID);
return m_Group.getMemMaxNUM();
}
public boolean isOffline(UUID uuid){
return Bukkit.getPlayer(uuid).equals(null) && !Bukkit.getOfflinePlayer(uuid).equals(null);
}
public boolean isOwner(UUID GroupUUID, UUID PlayerUUID){
return m_GroupArray.get(GroupUUID).isOwner(PlayerUUID);
}
private boolean isAvaliableGroup(UUID GroupUUID){
return m_GroupArray.containsKey(GroupUUID);
}
}

@ -0,0 +1,268 @@
package org.poopki.duckdns.user_db.Array;
import org.bukkit.Bukkit;
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 GroupEventHandler implements CommandExecutor {
GroupArray m_GroupArray;
UserInfoArray m_UserInfoArray;
AccountArray m_AccountArray;
UUID ZERO_UUID = new UUID(0,0);
String m_GroupType;
String m_Type;
public GroupEventHandler(GroupArray GA, UserInfoArray UIA, AccountArray AA, String GroupType, String Type){
m_GroupArray = GA;
m_UserInfoArray = UIA;
m_GroupType = GroupType;
m_Type=Type;
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(), m_Type).equals(ZERO_UUID)){
if(m_GroupArray.CreateGroup(tempUUID, args[1], p.getUniqueId())){
m_UserInfoArray.setUserGroupUUID(m_Type,p.getUniqueId(), tempUUID);
m_AccountArray.putAccountInfo(tempUUID,0);
p.sendMessage(args[1]+m_GroupType+"이 생성되었습니다.");
p.sendMessage(m_GroupType+" 멤버 목록: ");
for (String Name: m_GroupArray.GetGroupMembersName(tempUUID)){
p.sendMessage(Name);
}
p.sendMessage(m_GroupType+" 목록:");
for (String Name: m_GroupArray.GetGroupNameList()){
p.sendMessage(Name);
}
}
else{
p.sendMessage("이미 존재하는 "+m_GroupType+" 이름입니다.");
}
}
else{
p.sendMessage("이미"+m_GroupType+"을(를) 소유중입니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), m_Type));
}
break;
}
case "가입":{
p.sendMessage("플레이어 UUID:"+p.getUniqueId()+" 농장 UUID:"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), m_Type));
p.sendMessage("ZERO UUID:"+ZERO_UUID);
if(!m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), m_Type).equals(ZERO_UUID)){
p.sendMessage("이미 가입한 "+m_GroupType+"이(가) 존재합니다.");
}
else{
p.sendMessage("가입 완료");
m_GroupArray.SignUpGroup(m_Type,m_GroupArray.m_GroupNameList.get(args[1]),p.getUniqueId());
p.sendMessage(m_GroupType+" 멤버 목록: ");
for (String Name: m_GroupArray.GetGroupMembersName(m_GroupArray.m_GroupNameList.get(args[1]))){
p.sendMessage(Name);
}
p.sendMessage(m_GroupType+" 목록:");
for (String Name: m_GroupArray.GetGroupNameList()){
p.sendMessage(Name);
}
}
break;
}
case "초대":{
p.sendMessage("초대 테스트");
break;
}
case "강퇴":{
p.sendMessage("강퇴 테스트");
if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), m_Type).equals(ZERO_UUID)){
p.sendMessage("가입한 "+m_GroupType+"이(가) 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), m_Type));
}
else{
if(m_GroupArray.isOwner(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), m_Type), p.getUniqueId())){
if (args.length > 1) {
Player op = Bukkit.getPlayer(args[1]);
if (op != null) {
if(m_GroupArray.isGroupMember(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), m_Type),op.getUniqueId())) {
m_GroupArray.ExpulsionGroupPlayer(m_Type, m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), m_Type), p.getUniqueId());
}
else{
p.sendMessage(m_GroupType+"에 가입되지 않은 유저입니다");
}
}
else{
p.sendMessage("잘못된 대상입니다.");
}
}
else{
p.sendMessage("강퇴할 대상을 지정");
}
}
else{
p.sendMessage(m_GroupType+"주만 사용 가능한 명령어입니다."+ p.getUniqueId());
}
}
break;
}
case "탈퇴": {
if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), m_Type).equals(ZERO_UUID)){
p.sendMessage("가입한 "+m_GroupType+"이(가) 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), m_Type));
}
else{
p.sendMessage("탈퇴 플레이어 UUID:"+p.getUniqueId()+m_GroupType+" UUID:"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), m_Type));
m_GroupArray.ExpulsionGroupPlayer(m_Type,m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),m_Type),p.getUniqueId());
}
break;
}
case "이름":{
p.sendMessage("현재 "+m_GroupType+" 이름"+m_GroupArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Party")));
break;
}
case "정보": {
for (String Name: m_GroupArray.GetGroupNameList()){
p.sendMessage(m_GroupType+" 이름:");
p.sendMessage(Name);
p.sendMessage("인원 목록");
for (String Name2: m_GroupArray.GetGroupMembersName(m_GroupArray.m_GroupNameList.get(Name))) {
p.sendMessage(Name2);
}
p.sendMessage("계좌 잔액:"+m_AccountArray.getAccountInfo(m_GroupArray.m_GroupNameList.get(Name)));
}
}
case "계좌설정":{
if (p.isOp()) {
if (args.length > 1) {
if (args[1] != null) {
UUID op = m_GroupArray.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 {
p.sendMessage("관리자만 실행 가능한 명령어입니다.");
}
break;
}
case "입금": {
if (args.length > 1) {
if(args.length > 2) {
UUID op = m_GroupArray.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] + m_GroupType+"에 " + 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;
}
case "출금": {
if (args.length > 1) {
if(args.length > 2) {
UUID op = m_GroupArray.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] + m_GroupType+"에서 " + 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;
}
case "잔액": {
p.sendMessage("==잔액: " + m_AccountArray.getAccountInfo(m_GroupArray.GetUUID(args[1]))+ "원==");
break;
}
default: {
p.sendMessage("잘못된 명령어");
}
}
}
return true;
}
}

@ -0,0 +1,11 @@
package org.poopki.duckdns.user_db.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class Nation extends Group{
public Nation(String Name, List<UUID> uuid_list){
super(Name, uuid_list);
}
}

@ -0,0 +1,9 @@
package org.poopki.duckdns.user_db.Array;
import org.poopki.duckdns.user_db.UserInfoArray;
public class NationArray extends GroupArray{
public NationArray(UserInfoArray m_UIA){
super(m_UIA, 50);
}
}

@ -0,0 +1,290 @@
package org.poopki.duckdns.user_db.Array;
import org.bukkit.Bukkit;
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 NationEventHandler implements CommandExecutor {
NationArray m_NationArray;
UserInfoArray m_UserInfoArray;
AccountArray m_AccountArray;
UUID ZERO_UUID = new UUID(0,0);
public NationEventHandler(UserInfoArray UIA, NationArray GA, AccountArray AA){
m_NationArray = 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(), "Nation").equals(ZERO_UUID)){
p.sendMessage("이미 국가을 소유중"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation"));
return false;
}
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("이미 가입한 국가가 존재");
return false;
}
else{
p.sendMessage("가입 완료");
m_NationArray.SignUpGroup("Nation",m_NationArray.m_GroupNameList.get(args[1]),p.getUniqueId());
p.sendMessage("국가 멤버 목록: ");
for (String Name: m_NationArray.GetGroupMembersName(m_NationArray.m_GroupNameList.get(args[1]))){
p.sendMessage(Name);
}
p.sendMessage("국가 목록:");
for (String Name: m_NationArray.GetGroupNameList()){
p.sendMessage(Name);
}
}
break;
}
case "초대":{
p.sendMessage("초대 테스트");
break;
}
case "강퇴":{
p.sendMessage("강퇴 테스트"+args[1]);
if(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation").equals(ZERO_UUID)){
p.sendMessage("가입한 국가이 없습니다."+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation"));
return false;
}
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"));
return false;
}
else{
p.sendMessage("탈퇴 플레이어 UUID:"+p.getUniqueId()+" 국가 UUID:"+m_UserInfoArray.getUserGroupUUID(p.getUniqueId(), "Nation"));
m_NationArray.ExpulsionGroupPlayer("Nation",m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Nation"),p.getUniqueId());
}
break;
}
case "이름":{
p.sendMessage("현재 파티 이름"+m_NationArray.GetGroupName(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),"Nation")));
break;
}
case "정보": {
for (String Name: m_NationArray.GetGroupNameList()){
p.sendMessage("국가 이름:");
p.sendMessage(Name);
p.sendMessage("인원 목록");
for (String Name2: m_NationArray.GetGroupMembersName(m_NationArray.m_GroupNameList.get(Name))) {
p.sendMessage(Name2);
}
p.sendMessage("계좌 잔액:"+m_AccountArray.getAccountInfo(m_NationArray.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_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) {
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) {
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;
}
}
break;
}
case "잔액": {
p.sendMessage("==잔액: " + m_AccountArray.getAccountInfo(m_NationArray.GetUUID(args[1]))+ "원==");
break;
}
default: {
p.sendMessage("잘못된 명령어");
}
}
}
return true;
}
}

@ -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> uuid_list){
super(Name, uuid_list);
}
}

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

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

@ -0,0 +1,40 @@
package org.poopki.duckdns.user_db;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import java.util.Random;
public class CustomItem_test implements CommandExecutor { //명령어 처리 클래스는 CommandExecutor 인터페이스를 상속해야 한다.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { //명령어 실행 시
if(sender instanceof Player) { //명령어 사용자가 플레이어인 경우
Player player = (Player)sender; //명령어 사용자 객체를 플레이어 객체로 변환할 수 있음
player.sendMessage("zl존 개쩌는 테스트 명령어를 실행하셨습니다."); //사용자에게 메시지 발신
ItemStack irons = new ItemStack(Material.IRON_INGOT); //아이템을 ItemStack 객체를 생성해 만들 수 있음
ItemStack golds = new ItemStack(Material.GOLD_INGOT);
ItemStack diamonds = new ItemStack(Material.DIAMOND);
irons.setAmount(10); //아이템 갯수를 정할 수 있음
golds.setAmount(20);
diamonds.setAmount(30);
player.getInventory().addItem(irons, golds, diamonds); //플레이어의 인벤토리를 가져와 아이템을 집어넣음
return true; //true값을 반환하면 명령어가 성공한 것으로 간주
}
else if(sender instanceof ConsoleCommandSender) { //명령어 사용자가 콘솔인 경우
sender.sendMessage("콘솔에서는 이 명령어를 실행할 수 없습니다.");
return false; //false값을 반환하면 명령어가 실패한 것으로 간주
}
return false;
}
}

@ -1,25 +1,37 @@
package org.poopki.duckdns.user_db.DB;
import org.poopki.duckdns.user_db.AccountArray;
import org.poopki.duckdns.user_db.UserInfoArray;
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;
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;
public DBUpdate(UserInfoArray UIA, AccountArray AA){
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, 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;
@ -33,9 +45,9 @@ public class DBUpdate {
String sql = sb.append("create table if not exists UserInfo(")
.append("UUID varchar(36) PRIMARY KEY,")
.append("Name varchar(15), ")
.append("Nation int(8),") //public
.append("Squad int(8),") //public
.append("Farm int(8),") //public
.append("Nation varchar(36),") //public
.append("Squad varchar(36),") //public
.append("Farm varchar(36),") //public
.append("Account int(10)") //public
/*
.append("Occupation int(8),") //private
@ -58,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 {
@ -73,9 +85,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)));
}
@ -91,13 +104,124 @@ 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 Farm";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
List<UUID> m_MemberList = new ArrayList<>();
for(int index = 4; index<MAX_FARM_NUM; index++){
if(rs.getString(index) != null){
m_MemberList.add(index-4,UUID.fromString(rs.getString(index)));
}
}
m_FarmArray.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();
}
}
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 Nation";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
List<UUID> m_MemberList = new ArrayList<>();
for(int index = 4; index<MAX_FARM_NUM; index++){
if(rs.getString(index) != null){
m_MemberList.add(index-4,UUID.fromString(rs.getString(index)));
}
}
m_NationArray.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();
}
}
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<UUID> 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();
}
}
}
public void UpdateDB() throws SQLException { // 서버 종료시 DB 업데이트
Connection conn = null;
PreparedStatement pstmt;
// Update UserINFO
try{
Class.forName("org.mariadb.jdbc.Driver");
conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
@ -108,9 +232,9 @@ public class DBUpdate {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, String.valueOf(key.toString()));
pstmt.setString(2, String.valueOf(m_InfoArrayInstance.getUserName(key)));
pstmt.setString(3, String.valueOf(11));
pstmt.setString(4, String.valueOf(23));
pstmt.setString(5, String.valueOf(56));
pstmt.setString(3, String.valueOf(m_InfoArrayInstance.getUserGroupUUID(key, "Nation")));
pstmt.setString(4, String.valueOf(m_InfoArrayInstance.getUserGroupUUID(key, "Squad")));
pstmt.setString(5, String.valueOf(m_InfoArrayInstance.getUserGroupUUID(key, "Farm")));
pstmt.setString(6, String.valueOf(m_AccountArray.getAccountInfo(key)));
int cnt = pstmt.executeUpdate();
if( cnt == 0 ){
@ -134,5 +258,213 @@ public class DBUpdate {
conn.close();
}
}
// Update Farm Info
try{
Class.forName("org.mariadb.jdbc.Driver");
conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
for (UUID key : m_FarmArray.getKeySet()) {
String sql = "REPLACE INTO Farm VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, String.valueOf(key.toString()));
pstmt.setString(2, String.valueOf(m_FarmArray.GetGroupName(key)));
pstmt.setString(3, String.valueOf(m_AccountArray.getAccountInfo(key)));
int index = 4;
for (UUID MemUUID : m_FarmArray.GetGroupMembersUUID(key)){
pstmt.setString(index, String.valueOf(MemUUID.toString()));
index++;
}
for(; index<=MAX_FARM_NUM;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_FarmArray.m_DeleteQueue){
String sql = "DELETE FROM Farm WHERE FARM_UUID=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, String.valueOf(key.toString()));
int cnt = pstmt.executeUpdate();
m_FarmArray.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();
}
}
// Update nation Info
try{
Class.forName("org.mariadb.jdbc.Driver");
conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
for (UUID key: m_NationArray.m_DeleteQueue){
String sql = "DELETE FROM Nation WHERE NATION_UUID (?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, String.valueOf(key.toString()));
int cnt = pstmt.executeUpdate();
m_NationArray.m_DeleteQueue.remove(key);
}
for (UUID key : m_NationArray.getKeySet()) {
String sql = "REPLACE INTO Nation VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, String.valueOf(key.toString()));
pstmt.setString(2, String.valueOf(m_NationArray.GetGroupName(key)));
pstmt.setString(3, String.valueOf(m_AccountArray.getAccountInfo(key)));
int index = 4;
for (UUID MemUUID : m_NationArray.GetGroupMembersUUID(key)){
pstmt.setString(index, String.valueOf(MemUUID.toString()));
index++;
}
for(; index<=MAX_FARM_NUM;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_NationArray.m_DeleteQueue){
String sql = "DELETE FROM Nation WHERE NATION_UUID=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, String.valueOf(key.toString()));
int cnt = pstmt.executeUpdate();
m_NationArray.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();
}
}
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();
}
}
}
}

@ -0,0 +1,110 @@
package org.poopki.duckdns.user_db.GUI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
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;
public class BaseGUI implements Listener{
private final Inventory inv;
UUID m_uuid;
ItemManager m_ItemManager= new ItemManager();
AccountArray m_AA;
UserInfoArray m_UIA;
FarmArray m_FA;
NationArray m_NA;
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_SA = SA;
initItemSetting();
}
private void initItemSetting() {
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);
inv.setItem(10, m_ItemManager.btn3);
inv.setItem(19, m_ItemManager.btn4);
inv.setItem(11, m_ItemManager.btn5);
inv.setItem(20, m_ItemManager.btn6);
}
public void open(Player player){
player.openInventory(inv);
}
public void inven(InventoryClickEvent e){
Player p = (Player) e.getWhoClicked();
Inventory m_inv = e.getClickedInventory();
if (e.getInventory() != m_inv) return;
switch(e.getCurrentItem().getType()){
case CANDLE:
e.setCancelled(true);
p.sendMessage("10000원 증가");
m_AA.setAccountInfo(p.getUniqueId(), (long)m_AA.getAccountInfo(p.getUniqueId())+10000);
initItemSetting();
p.openInventory(inv);
break;
case BEEF:
e.setCancelled(true);
p.sendMessage("10000원 감소");
m_AA.setAccountInfo(p.getUniqueId(), (long)m_AA.getAccountInfo(p.getUniqueId())-10000);
initItemSetting();
p.openInventory(inv);
break;
case TORCH:
e.setCancelled(true);
p.sendMessage("국가 10000원 증가"+ m_AA.getAccountInfo(m_UIA.getUserGroupUUID(m_uuid, "Nation")));
m_AA.setAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Nation"), (long)m_AA.getAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Nation"))+10000);
initItemSetting();
p.openInventory(inv);
break;
case GRASS:
e.setCancelled(true);
p.sendMessage("국가 10000원 감소"+ m_AA.getAccountInfo(m_UIA.getUserGroupUUID(m_uuid, "Nation")));
m_AA.setAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Nation"), (long)m_AA.getAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Nation"))-10000);
initItemSetting();
p.openInventory(inv);
break;
case DIAMOND:
e.setCancelled(true);
p.sendMessage("농장 10000원 증가"+ m_AA.getAccountInfo(m_UIA.getUserGroupUUID(m_uuid, "Farm")));
m_AA.setAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Farm"), (long)m_AA.getAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Farm"))+10000);
initItemSetting();
p.openInventory(inv);
break;
case IRON_INGOT:
e.setCancelled(true);
p.sendMessage("농장 10000원 감소"+ m_AA.getAccountInfo(m_UIA.getUserGroupUUID(m_uuid, "Farm")));
m_AA.setAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Farm"), (long)m_AA.getAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Farm"))-10000);
initItemSetting();
p.openInventory(inv);
break;
}
}
}

@ -0,0 +1,60 @@
package org.poopki.duckdns.user_db.GUI;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
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;
import java.util.UUID;
public class ItemManager {
UUID ZERO_UUID = new UUID(0,0);
public ItemStack btn1 = buildItem(Material.CANDLE, 1, ChatColor.AQUA +"지갑 10000원 증가", "", ChatColor.GREEN + "----");
public ItemStack btn2 = buildItem(Material.BEEF, 1, ChatColor.AQUA +"지갑 10000원 감소", "", ChatColor.GREEN + "----");
public ItemStack btn3 = buildItem(Material.TORCH, 1, ChatColor.AQUA +"국가 10000원 증가", "", ChatColor.GREEN + "----");
public ItemStack btn4 = buildItem(Material.GRASS, 1, ChatColor.AQUA +"국가 10000원 감소", "", ChatColor.GREEN + "----");
public ItemStack btn5 = buildItem(Material.DIAMOND, 1, ChatColor.AQUA +"농장 10000원 증가", "", ChatColor.GREEN + "----");
public ItemStack btn6 = buildItem(Material.IRON_INGOT, 1, ChatColor.AQUA +"농장 10000원 증가", "", ChatColor.GREEN + "----");
private static ItemStack buildItem(Material type, int amount, String displayName, String... lore) {
ItemStack stack = new ItemStack(type, amount);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(displayName);
meta.setLore(Arrays.asList(lore));
stack.setItemMeta(meta);
return stack;
}
public ItemStack GetBalance(AccountArray AA, UserInfoArray UIA, FarmArray FA, NationArray NA, SquadArray SA, UUID m_uuid, String Type){
ItemStack dia = null;
switch (Type){
case "User":
dia = buildItem(Material.DIAMOND, 1, ChatColor.AQUA +""+UIA.getUserName(m_uuid), "잔액", ChatColor.GREEN + ""+AA.getAccountInfo(m_uuid));
break;
case "Farm":
if(ZERO_UUID.equals(UIA.getUserGroupUUID(m_uuid, "Farm"))){
dia = buildItem(Material.DIAMOND, 1, ChatColor.AQUA +"농장 없음", "잔액", ChatColor.GREEN + "----");
}else{
dia = buildItem(Material.DIAMOND, 1, ChatColor.AQUA +""+FA.GetGroupName(UIA.getUserGroupUUID(m_uuid,"Farm")), "잔액", ChatColor.GREEN + ""+AA.getAccountInfo(UIA.getUserGroupUUID(m_uuid, "Farm")));
}
break;
case "Nation":
if(ZERO_UUID.equals(UIA.getUserGroupUUID(m_uuid, "Nation"))){
dia = buildItem(Material.DIAMOND, 1, ChatColor.AQUA +"국가 없음", "잔액", ChatColor.GREEN + "----");
}
else{
dia = buildItem(Material.DIAMOND, 1, ChatColor.AQUA +""+NA.GetGroupName(UIA.getUserGroupUUID(m_uuid, "Nation")), "잔액", ChatColor.GREEN + ""+AA.getAccountInfo(UIA.getUserGroupUUID(m_uuid, "Nation")));
}
break;
}
return dia;
}
}

@ -0,0 +1,50 @@
package org.poopki.duckdns.user_db.GUI;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
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 {
AccountArray m_AccountArray;
UserInfoArray m_UserInfoArray;
FarmArray m_FarmArray;
NationArray m_NationArray;
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, m_SquadArray,((Player) sender).getUniqueId(), null);
inv.open(player);
}
return false;
}
@EventHandler
public void inven2(InventoryClickEvent e){
Player player = (Player) e.getWhoClicked();;
player.sendMessage("이벤트 발생");
BaseGUI inv = new BaseGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.inven(e);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

@ -0,0 +1,40 @@
package org.poopki.duckdns.user_db.Invite;
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.UserInfoArray;
import java.util.UUID;
public class Invitation {
protected long Time;
protected String Type;
protected UUID uuid;
protected Player sender;
protected Player receiver;
public Invitation(long Time, String Type, UUID uuid, Player sender, Player receiver){
this.Time = Time;
this.Type = Type;
this.uuid = uuid;
this.sender = sender;
this.receiver = receiver;
}
public long getTime(){
return this.Time;
}
public String getType(){
return this.Type;
}
public UUID getUUID(){
return this.uuid;
}
public Player getSender(){return this.sender;}
public Player getReceiver(){ return this.receiver;}
}

@ -0,0 +1,220 @@
package org.poopki.duckdns.user_db.Invite;
import org.bukkit.Bukkit;
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.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;
import java.util.Map;
import java.util.UUID;
public class InviteMaster implements CommandExecutor {
private static Map<UUID, Invitation> m_InviteQueue = new HashMap<UUID, Invitation>();
UserInfoArray m_UserInfoArray;
FarmArray m_FarmArray;
NationArray m_NationArray;
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) {
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 "농장": {
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 "분대": {
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, SquadArray SA, String Type){
if(!isExpired(receiver.getUniqueId())){
sender.sendMessage("응답 대기중");
return false;
}
switch (Type){
case "농장":
if(FA.GetGroupMemNUM(UIA.getUserGroupUUID(sender.getUniqueId(),"Farm"))>FA.GetGroupMemMaxNum(UIA.getUserGroupUUID(sender.getUniqueId(),"Farm"))){
sender.sendMessage("인원이 초과되었습니다.");
return false;
}
else{
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분)내 /초대 수락 혹은 /초대 거절 입력해주시기 바랍니다.");
}
break;
case "국가":
if(NA.GetGroupMemNUM(UIA.getUserGroupUUID(sender.getUniqueId(),"Nation"))>NA.GetGroupMemMaxNum(UIA.getUserGroupUUID(sender.getUniqueId(),"Nation"))){
sender.sendMessage("인원이 초과되었습니다.");
return false;
}
else{
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());
}
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, 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(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(receiver.getUniqueId()).getUUID())>FA.GetGroupMemMaxNum(m_InviteQueue.get(receiver.getUniqueId()).getUUID())){
sender.sendMessage("인원이 초과되었습니다.");
receiver.sendMessage("인원이 초과되었습니다..");
m_InviteQueue.remove(receiver.getUniqueId());
return false;
}
else{
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(receiver.getUniqueId()).getUUID())>NA.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());
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){
return !m_InviteQueue.containsKey(uuid) || (System.currentTimeMillis() - m_InviteQueue.get(uuid).getTime()) >= 300000L;
}
}

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" packagePrefix="org.poopki.duckdns.user_db" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1 @@
![](http://poopki.duckdns.org:3000/poopki/Project.The_SEED/raw/branch/master/IMG/logo.png)

@ -1,29 +1,88 @@
package org.poopki.duckdns.user_db;
public class Status {
int m_HP;
int m_MP;
int m_Level;
int m_BASE_HP;
int m_BASE_MP;
int m_BASE_STR;
int m_BASE_DEX;
int m_BASE_INT;
int m_BASE_LUK;
int m_BASE_PATK;
int m_BASE_PDEF;
int m_BASE_MATK;
int m_BASE_MDEF;
int m_EQ_HP;
int m_EQ_MP;
int m_STR;
int m_DEX;
int m_INT;
int m_LUK;
int m_EQ_STR;
int m_EQ_DEX;
int m_EQ_INT;
int m_EQ_LUK;
int m_PATK;
int m_PDEF;
int m_MATK;
int m_MDEF;
int m_EQ_PATK;
int m_EQ_PDEF;
int m_EQ_MATK;
int m_EQ_MDEF;
int m_EXP;
int m_MAX_EXP;
int m_Level;
//방어율 = (방어력 / (100 + 방어력)
//Add Equipment Class instance
public Status(int HP, int MP, int Level, int STR, int DEX, int INT, int LUK){
m_HP = HP;
m_MP = MP;
m_BASE_HP = HP;
m_BASE_MP = MP;
m_Level = Level;
m_STR = STR;
m_DEX = DEX;
m_INT = INT;
m_LUK = LUK;
m_BASE_STR = STR;
m_BASE_DEX = DEX;
m_BASE_INT = INT;
m_BASE_LUK = LUK;
}
public int GetBaseHP(){return m_BASE_HP;}
public int GetBaseMP(){return m_BASE_MP;}
public int GetBaseSTR(){return m_BASE_STR;}
public int GetBaseDEX(){return m_BASE_DEX;}
public int GetBaseINT(){return m_BASE_INT;}
public int GetBaseLUK(){return m_BASE_LUK;}
public int GetEXP(){return m_EXP;}
public int GetMaxEXP(){return m_MAX_EXP;}
public int GetLevel(){return m_Level;}
public int SetBaseHP(int HP){return m_BASE_HP=HP;}
public int SetBaseMP(int MP){return m_BASE_MP=MP;}
public int SetBaseSTR(int STR){return m_BASE_STR=STR;}
public int SetBaseDEX(int DEX){return m_BASE_DEX=DEX;}
public int SetBaseINT(int INT){return m_BASE_INT=INT;}
public int SetBaseLUK(int LUK){return m_BASE_LUK=LUK;}
public int SetEXP(int EXP){return m_EXP=EXP;}
public int SetMaxEXP(int EXP){return m_MAX_EXP=EXP;}
public int SetLevel(int Level){return m_Level=Level;}
public int GetBasePATK(){return m_BASE_PATK;}
public int GetBasePDEF(){return m_BASE_PDEF;}
public int GetBaseMATK(){return m_BASE_MATK;}
public int GetBaseMDEF(){return m_BASE_MDEF;}
public int GetEqHP(){return m_EQ_HP;}
public int GetEqMP(){return m_EQ_MP;}
public int GetEqSTR(){return m_EQ_STR;}
public int GetEqDEX(){return m_EQ_DEX;}
public int GetEqINT(){return m_EQ_INT;}
public int GetEqLUK(){return m_EQ_LUK;}
public int SetEqHP(int HP){return m_EQ_HP=HP;}
public int SetEqMP(int MP){return m_EQ_MP=MP;}
public int SetEqSTR(int STR){return m_EQ_STR=STR;}
public int SetEqDEX(int DEX){return m_EQ_DEX=DEX;}
public int SetEqINT(int INT){return m_EQ_INT=INT;}
public int SetEqLUK(int LUK){return m_EQ_LUK=LUK;}
public int GetEqPATK(){return m_EQ_PATK;}
public int GetEqPDEF(){return m_EQ_PDEF;}
public int GetEqMATK(){return m_EQ_MATK;}
public int GetEqMDEF(){return m_EQ_MDEF;}
}

@ -1,37 +1,28 @@
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;
public UserInfo(UUID uuid, String Name, int Nation, int Squad, int Farm){ //UserInfo 초기화
super(100,100,1,10,10,10,10);
private 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); //HP, MP, LEV, STR, DEX, INT, LUK
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; }
}

@ -6,8 +6,8 @@ import java.util.Set;
import java.util.UUID;
public class UserInfoArray {
private static Map<UUID, UserInfo> m_UserInfoArray = new HashMap<UUID, UserInfo>();
private Map<UUID, UserInfo> m_UserInfoArray = new HashMap<UUID, UserInfo>();
private Map<String, UUID> m_UserNameUUID = new HashMap();
public String getUserName(UUID uuid){ // 유저 이름 return
return m_UserInfoArray.get(uuid).getUserName();
}
@ -17,7 +17,20 @@ public class UserInfoArray {
public Set<UUID> getKeySet(){ // 유저 목록 return
return m_UserInfoArray.keySet();
}
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 UUID getUserGroupUUID(UUID PlayerUUID, String GroupType){
return m_UserInfoArray.get(PlayerUUID).GetGroupUUID(GroupType);
}
public UUID getUserUUID(String Name){
return m_UserNameUUID.get(Name);
}
public void setUserGroupUUID(String GroupType, UUID PlayerUUID, UUID GroupUUID){
m_UserInfoArray.get(PlayerUUID).SetGroupUUID(GroupType,GroupUUID);
}
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));
m_UserNameUUID.put(Name, uuid);
}
}

@ -3,6 +3,9 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.poopki.duckdns.user_db.Array.AccountArray;
import java.util.UUID;
public class UserJoin implements Listener {
private UserInfoArray m_InfoArrayInstance;
@ -15,7 +18,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);
}
}

@ -2,19 +2,22 @@ package org.poopki.duckdns.user_db;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.poopki.duckdns.user_db.Array.*;
import org.poopki.duckdns.user_db.DB.*;
import java.sql.Connection;
import org.poopki.duckdns.user_db.GUI.*;
import org.poopki.duckdns.user_db.Invite.*;
import java.sql.SQLException;
import java.sql.Statement;
public final class User_DB extends JavaPlugin implements Listener {
AccountArray m_AccountArrayInstance = new AccountArray();
UserInfoArray m_InfoArrayInstance = new UserInfoArray(); // UserInfo저장하는 Array instance 생성
UserInfoArray m_InfoArrayInstance = new UserInfoArray(); // UserInfo 저장하는 Array instance 생성
FarmArray m_FarmArrayInstance = new FarmArray(m_InfoArrayInstance);
NationArray m_NationArrayInstance = new NationArray(m_InfoArrayInstance);
SquadArray m_SquadArrayInstance = new SquadArray(m_InfoArrayInstance);
DBUpdate Database_backup = new DBUpdate(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance);
DBUpdate Database_backup = new DBUpdate(m_InfoArrayInstance, m_AccountArrayInstance);
@Override
public void onEnable() {
// Plugin startup logic
@ -24,8 +27,17 @@ public final class User_DB extends JavaPlugin implements Listener {
} catch (SQLException e) {
throw new RuntimeException(e);
}
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_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance), this);
}
@Override

Loading…
Cancel
Save