Compare commits

...

17 Commits

  1. 14
      Array/Account.java
  2. 4
      Array/AccountArray.java
  3. 175
      Array/FarmArray.java
  4. 26
      Array/Group.java
  5. 17
      Array/GroupArray.java
  6. 56
      Array/Nation.java
  7. 187
      Array/NationArray.java
  8. 8
      Array/NationEventHandler.java
  9. 178
      Array/SquadArray.java
  10. 132
      Bank/AccountGUI.java
  11. 57
      Bank/AccountGUIEvent.java
  12. 4
      Bank/Digit.java
  13. 2
      DB/DBConnect.java
  14. 271
      DB/DBUpdate.java
  15. 44
      GUI/BaseGUI.java
  16. 4
      GUI/ItemManager.java
  17. 22
      GUI/OpenInv.java
  18. 77
      InfoGUI/ScoreboardEvent.java
  19. 102
      Research/Research.java
  20. 44
      Research/ResearchGUIEvent.java
  21. 91
      TechTree/TechGUI.java
  22. 237
      TechTree/TechGUIEvent.java
  23. 22
      TechTree/TechStat.java
  24. 4
      UserInfo.java
  25. 26
      UserJoin.java
  26. 54
      User_DB.java
  27. 77
      WorldGuard/WG.java
  28. 36
      WorldGuard/WGRegionExample.java
  29. 89
      WorldGuard/WgCommand.java

