GUI
poopki 1 year ago
parent 2217f435c2
commit 36b0fec006
  1. 14
      Array/Account.java
  2. 4
      Array/AccountArray.java
  3. 175
      Array/FarmArray.java
  4. 93
      Array/Group.java
  5. 9
      Array/GroupArray.java
  6. 132
      Array/Nation.java
  7. 187
      Array/NationArray.java
  8. 4
      Array/NationEventHandler.java
  9. 178
      Array/SquadArray.java
  10. 13
      Bank/AccountGUI.java
  11. 19
      Bank/AccountGUIEvent.java
  12. 4
      Bank/Digit.java
  13. 280
      DB/DBUpdate.java
  14. 44
      GUI/BaseGUI.java
  15. 4
      GUI/Digit.java
  16. 4
      GUI/ItemManager.java
  17. 21
      GUI/OpenInv.java
  18. 64
      GUI/TechGUIEvent.java
  19. 101
      GUI/TechStat.java
  20. 4
      InfoGUI/ScoreboardEvent.java
  21. 102
      Research/Research.java
  22. 45
      Research/ResearchGUIEvent.java
  23. 49
      TechTree/TechGUI.java
  24. 237
      TechTree/TechGUIEvent.java
  25. 22
      TechTree/TechStat.java
  26. 11
      UserJoin.java
  27. 36
      User_DB.java
  28. 77
      WorldGuard/WG.java
  29. 36
      WorldGuard/WGRegionExample.java
  30. 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,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;
