parent
2217f435c2
commit
36b0fec006
30 changed files with 1386 additions and 672 deletions
@ -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,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); |
||||
} |
||||
|
||||
} |
||||
|
@ -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,4 @@ |
||||
package org.poopki.duckdns.user_db.Bank; |
||||
|
||||
public class Digit { |
||||
} |
@ -1,4 +0,0 @@ |
||||
package org.poopki.duckdns.user_db.GUI; |
||||
|
||||
public class Digit { |
||||
} |
@ -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); |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
@ -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…
Reference in new issue