@ -6,9 +6,9 @@ public class Account {
public Account(int Balance){ // Account Balance 초기화
m_Balance = Balance;
}
public boolean setBalance(Long Amount){
if(Amount<MAX_BALANCE) {
m_Balance = Amount.intValue();
public boolean setBalance(Long Amount){ // 잔액 설정
if(Amount<MAX_BALANCE) { // 잔고가 MAX_BALANCE 이하일경우
m_Balance = Amount.intValue(); // Amount만큼 설정
return true;
}else{
return false;
@ -16,8 +16,8 @@ public class Account {
}
public int getBalance(){ return m_Balance; } //잔액 return
public boolean credit(Long Amount){ // 입금
if(m_Balance+Amount < MAX_BALANCE) {
m_Balance += Amount.intValue();
if(m_Balance+Amount < MAX_BALANCE) { // 잔고가 MAX_BALANCE 이하일경우
m_Balance += Amount.intValue(); // Amount만큼 현재 잔고에서 더하기
return true;
}
else{
@ -25,8 +25,8 @@ public class Account {
}
}
public boolean withdraw(Long Amount){ // 출금
if(m_Balance >= Amount){
m_Balance -= Amount.intValue();
if(m_Balance >= Amount){ // 잔고가 MAX_BALANCE 이하일경우
m_Balance -= Amount.intValue(); // Amount만큼 현재 잔고에서 빼기
return true;
}
return false;

@ -1,12 +1,14 @@
package org.poopki.duckdns.user_db.Array;
import org.bukkit.plugin.Plugin;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class AccountArray {
private static Map<UUID, Account> m_AccountArray = new HashMap<UUID, Account>();
Plugin plugin;
public int transfer(UUID Src, UUID Des, Long Amount){ // 송금 method
Account m_Src = m_AccountArray.get(Src);
Account m_Des = m_AccountArray.get(Des);

@ -1,12 +1,183 @@
package org.poopki.duckdns.user_db.Array;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.poopki.duckdns.user_db.UserInfoArray;
import java.util.*;
public class FarmArray extends GroupArray{
public FarmArray(UserInfoArray m_UIA){
super(m_UIA, 10);
public Map<UUID, Farm> m_FarmArray;
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;
Plugin plugin;
public FarmArray(UserInfoArray m_UIA, int num, Plugin plugin){
super(m_UIA,num,plugin);
m_UserInfoArray = m_UIA;
m_FarmArray = new HashMap<UUID, Farm>();
m_GroupNameList = new HashMap<String, UUID>();
MAX_GROUP_NUM = num;
this.plugin = plugin;
}
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_FarmArray.put(GroupUUID, new Farm(Name, m_MemberList));
m_GroupNameList.put(Name, GroupUUID);
return true;
}
}
public void SetGroupTechTree(UUID GroupUUID, String TechName, Integer set){
m_FarmArray.get(GroupUUID).SetTechTree(TechName,set);
}
public int GetGroupTechTree(UUID GroupUUID, String TechName){
return m_FarmArray.get(GroupUUID).GetTechTree(TechName);
}
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_FarmArray.put(GroupUUID, new Farm(Name, m_MemberList));
m_GroupNameList.put(Name,GroupUUID);
return true;
}
public boolean CheckGroup(String GroupType, String Name){
return m_FarmArray.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_FarmArray.containsKey(GroupUUID)){
for(UUID key: GetGroupMembersUUID(GroupUUID)){
m_UserInfoArray.setUserGroupUUID(GroupType,key,new UUID(0,0));
}
m_GroupNameList.remove(GetGroupName(GroupUUID));
m_FarmArray.remove(GroupUUID);
return true;
}
else{
return false; // Group is not exists.
}
}
public String SignUpGroup(String GroupType, UUID GroupUUID, UUID PlayerUUID){
if(m_FarmArray.containsKey(GroupUUID) && m_UserInfoArray.getUserGroupUUID(PlayerUUID, GroupType).equals(ZERO_UUID)){
Group m_Group = m_FarmArray.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_FarmArray.get(GroupUUID).isMember(PlayerUUID)) {
Group m_Group = m_FarmArray.get(GroupUUID);
m_Group.Expulsion(PlayerUUID);
m_UserInfoArray.setUserGroupUUID(GroupType,PlayerUUID,ZERO_UUID);
int temp = m_FarmArray.get(GroupUUID).getMemNUM();
if(temp==0){
m_GroupNameList.remove(m_Group.getGroupName());
m_FarmArray.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_FarmArray.get(GroupUUID).getGroupMembers()){
try {
MembersName.add(Bukkit.getPlayer(key).getDisplayName());
}
catch(NullPointerException e){
}
}
return MembersName;
}
public List<UUID> GetGroupMembersUUID(UUID GroupUUID){
return m_FarmArray.get(GroupUUID).getGroupMembers();
}
public boolean isGroupMember(UUID GroupUUID, UUID PlayerUUID){
Group m_Group = m_FarmArray.get(GroupUUID);
return m_Group.isMember(PlayerUUID);
}
public int GetGroupMemNUM(UUID GroupUUID){
Group m_Group = m_FarmArray.get(GroupUUID);
return m_Group.getMemNUM();
}
public Set<String> GetGroupNameList(){
return m_GroupNameList.keySet();
}
public Set<UUID> getKeySet(){ // 유저 목록 return
return m_FarmArray.keySet();
}
public Set<String> getNameSet() { return m_GroupNameList.keySet(); }
public String GetGroupName(UUID GroupUUID){
Group m_Group = m_FarmArray.get(GroupUUID);
return m_Group.getGroupName();
}
public int GetGroupMemMaxNum(UUID GroupUUID){
Group m_Group = m_FarmArray.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_FarmArray.get(GroupUUID).isOwner(PlayerUUID);
}
private boolean isAvaliableGroup(UUID GroupUUID){
return m_FarmArray.containsKey(GroupUUID);
}
}

@ -1,15 +1,18 @@
package org.poopki.duckdns.user_db.Array;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.inventory.Inventory;
import org.poopki.duckdns.user_db.Research.Research;
import java.util.*;
public class Group {
private String m_Name;
private List<UUID> m_MemberList = new ArrayList<>();
public String m_Name;
public List<UUID> m_MemberList = new ArrayList<>();
public List<Research> m_ResearchArray = new ArrayList<Research>();
public Map<String, Integer> m_TechStat = new HashMap<String, Integer>();
UUID ZERO_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
int MAX_FARM_NUM = 10;
Inventory research_tab;
public Group(String Name, List<UUID> uuid_list){
int index = 0;
@ -49,4 +52,15 @@ public class Group {
return false;
}
}
public void InitTechTree(String A, Integer B){
m_TechStat.put(A,B);
}
public void SetTechTree(String TechName, Integer set){
m_TechStat.replace(TechName,set);
}
public int GetTechTree(String TechName){
return m_TechStat.get(TechName);
}
}

@ -2,6 +2,7 @@ package org.poopki.duckdns.user_db.Array;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.poopki.duckdns.user_db.UserInfoArray;
import java.util.*;
@ -9,18 +10,19 @@ import java.util.*;
public class GroupArray {
protected Map<UUID, Group> m_GroupArray;
public 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){
Plugin plugin;
public GroupArray(UserInfoArray m_UIA, int num, Plugin plugin){
m_UserInfoArray = m_UIA;
m_GroupArray = new HashMap<UUID, Group>();
m_GroupNameList = new HashMap<String, UUID>();
MAX_GROUP_NUM = num;
this.plugin = plugin;
}
public boolean CreateGroup(UUID GroupUUID, String Name, UUID PlayerUUID){
@ -36,6 +38,15 @@ public class GroupArray {
}
}
public void SetGroupTechTree(UUID GroupUUID, String TechName, Integer set){
m_GroupArray.get(GroupUUID).SetTechTree(TechName,set);
}
public int GetGroupTechTree(UUID GroupUUID, String TechName){
return m_GroupArray.get(GroupUUID).GetTechTree(TechName);
}
public boolean PutGroup(UUID GroupUUID, String Name,List<UUID> PlayerUUID){
List<UUID> m_MemberList = new ArrayList<>();

@ -1,11 +1,59 @@
package org.poopki.duckdns.user_db.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import dev.lone.itemsadder.api.CustomStack;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.poopki.duckdns.user_db.Research.Research;
import java.util.*;
public class Nation extends Group{
public Nation(String Name, List<UUID> uuid_list){
String[] techtree = {"agriculture","pottery","animal_husbandry","archery","mining","sailing","calendar","writing","trapping","wheel","masonry","bronze","optics","horseback","mathematics","construction","philosophy","drama","currency","engineering","iron_working","theology","civil_service","guilds","metal_casting","compass","education","chivalry","machinery","physics","steel","astronomy","acoustics","banking","printing_press","gunpowder","navigation","architecture","economics","metallurgy","chemistry","archaeology","scientific_theory","industrialization","rifling","military_science","fertilizer","biology","electricity","steam_power","dynamite","refrigeration","radio","flight","railroad","plastics","electronics","ballistics","combustion","penicillin","atomic_theory","radar","combined_arms","ecology","nuclear_fission","rocketry","computers","telecommunications","mobile_tactics","advanced_ballistics","satellites","robotics","lasers","the_internet","globalization","particle_physics","nuclear_fusion","nanotechnology","stealth"};
public Nation(String Name, List<UUID> uuid_list, Plugin plugin){
super(Name, uuid_list);
for(int i = 0; i<3; i++){
m_ResearchArray.add(new Research("연구 테스트",plugin, m_MemberList));
//연구 프로그레스바 등록
}
//Init 테크트리
for(String Key: techtree){
InitTechTree(Key,0);
}
new BukkitRunnable(){
@Override
public void run(){
for(Research key:m_ResearchArray){
for(UUID uuid: Nation.super.getGroupMembers()){
if(Bukkit.getPlayer(uuid)!=null){
key.tech1_progressbar.addPlayer(Bukkit.getPlayer(uuid));
}
}
}
}
}.runTaskTimer(plugin,0,20);
//InitResearchItem();
}
public void InitResearchItem(){
//System.out.println(CustomStack.getInstance("research:materials-book").getDisplayName());
ArrayList <ItemStack> InitStack = new ArrayList<ItemStack>();
InitStack.add(CustomStack.getInstance("research:materials-book").getItemStack());
InitStack.add(CustomStack.getInstance("research:materials-crystal").getItemStack());
InitStack.add(CustomStack.getInstance("research:materials-god_pot").getItemStack());
m_ResearchArray.get(0).SetMaterials(InitStack); // 0-> 고대 연구 아이템 설정
}
public void AddShowResearchProgressBar(Integer index, Player player){
m_ResearchArray.get(index).tech1_progressbar.addPlayer(player);
}
public void ShowResearchProgressBar(Integer index, boolean toggle){
m_ResearchArray.get(index).tech1_progressbar.setVisible(toggle);
}
}

@ -1,9 +1,190 @@
package org.poopki.duckdns.user_db.Array;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.Plugin;
import org.poopki.duckdns.user_db.UserInfoArray;
public class NationArray extends GroupArray{
public NationArray(UserInfoArray m_UIA){
super(m_UIA, 50);
import java.util.*;
public class NationArray {
public Map<UUID, Nation> m_NationArray;
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;
Plugin plugin;
public NationArray(UserInfoArray m_UIA, int num, Plugin plugin){
m_UserInfoArray = m_UIA;
m_NationArray = new HashMap<UUID, Nation>();
m_GroupNameList = new HashMap<String, UUID>();
MAX_GROUP_NUM = num;
this.plugin = plugin;
}
public Inventory getGroupTechInv(Player player, Integer index){
return m_NationArray.get(m_UserInfoArray.getUserGroupUUID(player.getUniqueId(),"Nation")).m_ResearchArray.get(index).getInventory();
}
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_NationArray.put(GroupUUID, new Nation(Name, m_MemberList, plugin));
m_GroupNameList.put(Name, GroupUUID);
return true;
}
}
/*
public void InitGroupTechTree(UUID GroupUUID){
m_NationArray.get(GroupUUID).InitTechTree();
}
*/
public void SetGroupTechTree(UUID GroupUUID, String TechName, Integer set){
m_NationArray.get(GroupUUID).SetTechTree(TechName,set);
}
public int GetGroupTechTree(UUID GroupUUID, String TechName){
return m_NationArray.get(GroupUUID).GetTechTree(TechName);
}
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_NationArray.put(GroupUUID, new Nation(Name, m_MemberList, plugin));
m_GroupNameList.put(Name,GroupUUID);
return true;
}
public boolean CheckGroup(String GroupType, String Name){
return m_NationArray.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_NationArray.containsKey(GroupUUID)){
for(UUID key: GetGroupMembersUUID(GroupUUID)){
m_UserInfoArray.setUserGroupUUID(GroupType,key,new UUID(0,0));
}
m_GroupNameList.remove(GetGroupName(GroupUUID));
m_NationArray.remove(GroupUUID);
return true;
}
else{
return false; // Group is not exists.
}
}
public String SignUpGroup(String GroupType, UUID GroupUUID, UUID PlayerUUID){
if(m_NationArray.containsKey(GroupUUID) && m_UserInfoArray.getUserGroupUUID(PlayerUUID, GroupType).equals(ZERO_UUID)){
Group m_Group = m_NationArray.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_NationArray.get(GroupUUID).isMember(PlayerUUID)) {
Group m_Group = m_NationArray.get(GroupUUID);
m_Group.Expulsion(PlayerUUID);
m_UserInfoArray.setUserGroupUUID(GroupType,PlayerUUID,ZERO_UUID);
int temp = m_NationArray.get(GroupUUID).getMemNUM();
if(temp==0){
m_GroupNameList.remove(m_Group.getGroupName());
m_NationArray.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_NationArray.get(GroupUUID).getGroupMembers()){
try {
MembersName.add(Bukkit.getPlayer(key).getDisplayName());
}
catch(NullPointerException e){
}
}
return MembersName;
}
public List<UUID> GetGroupMembersUUID(UUID GroupUUID){
return m_NationArray.get(GroupUUID).getGroupMembers();
}
public boolean isGroupMember(UUID GroupUUID, UUID PlayerUUID){
Group m_Group = m_NationArray.get(GroupUUID);
return m_Group.isMember(PlayerUUID);
}
public int GetGroupMemNUM(UUID GroupUUID){
Group m_Group = m_NationArray.get(GroupUUID);
return m_Group.getMemNUM();
}
public Set<String> GetGroupNameList(){
return m_GroupNameList.keySet();
}
public Set<UUID> getKeySet(){ // 유저 목록 return
return m_NationArray.keySet();
}
public Set<String> getNameSet() { return m_GroupNameList.keySet(); }
public String GetGroupName(UUID GroupUUID){
Group m_Group = m_NationArray.get(GroupUUID);
return m_Group.getGroupName();
}
public int GetGroupMemMaxNum(UUID GroupUUID){
Group m_Group = m_NationArray.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_NationArray.get(GroupUUID).isOwner(PlayerUUID);
}
private boolean isAvaliableGroup(UUID GroupUUID){
return m_NationArray.containsKey(GroupUUID);
}
}

@ -6,7 +6,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.poopki.duckdns.user_db.UserInfoArray;
import org.poopki.duckdns.user_db.Research.*;
import java.util.UUID;
public class NationEventHandler implements CommandExecutor {
@ -54,7 +54,7 @@ public class NationEventHandler implements CommandExecutor {
p.sendMessage(""+m_UserInfoArray.getUserGroupUUID(key,"Nation"));
}
p.sendMessage(args[1]+"국가이 생성되었습니다.");
p.sendMessage(args[1]+"국가이 생성되었습니다."+m_NationArray.GetGroupTechTree(tempUUID,"agriculture"));
p.sendMessage("국가 멤버 목록: ");
for (String Name: m_NationArray.GetGroupMembersName(tempUUID)){
@ -280,6 +280,10 @@ public class NationEventHandler implements CommandExecutor {
p.sendMessage("==잔액: " + m_AccountArray.getAccountInfo(m_NationArray.GetUUID(args[1]))+ "원==");
break;
}
case "테크": {
m_NationArray.SetGroupTechTree(m_NationArray.GetUUID(args[1]),args[2],1);
break;
}
default: {
p.sendMessage("잘못된 명령어");
}

@ -1,9 +1,181 @@
package org.poopki.duckdns.user_db.Array;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.poopki.duckdns.user_db.UserInfoArray;
public class SquadArray extends GroupArray{
public SquadArray(UserInfoArray m_UIA){
super(m_UIA, 8);
import java.util.*;
public class SquadArray {
public Map<UUID, Squad> m_SquadArray;
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;
Plugin plugin;
public SquadArray(UserInfoArray m_UIA, int num, Plugin plugin){
m_UserInfoArray = m_UIA;
m_SquadArray = new HashMap<UUID, Squad>();
m_GroupNameList = new HashMap<String, UUID>();
MAX_GROUP_NUM = num;
this.plugin = plugin;
}
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_SquadArray.put(GroupUUID, new Squad(Name, m_MemberList));
m_GroupNameList.put(Name, GroupUUID);
return true;
}
}
public void SetGroupTechTree(UUID GroupUUID, String TechName, Integer set){
m_SquadArray.get(GroupUUID).SetTechTree(TechName,set);
}
public int GetGroupTechTree(UUID GroupUUID, String TechName){
return m_SquadArray.get(GroupUUID).GetTechTree(TechName);
}
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_SquadArray.put(GroupUUID, new Squad(Name, m_MemberList));
m_GroupNameList.put(Name,GroupUUID);
return true;
}
public boolean CheckGroup(String GroupType, String Name){
return m_SquadArray.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_SquadArray.containsKey(GroupUUID)){
for(UUID key: GetGroupMembersUUID(GroupUUID)){
m_UserInfoArray.setUserGroupUUID(GroupType,key,new UUID(0,0));
}
m_GroupNameList.remove(GetGroupName(GroupUUID));
m_SquadArray.remove(GroupUUID);
return true;
}
else{
return false; // Group is not exists.
}
}
public String SignUpGroup(String GroupType, UUID GroupUUID, UUID PlayerUUID){
if(m_SquadArray.containsKey(GroupUUID) && m_UserInfoArray.getUserGroupUUID(PlayerUUID, GroupType).equals(ZERO_UUID)){
Group m_Group = m_SquadArray.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_SquadArray.get(GroupUUID).isMember(PlayerUUID)) {
Group m_Group = m_SquadArray.get(GroupUUID);
m_Group.Expulsion(PlayerUUID);
m_UserInfoArray.setUserGroupUUID(GroupType,PlayerUUID,ZERO_UUID);
int temp = m_SquadArray.get(GroupUUID).getMemNUM();
if(temp==0){
m_GroupNameList.remove(m_Group.getGroupName());
m_SquadArray.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_SquadArray.get(GroupUUID).getGroupMembers()){
try {
MembersName.add(Bukkit.getPlayer(key).getDisplayName());
}
catch(NullPointerException e){
}
}
return MembersName;
}
public List<UUID> GetGroupMembersUUID(UUID GroupUUID){
return m_SquadArray.get(GroupUUID).getGroupMembers();
}
public boolean isGroupMember(UUID GroupUUID, UUID PlayerUUID){
Group m_Group = m_SquadArray.get(GroupUUID);
return m_Group.isMember(PlayerUUID);
}
public int GetGroupMemNUM(UUID GroupUUID){
Group m_Group = m_SquadArray.get(GroupUUID);
return m_Group.getMemNUM();
}
public Set<String> GetGroupNameList(){
return m_GroupNameList.keySet();
}
public Set<UUID> getKeySet(){ // 유저 목록 return
return m_SquadArray.keySet();
}
public Set<String> getNameSet() { return m_GroupNameList.keySet(); }
public String GetGroupName(UUID GroupUUID){
Group m_Group = m_SquadArray.get(GroupUUID);
return m_Group.getGroupName();
}
public int GetGroupMemMaxNum(UUID GroupUUID){
Group m_Group = m_SquadArray.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_SquadArray.get(GroupUUID).isOwner(PlayerUUID);
}
private boolean isAvaliableGroup(UUID GroupUUID){
return m_SquadArray.containsKey(GroupUUID);
}
}

@ -0,0 +1,132 @@
package org.poopki.duckdns.user_db.Bank;
import dev.lone.itemsadder.api.CustomStack;;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
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.GUI.ItemManager;
import org.poopki.duckdns.user_db.UserInfoArray;
import org.bukkit.inventory.ItemStack;
import java.util.UUID;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang.StringEscapeUtils;
import java.util.stream.Stream;
public class AccountGUI 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 AccountGUI(AccountArray AA, UserInfoArray UIA, FarmArray FA, NationArray NA, SquadArray SA, UUID uuid, InventoryClickEvent e) {
m_uuid=uuid;
this.inv = Bukkit.createInventory(null,54,":offset_-8::bank_main:");
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);
CustomStack stack = CustomStack.getInstance("digits:digit-zero");
ItemStack itemStack = stack.getItemStack();
*/
List<String> strList = new ArrayList<String>();
String before = String.valueOf(m_AA.getAccountInfo(m_uuid));
strList.addAll(Arrays.asList(before.split("")));
int tmp = strList.size();
for(int i=0; i<8-tmp; i++) {
strList.add(0, "0");
}
for(int i = 0; i<strList.size(); i++){
inv.setItem(10+i, CustomStack.getInstance("digits:digit-"+strList.get(i)).getItemStack());
}
}
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 TORCH:
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.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,57 @@
package org.poopki.duckdns.user_db.Bank;
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 AccountGUIEvent implements Listener,CommandExecutor {
AccountArray m_AccountArray;
UserInfoArray m_UserInfoArray;
FarmArray m_FarmArray;
NationArray m_NationArray;
SquadArray m_SquadArray;
public AccountGUIEvent(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("이벤트 발생");
AccountGUI inv = new AccountGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray,((Player) sender).getUniqueId(), null);
inv.open(player);
}
return false;
}
@EventHandler
public boolean inven_Bank(InventoryClickEvent e){
Player player = (Player) e.getWhoClicked();;
String name = e.getView().getTitle();
player.sendMessage("이벤트 발생B");
if(name.equals(":offset_-8::bank_main:")){
if(e.getCurrentItem()!=null){
e.setCancelled(true);
AccountGUI inv = new AccountGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.inven(e);
return true;
}
}
return false;
}
}

@ -0,0 +1,4 @@
package org.poopki.duckdns.user_db.Bank;
public class Digit {
}

@ -5,7 +5,7 @@ import java.sql.*;
public class DBConnect {
private static final String DB_DRIVER_CLASS = "org.mariadb.jdbc.Driver";
private static final String DB_URL = "jdbc:mariadb://poopki.duckdns.org:3307/";
private static final String DB_URL = "jdbc:mariadb://192.168.2.4:3307/";
private static final String DB_USERNAME = "mc_dev";
private static final String DB_PASSWORD = "!Rkdalsrn1027";

@ -13,7 +13,7 @@ import java.util.UUID;
public class DBUpdate {
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_URL = "jdbc:mariadb://192.168.2.4:3307/mc_dev";
private final String DB_USERNAME = "mc_dev";
private final String DB_PASSWORD = "!Rkdalsrn1027";
private UserInfoArray m_InfoArrayInstance;
@ -42,17 +42,8 @@ public class DBUpdate {
System.out.println("Connection success");
stmt = conn.createStatement();
StringBuilder sb = new StringBuilder();
String sql = sb.append("create table if not exists UserInfo(")
.append("UUID varchar(36) PRIMARY KEY,")
.append("Name varchar(15), ")
.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
.append("Account int(8),") //private
.append("Status int(8)") //private*/
String sql = sb.append("create table if not exists TechTree(")
.append("UUID varchar(36) PRIMARY KEY")
.append(")").toString();
stmt.execute(sql);
}
@ -163,6 +154,7 @@ public class DBUpdate {
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)));
}
@ -178,8 +170,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 TechTree";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
Integer index=2;
if(rs.getString(index) != null){
for(String TechName: m_NationArray.m_NationArray.get(UUID.fromString(rs.getString(1))).m_TechStat.keySet()){
m_NationArray.SetGroupTechTree(UUID.fromString(rs.getString(1)),TechName, Integer.parseInt(rs.getString(index)));
index++;
}
}
}
} 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");
@ -237,11 +264,8 @@ public class DBUpdate {
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 ){
System.out.println("데이터 입력 실패");
}
else{
System.out.println("데이터 입력 성공");
if( cnt == 0 ) {
System.out.println("[DB] 유저 데이터 입력 실패");
}
}
@ -258,36 +282,56 @@ public class DBUpdate {
conn.close();
}
}
UpdateFarmInfo();
UpdateNationInfo();
UpdateSquadInfo();
// Update Farm 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 TechTree WHERE 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_FarmArray.getKeySet()) {
for (UUID key : m_NationArray.getKeySet()) {
String sql = "REPLACE INTO Farm VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";
String sql = "REPLACE INTO TechTree VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement(sql);
int index = 2;
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()));
for (String Name : m_NationArray.m_NationArray.get(key).m_TechStat.keySet()){
pstmt.setString(index, String.valueOf(m_NationArray.m_NationArray.get(key).GetTechTree(Name)));
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("데이터 입력 성공");
System.out.println("[DB] 국가 데이터 입력 실패");
}
}
}
catch(ClassNotFoundException e){
@ -303,16 +347,22 @@ public class DBUpdate {
}
}
}
public void UpdateFarmInfo(){
try{
Class.forName("org.mariadb.jdbc.Driver");
conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
Connection 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);
String sql = "DELETE FROM Farm WHERE Farm_UUID=?";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, String.valueOf(key.toString()));
int cnt = pstmt.executeUpdate();
m_FarmArray.m_DeleteQueue.remove(key);
}
if( conn != null && !conn.isClosed()){
conn.close();
}
}
catch(ClassNotFoundException e){
e.printStackTrace();
@ -321,48 +371,32 @@ public class DBUpdate {
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()) {
Connection conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
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()));
for (UUID key : m_FarmArray.getKeySet()) {
String sql = "REPLACE INTO Farm SET ";
String sql_A = "FARM_UUID='"+String.valueOf(key.toString())+"', NAME='"+String.valueOf(m_FarmArray.GetGroupName(key))+"', Account='"+String.valueOf(m_AccountArray.getAccountInfo(key))+"',";
String sql_B = "";
int index=1;
for (UUID MemUUID : m_FarmArray.GetGroupMembersUUID(key)){
sql_B = sql_B + "MEMBER"+String.valueOf(index)+"_UUID='"+String.valueOf(MemUUID.toString())+"',";
index++;
}
for(; index<=MAX_FARM_NUM;index++){
pstmt.setString(index, null);
}
sql_B = sql_B.substring(0,sql_B.length()-1);
sql = sql+sql_A+sql_B;
PreparedStatement pstmt = conn.prepareStatement(sql);
int cnt = pstmt.executeUpdate();
if( cnt == 0 ){
System.out.println("데이터 입력 실패");
}
else{
System.out.println("데이터 입력 성공");
System.out.println("[DB] 분대 데이터 입력 실패");
}
}
if( conn != null && !conn.isClosed()){
conn.close();
}
}
catch(ClassNotFoundException e){
e.printStackTrace();
@ -371,21 +405,21 @@ public class DBUpdate {
System.err.println("에러 내용 :" + e.getMessage());
System.out.println("DB Connection fail");
}
finally {
if( conn != null && !conn.isClosed()){
conn.close();
}
}
}
public void UpdateNationInfo(){
try{
Class.forName("org.mariadb.jdbc.Driver");
conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
Connection 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);
String sql = "DELETE FROM Nation WHERE Nation_UUID=?";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, String.valueOf(key.toString()));
int cnt = pstmt.executeUpdate();
m_NationArray.m_DeleteQueue.remove(key);
}
if( conn != null && !conn.isClosed()){
conn.close();
}
}
catch(ClassNotFoundException e){
e.printStackTrace();
@ -394,40 +428,33 @@ public class DBUpdate {
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()) {
Connection conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
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()));
for (UUID key : m_NationArray.getKeySet()) {
String sql = "REPLACE INTO Nation SET ";
String sql_A = "NATION_UUID='"+String.valueOf(key.toString())+"', NAME='"+String.valueOf(m_NationArray.GetGroupName(key))+"', Account='"+String.valueOf(m_AccountArray.getAccountInfo(key))+"',";
String sql_B = "";
int index=1;
for (UUID MemUUID : m_NationArray.GetGroupMembersUUID(key)){
sql_B = sql_B + "MEMBER"+String.valueOf(index)+"_UUID='"+String.valueOf(MemUUID.toString())+"',";
index++;
}
for(; index<=11;index++){
pstmt.setString(index, null);
}
sql_B = sql_B.substring(0,sql_B.length()-1);
sql = sql+sql_A+sql_B;
PreparedStatement pstmt = conn.prepareStatement(sql);
int cnt = pstmt.executeUpdate();
if( cnt == 0 ){
System.out.println("데이터 입력 실패");
System.out.println("[DB] 분대 데이터 입력 실패");
}
else{
System.out.println("데이터 입력 성공");
System.out.println("[DB] 분대 데이터 입력 성공");
}
}
if( conn != null && !conn.isClosed()){
conn.close();
}
}
catch(ClassNotFoundException e){
@ -437,22 +464,21 @@ public class DBUpdate {
System.err.println("에러 내용 :" + e.getMessage());
System.out.println("DB Connection fail");
}
finally {
if( conn != null && !conn.isClosed()){
conn.close();
}
}
}
public void UpdateSquadInfo(){
try{
Class.forName("org.mariadb.jdbc.Driver");
conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
Connection 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);
String sql = "DELETE FROM Squad WHERE Squad_UUID=?";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, String.valueOf(key.toString()));
int cnt = pstmt.executeUpdate();
m_SquadArray.m_DeleteQueue.remove(key);
}
if( conn != null && !conn.isClosed()){
conn.close();
}
}
catch(ClassNotFoundException e){
e.printStackTrace();
@ -461,10 +487,41 @@ public class DBUpdate {
System.err.println("에러 내용 :" + e.getMessage());
System.out.println("DB Connection fail");
}
finally {
try{
Class.forName("org.mariadb.jdbc.Driver");
Connection conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
for (UUID key : m_SquadArray.getKeySet()) {
String sql = "REPLACE INTO Squad SET ";
String sql_A = "Squad_UUID='"+String.valueOf(key.toString())+"', NAME='"+String.valueOf(m_SquadArray.GetGroupName(key))+"', Account='"+String.valueOf(m_AccountArray.getAccountInfo(key))+"',";
String sql_B = "";
int index=1;
for (UUID MemUUID : m_SquadArray.GetGroupMembersUUID(key)){
sql_B = sql_B + "MEMBER"+String.valueOf(index)+"_UUID='"+String.valueOf(MemUUID.toString())+"',";
index++;
}
sql_B = sql_B.substring(0,sql_B.length()-1);
sql = sql+sql_A+sql_B;
PreparedStatement pstmt = conn.prepareStatement(sql);
int cnt = pstmt.executeUpdate();
if( cnt == 0 ){
System.out.println("[DB] 분대 데이터 입력 실패");
}
else{
System.out.println("[DB] 분대 데이터 입력 성공");
}
}
if( conn != null && !conn.isClosed()){
conn.close();
}
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
catch(SQLException e){
System.err.println("에러 내용 :" + e.getMessage());
System.out.println("DB Connection fail");
}
}
}

@ -62,49 +62,5 @@ public class BaseGUI implements Listener{
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;
}
}
}