import java.util.*;
public class FarmArray extends GroupArray{
public FarmArray(UserInfoArray m_UIA){
super(m_UIA, 10);
public class FarmArray {
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){
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,14 +1,18 @@
package org.poopki.duckdns.user_db.Array;
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 List<String> TechList = Arrays.asList("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 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;
@ -16,7 +20,6 @@ public class Group {
m_MemberList.add(index,key);
index++;
}
InitTechTree();
m_Name = Name;
}
@ -50,86 +53,8 @@ public class Group {
}
}
public void InitTechTree(){
m_TechStat.put("agriculture",0);
m_TechStat.put("pottery",0);
m_TechStat.put("animal_husbandry",0);
m_TechStat.put("archery",0);
m_TechStat.put("mining",0);
m_TechStat.put("sailing",0);
m_TechStat.put("calendar",0);
m_TechStat.put("writing",0);
m_TechStat.put("trapping",0);
m_TechStat.put("wheel",0);
m_TechStat.put("masonry",0);
m_TechStat.put("bronze",0);
m_TechStat.put("optics",0);
m_TechStat.put("horseback",0);
m_TechStat.put("mathematics",0);
m_TechStat.put("construction",0);
m_TechStat.put("philosophy",0);
m_TechStat.put("drama",0);
m_TechStat.put("currency",0);
m_TechStat.put("engineering",0);
m_TechStat.put("iron_working",0);
m_TechStat.put("theology",0);
m_TechStat.put("civil_service",0);
m_TechStat.put("guilds",0);
m_TechStat.put("metal_casting",0);
m_TechStat.put("compass",0);
m_TechStat.put("education",0);
m_TechStat.put("chivalry",0);
m_TechStat.put("machinery",0);
m_TechStat.put("physics",0);
m_TechStat.put("steel",0);
m_TechStat.put("astronomy",0);
m_TechStat.put("acoustics",0);
m_TechStat.put("banking",0);
m_TechStat.put("printing_press",0);
m_TechStat.put("gunpowder",0);
m_TechStat.put("navigation",0);
m_TechStat.put("architecture",0);
m_TechStat.put("economics",0);
m_TechStat.put("metallurgy",0);
m_TechStat.put("chemistry",0);
m_TechStat.put("archaeology",0);
m_TechStat.put("scientific_theory",0);
m_TechStat.put("industrialization",0);
m_TechStat.put("rifling",0);
m_TechStat.put("military_science",0);
m_TechStat.put("fertilizer",0);
m_TechStat.put("biology",0);
m_TechStat.put("electricity",0);
m_TechStat.put("steam_power",0);
m_TechStat.put("dynamite",0);
m_TechStat.put("refrigeration",0);
m_TechStat.put("radio",0);
m_TechStat.put("flight",0);
m_TechStat.put("railroad",0);
m_TechStat.put("plastics",0);
m_TechStat.put("electronics",0);
m_TechStat.put("ballistics",0);
m_TechStat.put("combustion",0);
m_TechStat.put("penicillin",0);
m_TechStat.put("atomic_theory",0);
m_TechStat.put("radar",0);
m_TechStat.put("combined_arms",0);
m_TechStat.put("ecology",0);
m_TechStat.put("nuclear_fission",0);
m_TechStat.put("rocketry",0);
m_TechStat.put("computers",0);
m_TechStat.put("telecommunications",0);
m_TechStat.put("mobile_tactics",0);
m_TechStat.put("advanced_ballistics",0);
m_TechStat.put("satellites",0);
m_TechStat.put("robotics",0);
m_TechStat.put("lasers",0);
m_TechStat.put("the_internet",0);
m_TechStat.put("globalization",0);
m_TechStat.put("particle_physics",0);
m_TechStat.put("nuclear_fusion",0);
m_TechStat.put("nanotechnology",0);
m_TechStat.put("stealth",0);
public void InitTechTree(String A, Integer B){
m_TechStat.put(A,B);
}
public void SetTechTree(String TechName, Integer set){
m_TechStat.replace(TechName,set);

@ -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.*;
@ -15,12 +16,13 @@ public class GroupArray {
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,9 +38,6 @@ public class GroupArray {
}
}
public void InitGroupTechTree(UUID GroupUUID){
m_GroupArray.get(GroupUUID).InitTechTree();
}
public void SetGroupTechTree(UUID GroupUUID, String TechName, Integer set){
m_GroupArray.get(GroupUUID).SetTechTree(TechName,set);

@ -1,93 +1,57 @@
package org.poopki.duckdns.user_db.Array;
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);
}
private Map<String, Integer> m_TechStat = new HashMap<String, Integer>();
public void InitTechTree(){
m_TechStat.put("agriculture",0);
m_TechStat.put("pottery",0);
m_TechStat.put("animal_husbandry",0);
m_TechStat.put("archery",0);
m_TechStat.put("mining",0);
m_TechStat.put("sailing",0);
m_TechStat.put("calendar",0);
m_TechStat.put("writing",0);
m_TechStat.put("trapping",0);
m_TechStat.put("wheel",0);
m_TechStat.put("masonry",0);
m_TechStat.put("bronze",0);
m_TechStat.put("optics",0);
m_TechStat.put("horseback",0);
m_TechStat.put("mathematics",0);
m_TechStat.put("construction",0);
m_TechStat.put("philosophy",0);
m_TechStat.put("drama",0);
m_TechStat.put("currency",0);
m_TechStat.put("engineering",0);
m_TechStat.put("iron_working",0);
m_TechStat.put("theology",0);
m_TechStat.put("civil_service",0);
m_TechStat.put("guilds",0);
m_TechStat.put("metal_casting",0);
m_TechStat.put("compass",0);
m_TechStat.put("education",0);
m_TechStat.put("chivalry",0);
m_TechStat.put("machinery",0);
m_TechStat.put("physics",0);
m_TechStat.put("steel",0);
m_TechStat.put("astronomy",0);
m_TechStat.put("acoustics",0);
m_TechStat.put("banking",0);
m_TechStat.put("printing_press",0);
m_TechStat.put("gunpowder",0);
m_TechStat.put("navigation",0);
m_TechStat.put("architecture",0);
m_TechStat.put("economics",0);
m_TechStat.put("metallurgy",0);
m_TechStat.put("chemistry",0);
m_TechStat.put("archaeology",0);
m_TechStat.put("scientific_theory",0);
m_TechStat.put("industrialization",0);
m_TechStat.put("rifling",0);
m_TechStat.put("military_science",0);
m_TechStat.put("fertilizer",0);
m_TechStat.put("biology",0);
m_TechStat.put("electricity",0);
m_TechStat.put("steam_power",0);
m_TechStat.put("dynamite",0);
m_TechStat.put("refrigeration",0);
m_TechStat.put("radio",0);
m_TechStat.put("flight",0);
m_TechStat.put("railroad",0);
m_TechStat.put("plastics",0);
m_TechStat.put("electronics",0);
m_TechStat.put("ballistics",0);
m_TechStat.put("combustion",0);
m_TechStat.put("penicillin",0);
m_TechStat.put("atomic_theory",0);
m_TechStat.put("radar",0);
m_TechStat.put("combined_arms",0);
m_TechStat.put("ecology",0);
m_TechStat.put("nuclear_fission",0);
m_TechStat.put("rocketry",0);
m_TechStat.put("computers",0);
m_TechStat.put("telecommunications",0);
m_TechStat.put("mobile_tactics",0);
m_TechStat.put("advanced_ballistics",0);
m_TechStat.put("satellites",0);
m_TechStat.put("robotics",0);
m_TechStat.put("lasers",0);
m_TechStat.put("the_internet",0);
m_TechStat.put("globalization",0);
m_TechStat.put("particle_physics",0);
m_TechStat.put("nuclear_fusion",0);
m_TechStat.put("nanotechnology",0);
m_TechStat.put("stealth",0);
}
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);
}
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 {
@ -49,11 +49,11 @@ public class NationEventHandler implements CommandExecutor {
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]+"국가이 생성되었습니다."+m_NationArray.GetGroupTechTree(tempUUID,"agriculture"));
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);
}
}