@ -15,8 +15,8 @@ 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 btn1 = buildItem(Material.TORCH, 1, ChatColor.AQUA +"지갑 10000원 증가", "", ChatColor.GREEN + "----");
public ItemStack btn2 = buildItem(Material.TORCH, 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 + "----");

@ -1,5 +1,6 @@
package org.poopki.duckdns.user_db.GUI;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -37,14 +38,17 @@ public class OpenInv implements Listener,CommandExecutor {
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);
public boolean inven_TEST(InventoryClickEvent e){
Player player = (Player) e.getWhoClicked();
String name = e.getView().getTitle();
if(name.equals("TESTGUI")){
if(e.getCurrentItem()!=null){
e.setCancelled(true);
BaseGUI inv = new BaseGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.inven(e);
return true;
}
}
return false;
}
}

@ -0,0 +1,77 @@
package org.poopki.duckdns.user_db.InfoGUI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.*;
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 ScoreboardEvent {
ScoreboardManager manager;
Scoreboard scoreboard;
UUID ZERO_UUID = new UUID(0,0);
private UserInfoArray m_InfoArrayInstance;
private AccountArray m_AccountArray;
private FarmArray m_FarmArray;
private NationArray m_NationArray;
private SquadArray m_SquadArray;
public ScoreboardEvent(UserInfoArray m_UIA, FarmArray FA, NationArray NA, SquadArray SA, AccountArray AA){
m_InfoArrayInstance = m_UIA;
m_AccountArray = AA;
m_FarmArray = FA;
m_NationArray = NA;
m_SquadArray = SA;
}
public void ScoreboardUpdate(Player player){
manager = Bukkit.getScoreboardManager();
scoreboard = manager.getNewScoreboard();
Objective score_obj = scoreboard.registerNewObjective("Scoreboard","dummy");
score_obj.setDisplaySlot(DisplaySlot.SIDEBAR);
Score score = score_obj.getScore(ChatColor.BLUE + "==-=-=-=-=-=-==");
score.setScore(15);
Score score1 = score_obj.getScore("계좌 잔액: "+m_AccountArray.getAccountInfo(player.getUniqueId())+"원");
score1.setScore(14);
Score score3 = score_obj.getScore(ChatColor.BLUE + "==-=-=-=-=-=-==");
score3.setScore(15);
if(ZERO_UUID.equals(m_InfoArrayInstance.getUserGroupUUID(player.getUniqueId(), "Farm"))) {
Score score4 = score_obj.getScore("농장 이름: ----");
score4.setScore(14);
}
else{
Score score4 = score_obj.getScore("농장 이름: " + m_FarmArray.GetGroupName(m_InfoArrayInstance.getUserGroupUUID(player.getUniqueId(), "Farm")));
score4.setScore(14);
}
if(ZERO_UUID.equals(m_InfoArrayInstance.getUserGroupUUID(player.getUniqueId(), "Nation"))) {
Score score5 = score_obj.getScore("국가 이름: ----");
score5.setScore(13);
}
else{
Score score5 = score_obj.getScore("국가 이름: "+m_NationArray.GetGroupName(m_InfoArrayInstance.getUserGroupUUID(player.getUniqueId(), "Nation")));
score5.setScore(13);
}
if(ZERO_UUID.equals(m_InfoArrayInstance.getUserGroupUUID(player.getUniqueId(), "Squad"))) {
Score score6 = score_obj.getScore("분대 이름: ----");
score6.setScore(12);
}
else{
Score score6 = score_obj.getScore("분대 이름: "+m_SquadArray.GetGroupName(m_InfoArrayInstance.getUserGroupUUID(player.getUniqueId(), "Squad")));
score6.setScore(12);
}
player.setScoreboard(scoreboard);
}
}