@ -1,6 +1,6 @@
package org.poopki.duckdns.user_db.GUI;
package org.poopki.duckdns.user_db.Bank;
import dev.lone.itemsadder.api.CustomStack;
import dev.lone.itemsadder.api.CustomStack;;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -11,6 +11,7 @@ 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;
@ -80,16 +81,16 @@ public class AccountGUI implements Listener{
Inventory m_inv = e.getClickedInventory();
if (e.getInventory() != m_inv) return;
/*
switch(e.getCurrentItem().getType()){
case CANDLE:
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 BEEF:
case TORCH:
e.setCancelled(true);
p.sendMessage("10000원 감소");
m_AA.setAccountInfo(p.getUniqueId(), (long)m_AA.getAccountInfo(p.getUniqueId())-10000);
@ -125,5 +126,7 @@ public class AccountGUI implements Listener{
p.openInventory(inv);
break;
}
*/
}
}

@ -1,4 +1,4 @@
package org.poopki.duckdns.user_db.GUI;
package org.poopki.duckdns.user_db.Bank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -37,12 +37,19 @@ public class AccountGUIEvent implements Listener,CommandExecutor {
return false;
}
@EventHandler
public void inven2(InventoryClickEvent e){
public boolean inven_Bank(InventoryClickEvent e){
Player player = (Player) e.getWhoClicked();;
player.sendMessage("이벤트 발생");
AccountGUI inv = new AccountGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.inven(e);
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 {
}

@ -154,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)));
}
@ -183,7 +184,7 @@ public class DBUpdate {
while(rs.next()){
Integer index=2;
if(rs.getString(index) != null){
for(String TechName: m_NationArray.m_GroupArray.get(UUID.fromString(rs.getString(1))).TechList){
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++;
}
@ -203,6 +204,8 @@ public class DBUpdate {
}
}
//
try {
Class.forName("org.mariadb.jdbc.Driver");
@ -262,10 +265,10 @@ public class DBUpdate {
pstmt.setString(6, String.valueOf(m_AccountArray.getAccountInfo(key)));
int cnt = pstmt.executeUpdate();
if( cnt == 0 ){
System.out.println("데이터 입력 실패");
System.out.println("[DB] 유저 데이터 입력 실패");
}
else{
System.out.println("데이터 입력 성공");
System.out.println("[DB] 유저 데이터 입력 성공");
}
}
@ -282,60 +285,20 @@ 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_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=?";
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_FarmArray.m_DeleteQueue.remove(key);
m_NationArray.m_DeleteQueue.remove(key);
}
}
catch(ClassNotFoundException e){
@ -350,40 +313,28 @@ public class DBUpdate {
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 (?,?,?,?,?,?,?,?,?,?,?,?,?)";
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_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 (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("데이터 입력 실패");
System.out.println("[DB] 국가 데이터 입력 실패");
}
else{
System.out.println("데이터 입력 성공");
System.out.println("[DB] 국가 데이터 입력 성공");
}
}
@ -400,15 +351,22 @@ public class DBUpdate {
conn.close();
}
}
}
public void UpdateFarmInfo(){
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);
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=?";
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){
@ -418,40 +376,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);
Connection 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()));
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<=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){
@ -461,21 +412,20 @@ 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);
for (UUID key: m_SquadArray.m_DeleteQueue){
String sql = "DELETE FROM Squad WHERE Squad_UUID=?";
pstmt = conn.prepareStatement(sql);
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=?";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, String.valueOf(key.toString()));
int cnt = pstmt.executeUpdate();
m_SquadArray.m_DeleteQueue.remove(key);
m_NationArray.m_DeleteQueue.remove(key);
}
if( conn != null && !conn.isClosed()){
conn.close();
}
}
catch(ClassNotFoundException e){
@ -485,40 +435,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){
@ -528,22 +471,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 Squad_UUID=?";
pstmt = conn.prepareStatement(sql);
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();
@ -552,64 +494,35 @@ public class DBUpdate {
System.err.println("에러 내용 :" + e.getMessage());
System.out.println("DB Connection fail");
}
finally {
if( conn != null && !conn.isClosed()){
conn.close();
}
}
//Update Tech
try{
Class.forName("org.mariadb.jdbc.Driver");
conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
for (UUID key : m_NationArray.getKeySet()) {
String sql = "REPLACE INTO TechTree VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement(sql);
int index = 2;
Connection conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD);
pstmt.setString(1, String.valueOf(key.toString()));
for (String Name : m_NationArray.m_GroupArray.get(key).TechList){
System.out.println(Name+String.valueOf(m_NationArray.m_GroupArray.get(key).GetTechTree(Name)));
pstmt.setString(index, String.valueOf(m_NationArray.m_GroupArray.get(key).GetTechTree(Name)));
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("데이터 입력 실패");
System.out.println("[DB] 분대 데이터 입력 실패");
}
else{
System.out.println("데이터 입력 성공");
System.out.println("[DB] 분대 데이터 입력 성공");
}
}
}
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 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();
}
@ -617,10 +530,5 @@ public class DBUpdate {
System.err.println("에러 내용 :" + e.getMessage());
System.out.println("DB Connection fail");
}
finally {
if( conn != null && !conn.isClosed()){
conn.close();
}
}
}
}

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

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

@ -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,13 +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;
}
}

@ -1,64 +0,0 @@
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;
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);
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;
player.sendMessage("TECH: "+player.getUniqueId());
player.sendMessage("TECH: "+m_UserInfoArray.getUserGroupUUID(player.getUniqueId(),"Nation"));
player.sendMessage("TECH: "+m_NationArray.GetGroupTechTree(m_UserInfoArray.getUserGroupUUID(player.getUniqueId(),"Nation"),"agriculture"));
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray,player.getUniqueId(), null);
inv.open(player);
}
}
return false;
}
@EventHandler
public void inven2(InventoryClickEvent e){
Player player = (Player) e.getWhoClicked();;
player.sendMessage("이벤트 발생");
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e);
inv.inven(e);
}
}

@ -1,101 +0,0 @@
package org.poopki.duckdns.user_db.GUI;
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(){
m_TechStat.put("agriculture",0);
m_TechStat.put("pottery",0);
m_TechStat.put("animal_husbandry",0);
m_TechStat.put("archery",0);
m_TechStat.put("mining",0);
m_TechStat.put("sailing",0);
m_TechStat.put("calendar",0);
m_TechStat.put("writing",0);
m_TechStat.put("trapping",0);
m_TechStat.put("wheel",0);
m_TechStat.put("masonry",0);
m_TechStat.put("bronze",0);
m_TechStat.put("optics",0);
m_TechStat.put("horseback",0);
m_TechStat.put("mathematics",0);
m_TechStat.put("construction",0);
m_TechStat.put("philosophy",0);
m_TechStat.put("drama",0);
m_TechStat.put("currency",0);
m_TechStat.put("engineering",0);
m_TechStat.put("iron_working",0);
m_TechStat.put("theology",0);
m_TechStat.put("civil_service",0);
m_TechStat.put("guilds",0);
m_TechStat.put("metal_casting",0);
m_TechStat.put("compass",0);
m_TechStat.put("education",0);
m_TechStat.put("chivalry",0);
m_TechStat.put("machinery",0);
m_TechStat.put("physics",0);
m_TechStat.put("steel",0);
m_TechStat.put("astronomy",0);
m_TechStat.put("acoustics",0);
m_TechStat.put("banking",0);
m_TechStat.put("printing_press",0);
m_TechStat.put("gunpowder",0);
m_TechStat.put("navigation",0);
m_TechStat.put("architecture",0);
m_TechStat.put("economics",0);
m_TechStat.put("metallurgy",0);
m_TechStat.put("chemistry",0);
m_TechStat.put("archaeology",0);
m_TechStat.put("scientific_theory",0);
m_TechStat.put("industrialization",0);
m_TechStat.put("rifling",0);
m_TechStat.put("military_science",0);
m_TechStat.put("fertilizer",0);
m_TechStat.put("biology",0);
m_TechStat.put("electricity",0);
m_TechStat.put("steam_power",0);
m_TechStat.put("dynamite",0);
m_TechStat.put("refrigeration",0);
m_TechStat.put("radio",0);
m_TechStat.put("flight",0);
m_TechStat.put("railroad",0);
m_TechStat.put("plastics",0);
m_TechStat.put("electronics",0);
m_TechStat.put("ballistics",0);
m_TechStat.put("combustion",0);
m_TechStat.put("penicillin",0);
m_TechStat.put("atomic_theory",0);
m_TechStat.put("radar",0);
m_TechStat.put("combined_arms",0);
m_TechStat.put("ecology",0);
m_TechStat.put("nuclear_fission",0);
m_TechStat.put("rocketry",0);
m_TechStat.put("computers",0);
m_TechStat.put("telecommunications",0);
m_TechStat.put("mobile_tactics",0);
m_TechStat.put("advanced_ballistics",0);
m_TechStat.put("satellites",0);
m_TechStat.put("robotics",0);
m_TechStat.put("lasers",0);
m_TechStat.put("the_internet",0);
m_TechStat.put("globalization",0);
m_TechStat.put("particle_physics",0);
m_TechStat.put("nuclear_fusion",0);
m_TechStat.put("nanotechnology",0);
m_TechStat.put("stealth",0);
}
public void EnableTechTree(String TechName){
m_TechStat.replace(TechName,1);
}
public int GetTachTree(String TechName){
return m_TechStat.get(TechName);
}
}