@ -0,0 +1,102 @@
package org.poopki.duckdns.user_db.Research;
import dev.lone.itemsadder.api.CustomStack;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.boss.*;
import org.poopki.duckdns.user_db.Array.Account;
import org.poopki.duckdns.user_db.Array.NationArray;
import org.poopki.duckdns.user_db.UserInfoArray;
import java.sql.SQLException;
import java.util.*;
public class Research {
public Inventory research_tab;
public String m_title;
public Double m_progress=0.0;
public ArrayList <ItemStack> m_material = new ArrayList<ItemStack>();
public BossBar tech1_progressbar;
public Integer research_point=0;
public Research(String title, Plugin plugin, List<UUID>MemberList) {
research_tab = Bukkit.createInventory(null, 54, title);
tech1_progressbar = Bukkit.createBossBar(m_title, BarColor.BLUE,BarStyle.SOLID);
new BukkitRunnable(){
@Override
public void run(){
if(CheckItem()){
if(1<=m_progress) {
research_point = research_point+1;
m_progress = 0.0;
for(UUID key: MemberList){
if(Bukkit.getPlayer(key) != null){
Bukkit.getPlayer(key).sendMessage("국가의 연구가 완료되었습니다.");
}
}
}else{
System.out.println(m_progress);
m_progress = m_progress + 0.2;
}
}
tech1_progressbar.setProgress(m_progress);
for(Player p: tech1_progressbar.getPlayers()){
}
}
}.runTaskTimer(plugin,0,20);
}
public void SetMaterials(ArrayList <ItemStack> m_material){
for(ItemStack Key: m_material){
this.m_material.add(Key);
}
}
public Inventory getInventory(){
return research_tab;
}
private boolean CheckItem() {
if(0<m_material.size()&&m_material.size()<=3){
if(research_tab.containsAtLeast(m_material.get(0),1) &&research_tab.containsAtLeast(m_material.get(1),1) && research_tab.containsAtLeast(m_material.get(2),1)){
tech1_progressbar.setVisible(true);
return true;
}
else{
tech1_progressbar.setVisible(false);
return false;
}
} else if (0<m_material.size()&&m_material.size()<=6) {
if(research_tab.containsAtLeast(m_material.get(0),1) &&research_tab.containsAtLeast(m_material.get(1),1) && research_tab.containsAtLeast(m_material.get(2),1)
&& research_tab.containsAtLeast(m_material.get(3),1) &&research_tab.containsAtLeast(m_material.get(4),1) && research_tab.containsAtLeast(m_material.get(5),1)){
tech1_progressbar.setVisible(true);
return true;
}
else{
tech1_progressbar.setVisible(false);
return false;
}
}
else if (0<m_material.size()&&m_material.size()<=9){
if(research_tab.containsAtLeast(m_material.get(0),1) &&research_tab.containsAtLeast(m_material.get(1),1) && research_tab.containsAtLeast(m_material.get(2),1)
&& research_tab.containsAtLeast(m_material.get(3),1) &&research_tab.containsAtLeast(m_material.get(4),1) && research_tab.containsAtLeast(m_material.get(5),1)
&& research_tab.containsAtLeast(m_material.get(6),1) &&research_tab.containsAtLeast(m_material.get(7),1) && research_tab.containsAtLeast(m_material.get(8),1)){
tech1_progressbar.setVisible(true);
return true;
}
else{
tech1_progressbar.setVisible(false);
return false;
}
}
else {
tech1_progressbar.setVisible(false);
return false;}
}
}

@ -0,0 +1,44 @@
package org.poopki.duckdns.user_db.Research;
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.Bank.AccountGUI;
import org.poopki.duckdns.user_db.UserInfoArray;
public class ResearchGUIEvent implements Listener,CommandExecutor {
AccountArray m_AccountArray;
UserInfoArray m_UserInfoArray;
NationArray m_NationArray;
public ResearchGUIEvent(UserInfoArray m_UIA, NationArray NA){
m_UserInfoArray = m_UIA;
m_NationArray = NA;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
if(sender instanceof Player){
switch(args[0]){
case "초기화":
m_NationArray.m_NationArray.get(m_UserInfoArray.getUserGroupUUID(player.getUniqueId(),"Nation")).InitResearchItem();
case "고대":
player.sendMessage("이벤트 발생");
player.openInventory(m_NationArray.getGroupTechInv(player, 0));
break;
case "중세":
player.sendMessage("이벤트 발생");
player.openInventory(m_NationArray.getGroupTechInv(player, 1));
break;
}
}
return false;
}
}

@ -0,0 +1,91 @@
package org.poopki.duckdns.user_db.TechTree;
import dev.lone.itemsadder.api.CustomStack;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
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.GUI.ItemManager;
import org.poopki.duckdns.user_db.UserInfoArray;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class TechGUI 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 TechGUI(AccountArray AA, UserInfoArray UIA, FarmArray FA, NationArray NA, SquadArray SA, UUID uuid, InventoryClickEvent e) {
m_uuid=uuid;
this.inv = Bukkit.createInventory(null,54,":offset_-8::ancient_era:");
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);
CustomStack stack = CustomStack.getInstance("digits:digit-zero");
ItemStack itemStack = stack.getItemStack();
*/
inv.setItem(27, CustomStack.getInstance("techtree:agriculture_"+ Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"agriculture"))).getItemStack());
inv.setItem(20, CustomStack.getInstance("techtree:pottery_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"pottery"))).getItemStack());
inv.setItem(29, CustomStack.getInstance("techtree:archery_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"archery"))).getItemStack());
inv.setItem(38, CustomStack.getInstance("techtree:mining_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"mining"))).getItemStack());
inv.setItem(13, CustomStack.getInstance("techtree:animal_husbandry_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"animal_husbandry"))).getItemStack());
inv.setItem(22, CustomStack.getInstance("techtree:writing_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"writing"))).getItemStack());
inv.setItem(31, CustomStack.getInstance("techtree:masonry_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"masonry"))).getItemStack());
inv.setItem(40, CustomStack.getInstance("techtree:bronze_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"bronze"))).getItemStack());
inv.setItem(15, CustomStack.getInstance("techtree:calendar_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"calendar"))).getItemStack());
inv.setItem(24, CustomStack.getInstance("techtree:trapping_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"trapping"))).getItemStack());
inv.setItem(33, CustomStack.getInstance("techtree:writing_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"writing"))).getItemStack());
inv.setItem(42, CustomStack.getInstance("techtree:wheel_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"wheel"))).getItemStack());
inv.setItem(51, CustomStack.getInstance("techtree:optics_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"optics"))).getItemStack());
inv.setItem(17, CustomStack.getInstance("techtree:sailing_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"sailing"))).getItemStack());
inv.setItem(26, CustomStack.getInstance("techtree:mathematics_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"mathematics"))).getItemStack());
inv.setItem(35, CustomStack.getInstance("techtree:construction_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"construction"))).getItemStack());
inv.setItem(44, CustomStack.getInstance("techtree:horseback_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"horseback"))).getItemStack());
}
public void open(Player player){
player.openInventory(inv);
}
public void inven(InventoryClickEvent e){
Player p = (Player) e.getWhoClicked();
Inventory m_inv = e.getClickedInventory();
}
}

@ -0,0 +1,237 @@
package org.poopki.duckdns.user_db.TechTree;
import dev.lone.itemsadder.api.CustomStack;
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.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.ArrayList;
import java.util.List;
import java.util.UUID;
public class TechGUIEvent implements Listener,CommandExecutor {
AccountArray m_AccountArray;
UserInfoArray m_UserInfoArray;
FarmArray m_FarmArray;
NationArray m_NationArray;
SquadArray m_SquadArray;
UUID ZERO_UUID = new UUID(0,0);
ArrayList<String> PrevTech = new ArrayList<String>();
public TechGUIEvent(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){
if(ZERO_UUID.equals(m_UserInfoArray.getUserGroupUUID(((Player) sender).getUniqueId(), "Nation"))){
Player player = (Player) sender;
player.sendMessage("국가에 소속된 유저만 사용이 가능");
}
else{
Player player = (Player) sender;
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray,player.getUniqueId(), null);
inv.open(player);
}
}
return false;
}
@EventHandler
public boolean inven_Tech(InventoryClickEvent e){
Player player = (Player) e.getWhoClicked();;
String name = e.getView().getTitle();
if(name.equals(":offset_-8::ancient_era:")){
if(CheckClickItem(e.getCurrentItem(),"techtree:agriculture_0")){
e.setCancelled(true);
if(CheckPoint(player,0, "Nation")){
SelectTech(player, "Nation", "agriculture", 0);
player.sendMessage("국가 테크를 선택하였습니다.");
}
else{
player.sendMessage("테크 포인트가 부족합니다.");
}
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.open(player);
return true;
}
if(CheckClickItem(e.getCurrentItem(),"techtree:pottery_0")){
e.setCancelled(true);
PrevTech.add("agriculture");
if(CheckPoint(player,0, "Nation")){
if(CheckTechTree(player,"Nation",PrevTech)){
SelectTech(player, "Nation", "pottery", 0);
player.sendMessage("국가 테크를 선택하였습니다.");
}
else{
player.sendMessage("이전 테크를 선택하지 않았습니다.");
}
}
else{
player.sendMessage("테크 포인트가 부족합니다.");
}
PrevTech.clear();
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.open(player);
return true;
}
if(CheckClickItem(e.getCurrentItem(),"techtree:mining_0")){
e.setCancelled(true);
PrevTech.add("agriculture");
if(CheckPoint(player,0, "Nation")){
if(CheckTechTree(player,"Nation",PrevTech)){
SelectTech(player, "Nation", "mining", 0);
player.sendMessage("국가 테크를 선택하였습니다.");
}
else{
player.sendMessage("이전 테크를 선택하지 않았습니다.");
}
}
else{
player.sendMessage("테크 포인트가 부족합니다.");
}
PrevTech.clear();
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.open(player);
return true;
}
if(CheckClickItem(e.getCurrentItem(),"techtree:archery_0")){
e.setCancelled(true);
PrevTech.add("agriculture");
if(CheckPoint(player,0, "Nation")){
if(CheckTechTree(player,"Nation",PrevTech)){
SelectTech(player, "Nation", "archery", 0);
player.sendMessage("국가 테크를 선택하였습니다.");
}
else{
player.sendMessage("이전 테크를 선택하지 않았습니다.");
}
}
else{
player.sendMessage("테크 포인트가 부족합니다.");
}
PrevTech.clear();
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.open(player);
return true;
}
if(CheckClickItem(e.getCurrentItem(),"techtree:animal_husbandry_0")){
e.setCancelled(true);
PrevTech.add("pottery");
PrevTech.add("agriculture");
if(CheckPoint(player,0, "Nation")){
if(CheckTechTree(player,"Nation",PrevTech)){
SelectTech(player, "Nation", "animal_husbandry", 0);
player.sendMessage("국가 테크를 선택하였습니다.");
}
else{
player.sendMessage("이전 테크를 선택하지 않았습니다.");
}
}
else{
player.sendMessage("테크 포인트가 부족합니다.");
}
PrevTech.clear();
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.open(player);
return true;
}
if(CheckClickItem(e.getCurrentItem(),"techtree:writing_0")){
e.setCancelled(true);
PrevTech.add("pottery");
PrevTech.add("agriculture");
if(CheckPoint(player,0, "Nation")){
if(CheckTechTree(player,"Nation",PrevTech)){
SelectTech(player, "Nation", "writing", 0);
player.sendMessage("국가 테크를 선택하였습니다.");
}
else{
player.sendMessage("이전 테크를 선택하지 않았습니다.");
}
}
else{
player.sendMessage("테크 포인트가 부족합니다.");
}
PrevTech.clear();
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.open(player);
return true;
}
if(CheckClickItem(e.getCurrentItem(),"techtree:masonry_0")){
e.setCancelled(true);
PrevTech.add("archery");
PrevTech.add("agriculture");
if(CheckPoint(player,0, "Nation")){
if(CheckTechTree(player,"Nation",PrevTech)){
SelectTech(player, "Nation", "masonry", 0);
player.sendMessage("국가 테크를 선택하였습니다.");
}
else{
player.sendMessage("이전 테크를 선택하지 않았습니다.");
}
}
else{
player.sendMessage("테크 포인트가 부족합니다.");
}
PrevTech.clear();
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.open(player);
return true;
}
if(CheckClickItem(e.getCurrentItem(),"techtree:bronze_0")){
e.setCancelled(true);
PrevTech.add("mining");
PrevTech.add("agriculture");
if(CheckPoint(player,0, "Nation")){
if(CheckTechTree(player,"Nation",PrevTech)){
SelectTech(player, "Nation", "bronze", 0);
player.sendMessage("국가 테크를 선택하였습니다.");
}
else{
player.sendMessage("이전 테크를 선택하지 않았습니다.");
}
}
else{
player.sendMessage("테크 포인트가 부족합니다.");
}
PrevTech.clear();
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.open(player);
return true;
}
}
return false;
}
public boolean CheckClickItem(ItemStack ClickedItem, String Name){
return ClickedItem.getItemMeta().getDisplayName().equals(CustomStack.getInstance(Name).getItemStack().getItemMeta().getDisplayName());
}
public boolean CheckPoint(Player p, Integer page, String Type){
return !m_NationArray.m_NationArray.get(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),Type)).m_ResearchArray.get(page).research_point.equals(0);
}
public boolean CheckTechTree(Player p, String Type, ArrayList<String> PrevTech){
for(String key: PrevTech){
if(m_NationArray.m_NationArray.get(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),Type)).GetTechTree(key)==0){
return false;
}
}
return true;
}
public void SelectTech(Player p, String Type, String TechName, Integer page){
m_NationArray.m_NationArray.get(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),Type)).SetTechTree(TechName, 1);
m_NationArray.m_NationArray.get(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),Type)).m_ResearchArray.get(page).research_point--;
}
}

@ -0,0 +1,22 @@
package org.poopki.duckdns.user_db.TechTree;
import org.poopki.duckdns.user_db.UserInfo;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class TechStat {
private Map<String, Integer> m_TechStat = new HashMap<String, Integer>();
public void InitTechTree(String A, Integer B){
m_TechStat.put(A,B);
}
public void SetTechTree(String TechName, Integer set){
m_TechStat.replace(TechName,set);
}
public int GetTechTree(String TechName){
return m_TechStat.get(TechName);
}
}

@ -7,7 +7,7 @@ public class UserInfo extends Status {
private String m_Name;
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 초기화
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;
@ -25,4 +25,4 @@ public class UserInfo extends Status {
}
public UUID getUserUUID(){ return m_UUID; }
}
}

@ -1,18 +1,29 @@
package org.poopki.duckdns.user_db;
import org.bukkit.Bukkit;
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 org.poopki.duckdns.user_db.Array.*;
import org.poopki.duckdns.user_db.InfoGUI.ScoreboardEvent;
import java.util.UUID;
public class UserJoin implements Listener {
private UserInfoArray m_InfoArrayInstance;
private AccountArray m_AccountArray;
UserJoin(UserInfoArray UIA, AccountArray AA){
private FarmArray m_FarmArray;
private NationArray m_NationArray;
private SquadArray m_SquadArray;
UUID ZERO_UUID = new UUID(0,0);
private ScoreboardEvent m_ScoreboardEventHandler;
UserJoin(UserInfoArray m_UIA, FarmArray FA, NationArray NA, SquadArray SA, AccountArray AA, ScoreboardEvent SE){
m_AccountArray = AA;
m_InfoArrayInstance = UIA;
m_InfoArrayInstance = m_UIA;
m_FarmArray = FA;
m_NationArray = NA;
m_SquadArray = SA;
m_ScoreboardEventHandler = SE;
}
@EventHandler
public void PlayerLogin(PlayerJoinEvent e) {
@ -21,5 +32,14 @@ public class UserJoin implements Listener {
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);
}
m_ScoreboardEventHandler.ScoreboardUpdate(p);
if(!m_InfoArrayInstance.getUserGroupUUID(p.getUniqueId(),"Nation").equals(ZERO_UUID)){
m_NationArray.m_NationArray.get(m_InfoArrayInstance.getUserGroupUUID(p.getUniqueId(),"Nation")).AddShowResearchProgressBar(0, p);
m_NationArray.m_NationArray.get(m_InfoArrayInstance.getUserGroupUUID(p.getUniqueId(),"Nation")).AddShowResearchProgressBar(1, p);
m_NationArray.m_NationArray.get(m_InfoArrayInstance.getUserGroupUUID(p.getUniqueId(),"Nation")).AddShowResearchProgressBar(2, p);
}
}
}

@ -1,11 +1,24 @@
package org.poopki.duckdns.user_db;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.poopki.duckdns.user_db.Array.*;
import org.poopki.duckdns.user_db.Bank.AccountGUIEvent;
import org.poopki.duckdns.user_db.DB.*;
import org.poopki.duckdns.user_db.GUI.*;
import org.poopki.duckdns.user_db.InfoGUI.ScoreboardEvent;
import org.poopki.duckdns.user_db.Invite.*;
import org.poopki.duckdns.user_db.TechTree.TechGUIEvent;
import org.poopki.duckdns.user_db.Research.*;
import org.poopki.duckdns.user_db.WorldGuard.*;
import java.sql.SQLException;
@ -13,11 +26,12 @@ public final class User_DB extends JavaPlugin implements Listener {
AccountArray m_AccountArrayInstance = new AccountArray();
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);
FarmArray m_FarmArrayInstance = new FarmArray(m_InfoArrayInstance, 10,this);
NationArray m_NationArrayInstance = new NationArray(m_InfoArrayInstance,50,this);
SquadArray m_SquadArrayInstance = new SquadArray(m_InfoArrayInstance,4,this);
ScoreboardEvent m_ScoreboardEventHandler = new ScoreboardEvent(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance);
DBUpdate Database_backup = new DBUpdate(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance);
final WgCommand wgCommand = new WgCommand();
@Override
public void onEnable() {
// Plugin startup logic
@ -27,19 +41,43 @@ 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 AccountGUIEvent(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance));
getCommand("테크").setExecutor(new TechGUIEvent(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);
getCommand("연구").setExecutor(new ResearchGUIEvent(m_InfoArrayInstance, m_NationArrayInstance));
getCommand("wge").setExecutor(wgCommand);
getCommand("wge").setTabCompleter(wgCommand);
getServer().getPluginManager().registerEvents(new UserJoin(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance, m_ScoreboardEventHandler),
this);
getServer().getPluginManager().registerEvents(new OpenInv( m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance), this);
getServer().getPluginManager().registerEvents(new AccountGUIEvent(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance), this);
getServer().getPluginManager().registerEvents(new TechGUIEvent(m_InfoArrayInstance, m_FarmArrayInstance, m_NationArrayInstance, m_SquadArrayInstance, m_AccountArrayInstance), this);
//getServer().getPluginManager().registerEvents(new WgCommand(), this);
getServer().getPluginManager().registerEvents(new WGRegionExample(), this);
getCommand("지역").setExecutor(new WG(this));
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run(){
for(Player p : Bukkit.getOnlinePlayers()) {
m_ScoreboardEventHandler.ScoreboardUpdate(p);
}
try{
Database_backup.UpdateDB();
} catch (SQLException e){
throw new RuntimeException(e);
}
}
},0,20L);
}
@Override
public void onDisable() {
// Plugin shutdown logic
@ -49,4 +87,6 @@ public final class User_DB extends JavaPlugin implements Listener {
throw new RuntimeException(e);
}
}
}

@ -0,0 +1,77 @@
package org.poopki.duckdns.user_db.WorldGuard;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.managers.storage.StorageException;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class WG implements CommandExecutor {
public WorldGuardPlugin worldGuardPlugin;
private RegionManager rm;
private ProtectedRegion pr;
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
public WG(Plugin plugin){
worldGuardPlugin =getWorldGuard(plugin);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player) sender;
LocalPlayer pl= WorldGuardPlugin.inst().wrapPlayer(p);
this.rm = container.get(pl.getWorld());
if (args.length != 0) {
switch (args[0]) {
case "지상":{
// [1]: radius, [2]-[4]: center point axys(x, y, z)
Integer radius = Integer.parseInt(args[1]);
BlockVector3 min = BlockVector3.at(Integer.parseInt(args[2])-radius/2, Integer.parseInt(args[3])-10, Integer.parseInt(args[4])+radius/2);
BlockVector3 max = BlockVector3.at(Integer.parseInt(args[2])+radius/2, Integer.parseInt(args[3])+50, Integer.parseInt(args[4])-radius/2);
ProtectedRegion region = new ProtectedCuboidRegion(args[5], min, max);
this.rm.addRegion(region);
break;
}
case "지하":{
Integer radius = Integer.parseInt(args[1]);
BlockVector3 min = BlockVector3.at(Integer.parseInt(args[2])-radius/2, Integer.parseInt(args[3])-11, Integer.parseInt(args[4])+radius/2);
BlockVector3 max = BlockVector3.at(Integer.parseInt(args[2])+radius/2, Integer.parseInt(args[3])-100, Integer.parseInt(args[4])-radius/2);
ProtectedRegion region = new ProtectedCuboidRegion(args[5], min, max);
this.rm.addRegion(region);
break;
}
}
}
try {
this.rm.save();
} catch (StorageException e) {
e.printStackTrace();
p.sendMessage("region-save-error");
return false;
}
return true;
}
public WorldGuardPlugin getWorldGuard(Plugin plugin){
Plugin WGPlugin = plugin.getServer().getPluginManager().getPlugin("WorldGuard");
if(WGPlugin == null || !(WGPlugin instanceof WorldGuardPlugin)){
return null;
}
return (WorldGuardPlugin) WGPlugin;
}
public void save() throws StorageException {
this.rm.addRegion(pr);
this.rm.save();
}
}

@ -0,0 +1,36 @@
package org.poopki.duckdns.user_db.WorldGuard;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import de.netzkronehd.wgregionevents.events.RegionEnterEvent;
import de.netzkronehd.wgregionevents.events.RegionEnteredEvent;
import de.netzkronehd.wgregionevents.events.RegionLeaveEvent;
import de.netzkronehd.wgregionevents.events.RegionLeftEvent;
public class WGRegionExample implements Listener {
public static final String PREFIX = "§8[§aWGE-Example§8]§7 ";
@EventHandler
public void onRegionEnter(RegionEnterEvent e) {
e.getPlayer().sendMessage(PREFIX+"You are entering§e "+e.getRegion().getId()+"§7.");
}
@EventHandler
public void onRegionEntered(RegionEnteredEvent e) {
e.getPlayer().sendMessage(PREFIX+"You entered§e "+e.getRegion().getId()+"§7.");
}
@EventHandler
public void onRegionLeave(RegionLeaveEvent e) {
e.getPlayer().sendMessage(PREFIX+"You are leaving§e "+e.getRegion().getId()+"§7.");
}
@EventHandler
public void onRegionLeft(RegionLeftEvent e) {
e.getPlayer().sendMessage(PREFIX+"You left§e "+e.getRegion().getId()+"§7.");
}
}

@ -0,0 +1,89 @@
package org.poopki.duckdns.user_db.WorldGuard;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import de.netzkronehd.wgregionevents.api.SimpleWorldGuardAPI;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class WgCommand implements CommandExecutor, TabExecutor {
private final SimpleWorldGuardAPI simpleWorldGuardAPI;
public WgCommand() {
simpleWorldGuardAPI = new SimpleWorldGuardAPI();
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(args.length == 2) {
if(args[0].equals("playersinregion")) {
final List<Player> players = simpleWorldGuardAPI.getPlayersInRegion(args[1]);
final StringBuilder sb = new StringBuilder(WGRegionExample.PREFIX+"Player: ");
for(Player player : players) {
sb.append(player.getName()).append(", ");
}
sender.sendMessage(sb.toString());
return true;
} else if(args[0].equalsIgnoreCase("regions")) {
final Player p = Bukkit.getPlayer(args[1]);
if(p != null) {
final StringBuilder sb = new StringBuilder(WGRegionExample.PREFIX+"Regions: ");
for (ProtectedRegion region : simpleWorldGuardAPI.getRegions(p.getLocation())) {
sb.append(region.getId()).append("§7, ");
}
sender.sendMessage(sb.toString());
} else sender.sendMessage(WGRegionExample.PREFIX+"That player is offline.");
return true;
}
}
sendHelp(sender);
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
final List<String> tabs = new ArrayList<>();
if(args.length == 1) {
args[0] = args[0].toLowerCase();
if("regions".startsWith(args[0])) tabs.add("regions");
if("playersinregion".startsWith(args[0])) tabs.add("playersinregion");
} else if(args.length == 2) {
if(args[0].equalsIgnoreCase("regions")) {
args[1] = args[1].toLowerCase();
for (Player player : Bukkit.getOnlinePlayers()) {
if(player.getName().toLowerCase().startsWith(args[1])) {
tabs.add(player.getName());
}
}
} else if(args[0].equalsIgnoreCase("playersinregion")) {
args[1] = args[1].toLowerCase();
for(ProtectedRegion pr : simpleWorldGuardAPI.getRegions().values()) {
if(pr.getId().toLowerCase().startsWith(args[1])) {
tabs.add(pr.getId());
}
}
}
}
return tabs;
}
private void sendHelp(CommandSender s) {
s.sendMessage(WGRegionExample.PREFIX+"Wrong usage, please use:");
s.sendMessage("§e/wge playersinregion§8 <§eRegion§8>");
s.sendMessage("§e/wge regions§8 <§ePlayer§8>");
}
}
Loading…
Cancel
Save