@ -1,4 +1,4 @@
package org.poopki.duckdns.user_db.GUI;
package org.poopki.duckdns.user_db.InfoGUI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -33,7 +33,7 @@ public class ScoreboardEvent {
manager = Bukkit.getScoreboardManager();
scoreboard = manager.getNewScoreboard();
Objective score_obj = scoreboard.registerNewObjective("Scoreboard","dummy","계좌");
Objective score_obj = scoreboard.registerNewObjective("Scoreboard","dummy");
score_obj.setDisplaySlot(DisplaySlot.SIDEBAR);
Score score = score_obj.getScore(ChatColor.BLUE + "==-=-=-=-=-=-==");

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

@ -1,4 +1,4 @@
package org.poopki.duckdns.user_db.GUI;
package org.poopki.duckdns.user_db.TechTree;
import dev.lone.itemsadder.api.CustomStack;
import org.bukkit.Bukkit;
@ -10,6 +10,7 @@ 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;
@ -88,51 +89,5 @@ public class TechGUI implements Listener{
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,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);
}
}

@ -1,13 +1,11 @@
package org.poopki.duckdns.user_db;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.scoreboard.*;
import org.poopki.duckdns.user_db.Array.*;
import org.poopki.duckdns.user_db.GUI.ScoreboardEvent;
import org.poopki.duckdns.user_db.InfoGUI.ScoreboardEvent;
import java.util.UUID;
@ -17,7 +15,7 @@ public class UserJoin implements Listener {
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;
@ -35,6 +33,11 @@ public class UserJoin implements Listener {
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,29 +1,37 @@
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.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.*;
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;
import java.util.UUID;
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
@ -41,10 +49,18 @@ public final class User_DB extends JavaPlugin implements Listener {
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));
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
@ -52,8 +68,14 @@ public final class User_DB extends JavaPlugin implements Listener {
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() {

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