Compare commits
17 Commits
Group_Syst
...
GUI
Author | SHA1 | Date |
---|---|---|
poopki | 6dceb6aebb | 10 months ago |
poopki | b91f592dc1 | 10 months ago |
poopki | 343829f9d0 | 10 months ago |
poopki | 36b0fec006 | 1 year ago |
poopki | 2217f435c2 | 2 years ago |
poopki | e495926665 | 2 years ago |
poopki | ed6a80ef56 | 2 years ago |
poopki | 8591169fc2 | 2 years ago |
poopki | 38423f8df2 | 3 years ago |
poopki | bcd543c979 | 3 years ago |
poopki | 84dbe56db4 | 3 years ago |
poopki | 174ed17fb7 | 3 years ago |
poopki | ccae645f93 | 3 years ago |
poopki | 7864c65aee | 3 years ago |
poopki | 7ae8860680 | 3 years ago |
poopki | 339bf481b3 | 3 years ago |
poopki | 55027d831a | 3 years ago |
29 changed files with 1854 additions and 206 deletions
@ -1,12 +1,183 @@ |
|||||||
package org.poopki.duckdns.user_db.Array; |
package org.poopki.duckdns.user_db.Array; |
||||||
|
|
||||||
import org.bukkit.Bukkit; |
import org.bukkit.Bukkit; |
||||||
|
import org.bukkit.entity.Player; |
||||||
|
import org.bukkit.plugin.Plugin; |
||||||
import org.poopki.duckdns.user_db.UserInfoArray; |
import org.poopki.duckdns.user_db.UserInfoArray; |
||||||
|
|
||||||
import java.util.*; |
import java.util.*; |
||||||
|
|
||||||
public class FarmArray extends GroupArray{ |
public class FarmArray extends GroupArray{ |
||||||
public FarmArray(UserInfoArray m_UIA){ |
|
||||||
super(m_UIA, 10); |
|
||||||
|
public Map<UUID, Farm> m_FarmArray; |
||||||
|
protected Map<String, UUID> m_GroupNameList; |
||||||
|
public List<UUID> m_DeleteQueue = new ArrayList<>(); |
||||||
|
UserInfoArray m_UserInfoArray; |
||||||
|
UUID ZERO_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); |
||||||
|
int MAX_GROUP_NUM = 10; |
||||||
|
Plugin plugin; |
||||||
|
public FarmArray(UserInfoArray m_UIA, int num, Plugin plugin){ |
||||||
|
super(m_UIA,num,plugin); |
||||||
|
m_UserInfoArray = m_UIA; |
||||||
|
m_FarmArray = new HashMap<UUID, Farm>(); |
||||||
|
m_GroupNameList = new HashMap<String, UUID>(); |
||||||
|
MAX_GROUP_NUM = num; |
||||||
|
this.plugin = plugin; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public boolean CreateGroup(UUID GroupUUID, String Name, UUID PlayerUUID){ |
||||||
|
if(m_GroupNameList.containsKey(Name)){ |
||||||
|
return false; // Conflict
|
||||||
|
} else{ |
||||||
|
List<UUID> m_MemberList = new ArrayList<>(); |
||||||
|
m_MemberList.add(PlayerUUID); |
||||||
|
|
||||||
|
m_FarmArray.put(GroupUUID, new Farm(Name, m_MemberList)); |
||||||
|
m_GroupNameList.put(Name, GroupUUID); |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void SetGroupTechTree(UUID GroupUUID, String TechName, Integer set){ |
||||||
|
m_FarmArray.get(GroupUUID).SetTechTree(TechName,set); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public int GetGroupTechTree(UUID GroupUUID, String TechName){ |
||||||
|
return m_FarmArray.get(GroupUUID).GetTechTree(TechName); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean PutGroup(UUID GroupUUID, String Name,List<UUID> PlayerUUID){ |
||||||
|
List<UUID> m_MemberList = new ArrayList<>(); |
||||||
|
|
||||||
|
Iterator <UUID> it = PlayerUUID.iterator(); |
||||||
|
|
||||||
|
while(it.hasNext()){ |
||||||
|
m_MemberList.add(it.next()); |
||||||
|
} |
||||||
|
|
||||||
|
m_FarmArray.put(GroupUUID, new Farm(Name, m_MemberList)); |
||||||
|
m_GroupNameList.put(Name,GroupUUID); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean CheckGroup(String GroupType, String Name){ |
||||||
|
return m_FarmArray.containsKey(m_GroupNameList.get(Name)); |
||||||
|
} |
||||||
|
public static <K, V> K getKey(Map<K, V> map, V value) { |
||||||
|
|
||||||
|
for (K key : map.keySet()) { |
||||||
|
if (value.equals(map.get(key))) { |
||||||
|
return key; |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public UUID GetUUID(String name){ |
||||||
|
return m_GroupNameList.get(name); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean DeleteGroup(UUID GroupUUID, String GroupType){ |
||||||
|
if(m_FarmArray.containsKey(GroupUUID)){ |
||||||
|
for(UUID key: GetGroupMembersUUID(GroupUUID)){ |
||||||
|
m_UserInfoArray.setUserGroupUUID(GroupType,key,new UUID(0,0)); |
||||||
|
} |
||||||
|
|
||||||
|
m_GroupNameList.remove(GetGroupName(GroupUUID)); |
||||||
|
m_FarmArray.remove(GroupUUID); |
||||||
|
return true; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return false; // Group is not exists.
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public String SignUpGroup(String GroupType, UUID GroupUUID, UUID PlayerUUID){ |
||||||
|
if(m_FarmArray.containsKey(GroupUUID) && m_UserInfoArray.getUserGroupUUID(PlayerUUID, GroupType).equals(ZERO_UUID)){ |
||||||
|
Group m_Group = m_FarmArray.get(GroupUUID); |
||||||
|
m_Group.SignUp(PlayerUUID); |
||||||
|
m_UserInfoArray.setUserGroupUUID(GroupType,PlayerUUID,GroupUUID); |
||||||
|
return ""; |
||||||
|
} else{ |
||||||
|
return "다른 그룹에 가입되어있습니다."; // Wrong Group
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public boolean ExpulsionGroupPlayer(String GroupType, UUID GroupUUID, UUID PlayerUUID){ |
||||||
|
if(m_FarmArray.get(GroupUUID).isMember(PlayerUUID)) { |
||||||
|
Group m_Group = m_FarmArray.get(GroupUUID); |
||||||
|
m_Group.Expulsion(PlayerUUID); |
||||||
|
m_UserInfoArray.setUserGroupUUID(GroupType,PlayerUUID,ZERO_UUID); |
||||||
|
int temp = m_FarmArray.get(GroupUUID).getMemNUM(); |
||||||
|
|
||||||
|
if(temp==0){ |
||||||
|
m_GroupNameList.remove(m_Group.getGroupName()); |
||||||
|
m_FarmArray.remove(GroupUUID); |
||||||
|
m_DeleteQueue.add(GroupUUID); |
||||||
|
Bukkit.getPlayer(PlayerUUID).sendMessage(""+temp+" "+m_DeleteQueue); |
||||||
|
} |
||||||
|
return true; |
||||||
|
} else{ |
||||||
|
return false; // Wrong Player Name. FIXME{Need Checking function for a validate user name's }
|
||||||
|
/* Player op = Bukkit.getPlayer(args[1]); |
||||||
|
if (op != null) { |
||||||
|
*/ |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public List<String> GetGroupMembersName(UUID GroupUUID){ |
||||||
|
List<String> MembersName = new ArrayList<>(); |
||||||
|
for (UUID key : m_FarmArray.get(GroupUUID).getGroupMembers()){ |
||||||
|
try { |
||||||
|
MembersName.add(Bukkit.getPlayer(key).getDisplayName()); |
||||||
|
} |
||||||
|
catch(NullPointerException e){ |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
return MembersName; |
||||||
|
} |
||||||
|
public List<UUID> GetGroupMembersUUID(UUID GroupUUID){ |
||||||
|
return m_FarmArray.get(GroupUUID).getGroupMembers(); |
||||||
|
} |
||||||
|
public boolean isGroupMember(UUID GroupUUID, UUID PlayerUUID){ |
||||||
|
Group m_Group = m_FarmArray.get(GroupUUID); |
||||||
|
return m_Group.isMember(PlayerUUID); |
||||||
} |
} |
||||||
|
public int GetGroupMemNUM(UUID GroupUUID){ |
||||||
|
Group m_Group = m_FarmArray.get(GroupUUID); |
||||||
|
return m_Group.getMemNUM(); |
||||||
|
} |
||||||
|
public Set<String> GetGroupNameList(){ |
||||||
|
return m_GroupNameList.keySet(); |
||||||
|
} |
||||||
|
|
||||||
|
public Set<UUID> getKeySet(){ // 유저 목록 return
|
||||||
|
return m_FarmArray.keySet(); |
||||||
|
} |
||||||
|
|
||||||
|
public Set<String> getNameSet() { return m_GroupNameList.keySet(); } |
||||||
|
public String GetGroupName(UUID GroupUUID){ |
||||||
|
Group m_Group = m_FarmArray.get(GroupUUID); |
||||||
|
return m_Group.getGroupName(); |
||||||
|
} |
||||||
|
public int GetGroupMemMaxNum(UUID GroupUUID){ |
||||||
|
Group m_Group = m_FarmArray.get(GroupUUID); |
||||||
|
return m_Group.getMemMaxNUM(); |
||||||
|
} |
||||||
|
public boolean isOffline(UUID uuid){ |
||||||
|
return Bukkit.getPlayer(uuid).equals(null) && !Bukkit.getOfflinePlayer(uuid).equals(null); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isOwner(UUID GroupUUID, UUID PlayerUUID){ |
||||||
|
return m_FarmArray.get(GroupUUID).isOwner(PlayerUUID); |
||||||
|
} |
||||||
|
private boolean isAvaliableGroup(UUID GroupUUID){ |
||||||
|
return m_FarmArray.containsKey(GroupUUID); |
||||||
|
} |
||||||
|
|
||||||
} |
} |
||||||
|
@ -1,11 +1,59 @@ |
|||||||
package org.poopki.duckdns.user_db.Array; |
package org.poopki.duckdns.user_db.Array; |
||||||
|
|
||||||
import java.util.ArrayList; |
import dev.lone.itemsadder.api.CustomStack; |
||||||
import java.util.List; |
import org.bukkit.Bukkit; |
||||||
import java.util.UUID; |
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 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); |
super(Name, uuid_list); |
||||||
|
for(int i = 0; i<3; i++){ |
||||||
|
m_ResearchArray.add(new Research("연구 테스트",plugin, m_MemberList)); |
||||||
|
//연구 프로그레스바 등록
|
||||||
|
} |
||||||
|
//Init 테크트리
|
||||||
|
for(String Key: techtree){ |
||||||
|
InitTechTree(Key,0); |
||||||
|
} |
||||||
|
|
||||||
|
new BukkitRunnable(){ |
||||||
|
@Override |
||||||
|
public void run(){ |
||||||
|
for(Research key:m_ResearchArray){ |
||||||
|
for(UUID uuid: Nation.super.getGroupMembers()){ |
||||||
|
if(Bukkit.getPlayer(uuid)!=null){ |
||||||
|
key.tech1_progressbar.addPlayer(Bukkit.getPlayer(uuid)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}.runTaskTimer(plugin,0,20); |
||||||
|
//InitResearchItem();
|
||||||
|
} |
||||||
|
|
||||||
|
public void InitResearchItem(){ |
||||||
|
//System.out.println(CustomStack.getInstance("research:materials-book").getDisplayName());
|
||||||
|
ArrayList <ItemStack> InitStack = new ArrayList<ItemStack>(); |
||||||
|
InitStack.add(CustomStack.getInstance("research:materials-book").getItemStack()); |
||||||
|
InitStack.add(CustomStack.getInstance("research:materials-crystal").getItemStack()); |
||||||
|
InitStack.add(CustomStack.getInstance("research:materials-god_pot").getItemStack()); |
||||||
|
m_ResearchArray.get(0).SetMaterials(InitStack); // 0-> 고대 연구 아이템 설정
|
||||||
|
} |
||||||
|
public void AddShowResearchProgressBar(Integer index, Player player){ |
||||||
|
m_ResearchArray.get(index).tech1_progressbar.addPlayer(player); |
||||||
|
} |
||||||
|
|
||||||
|
public void ShowResearchProgressBar(Integer index, boolean toggle){ |
||||||
|
m_ResearchArray.get(index).tech1_progressbar.setVisible(toggle); |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,9 +1,190 @@ |
|||||||
package org.poopki.duckdns.user_db.Array; |
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; |
import org.poopki.duckdns.user_db.UserInfoArray; |
||||||
|
|
||||||
public class NationArray extends GroupArray{ |
import java.util.*; |
||||||
public NationArray(UserInfoArray m_UIA){ |
|
||||||
super(m_UIA, 50); |
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; |
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 org.poopki.duckdns.user_db.UserInfoArray; |
||||||
|
|
||||||
public class SquadArray extends GroupArray{ |
import java.util.*; |
||||||
public SquadArray(UserInfoArray m_UIA){ |
|
||||||
super(m_UIA, 8); |
public class SquadArray { |
||||||
|
|
||||||
|
|
||||||
|
public Map<UUID, Squad> m_SquadArray; |
||||||
|
protected Map<String, UUID> m_GroupNameList; |
||||||
|
public List<UUID> m_DeleteQueue = new ArrayList<>(); |
||||||
|
UserInfoArray m_UserInfoArray; |
||||||
|
UUID ZERO_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); |
||||||
|
int MAX_GROUP_NUM = 10; |
||||||
|
Plugin plugin; |
||||||
|
public SquadArray(UserInfoArray m_UIA, int num, Plugin plugin){ |
||||||
|
m_UserInfoArray = m_UIA; |
||||||
|
m_SquadArray = new HashMap<UUID, Squad>(); |
||||||
|
m_GroupNameList = new HashMap<String, UUID>(); |
||||||
|
MAX_GROUP_NUM = num; |
||||||
|
this.plugin = plugin; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean CreateGroup(UUID GroupUUID, String Name, UUID PlayerUUID){ |
||||||
|
if(m_GroupNameList.containsKey(Name)){ |
||||||
|
return false; // Conflict
|
||||||
|
} else{ |
||||||
|
List<UUID> m_MemberList = new ArrayList<>(); |
||||||
|
m_MemberList.add(PlayerUUID); |
||||||
|
|
||||||
|
m_SquadArray.put(GroupUUID, new Squad(Name, m_MemberList)); |
||||||
|
m_GroupNameList.put(Name, GroupUUID); |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void SetGroupTechTree(UUID GroupUUID, String TechName, Integer set){ |
||||||
|
m_SquadArray.get(GroupUUID).SetTechTree(TechName,set); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public int GetGroupTechTree(UUID GroupUUID, String TechName){ |
||||||
|
return m_SquadArray.get(GroupUUID).GetTechTree(TechName); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean PutGroup(UUID GroupUUID, String Name,List<UUID> PlayerUUID){ |
||||||
|
List<UUID> m_MemberList = new ArrayList<>(); |
||||||
|
|
||||||
|
Iterator <UUID> it = PlayerUUID.iterator(); |
||||||
|
|
||||||
|
while(it.hasNext()){ |
||||||
|
m_MemberList.add(it.next()); |
||||||
|
} |
||||||
|
|
||||||
|
m_SquadArray.put(GroupUUID, new Squad(Name, m_MemberList)); |
||||||
|
m_GroupNameList.put(Name,GroupUUID); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean CheckGroup(String GroupType, String Name){ |
||||||
|
return m_SquadArray.containsKey(m_GroupNameList.get(Name)); |
||||||
|
} |
||||||
|
public static <K, V> K getKey(Map<K, V> map, V value) { |
||||||
|
|
||||||
|
for (K key : map.keySet()) { |
||||||
|
if (value.equals(map.get(key))) { |
||||||
|
return key; |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public UUID GetUUID(String name){ |
||||||
|
return m_GroupNameList.get(name); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean DeleteGroup(UUID GroupUUID, String GroupType){ |
||||||
|
if(m_SquadArray.containsKey(GroupUUID)){ |
||||||
|
for(UUID key: GetGroupMembersUUID(GroupUUID)){ |
||||||
|
m_UserInfoArray.setUserGroupUUID(GroupType,key,new UUID(0,0)); |
||||||
|
} |
||||||
|
|
||||||
|
m_GroupNameList.remove(GetGroupName(GroupUUID)); |
||||||
|
m_SquadArray.remove(GroupUUID); |
||||||
|
return true; |
||||||
|
} |
||||||
|
else{ |
||||||
|
return false; // Group is not exists.
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public String SignUpGroup(String GroupType, UUID GroupUUID, UUID PlayerUUID){ |
||||||
|
if(m_SquadArray.containsKey(GroupUUID) && m_UserInfoArray.getUserGroupUUID(PlayerUUID, GroupType).equals(ZERO_UUID)){ |
||||||
|
Group m_Group = m_SquadArray.get(GroupUUID); |
||||||
|
m_Group.SignUp(PlayerUUID); |
||||||
|
m_UserInfoArray.setUserGroupUUID(GroupType,PlayerUUID,GroupUUID); |
||||||
|
return ""; |
||||||
|
} else{ |
||||||
|
return "다른 그룹에 가입되어있습니다."; // Wrong Group
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public boolean ExpulsionGroupPlayer(String GroupType, UUID GroupUUID, UUID PlayerUUID){ |
||||||
|
if(m_SquadArray.get(GroupUUID).isMember(PlayerUUID)) { |
||||||
|
Group m_Group = m_SquadArray.get(GroupUUID); |
||||||
|
m_Group.Expulsion(PlayerUUID); |
||||||
|
m_UserInfoArray.setUserGroupUUID(GroupType,PlayerUUID,ZERO_UUID); |
||||||
|
int temp = m_SquadArray.get(GroupUUID).getMemNUM(); |
||||||
|
|
||||||
|
if(temp==0){ |
||||||
|
m_GroupNameList.remove(m_Group.getGroupName()); |
||||||
|
m_SquadArray.remove(GroupUUID); |
||||||
|
m_DeleteQueue.add(GroupUUID); |
||||||
|
Bukkit.getPlayer(PlayerUUID).sendMessage(""+temp+" "+m_DeleteQueue); |
||||||
|
} |
||||||
|
return true; |
||||||
|
} else{ |
||||||
|
return false; // Wrong Player Name. FIXME{Need Checking function for a validate user name's }
|
||||||
|
/* Player op = Bukkit.getPlayer(args[1]); |
||||||
|
if (op != null) { |
||||||
|
*/ |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public List<String> GetGroupMembersName(UUID GroupUUID){ |
||||||
|
List<String> MembersName = new ArrayList<>(); |
||||||
|
for (UUID key : m_SquadArray.get(GroupUUID).getGroupMembers()){ |
||||||
|
try { |
||||||
|
MembersName.add(Bukkit.getPlayer(key).getDisplayName()); |
||||||
|
} |
||||||
|
catch(NullPointerException e){ |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
return MembersName; |
||||||
|
} |
||||||
|
public List<UUID> GetGroupMembersUUID(UUID GroupUUID){ |
||||||
|
return m_SquadArray.get(GroupUUID).getGroupMembers(); |
||||||
|
} |
||||||
|
public boolean isGroupMember(UUID GroupUUID, UUID PlayerUUID){ |
||||||
|
Group m_Group = m_SquadArray.get(GroupUUID); |
||||||
|
return m_Group.isMember(PlayerUUID); |
||||||
} |
} |
||||||
|
public int GetGroupMemNUM(UUID GroupUUID){ |
||||||
|
Group m_Group = m_SquadArray.get(GroupUUID); |
||||||
|
return m_Group.getMemNUM(); |
||||||
|
} |
||||||
|
public Set<String> GetGroupNameList(){ |
||||||
|
return m_GroupNameList.keySet(); |
||||||
|
} |
||||||
|
|
||||||
|
public Set<UUID> getKeySet(){ // 유저 목록 return
|
||||||
|
return m_SquadArray.keySet(); |
||||||
|
} |
||||||
|
|
||||||
|
public Set<String> getNameSet() { return m_GroupNameList.keySet(); } |
||||||
|
public String GetGroupName(UUID GroupUUID){ |
||||||
|
Group m_Group = m_SquadArray.get(GroupUUID); |
||||||
|
return m_Group.getGroupName(); |
||||||
|
} |
||||||
|
public int GetGroupMemMaxNum(UUID GroupUUID){ |
||||||
|
Group m_Group = m_SquadArray.get(GroupUUID); |
||||||
|
return m_Group.getMemMaxNUM(); |
||||||
|
} |
||||||
|
public boolean isOffline(UUID uuid){ |
||||||
|
return Bukkit.getPlayer(uuid).equals(null) && !Bukkit.getOfflinePlayer(uuid).equals(null); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isOwner(UUID GroupUUID, UUID PlayerUUID){ |
||||||
|
return m_SquadArray.get(GroupUUID).isOwner(PlayerUUID); |
||||||
|
} |
||||||
|
private boolean isAvaliableGroup(UUID GroupUUID){ |
||||||
|
return m_SquadArray.containsKey(GroupUUID); |
||||||
|
} |
||||||
|
|
||||||
} |
} |
||||||
|
@ -0,0 +1,132 @@ |
|||||||
|
package org.poopki.duckdns.user_db.Bank; |
||||||
|
|
||||||
|
import dev.lone.itemsadder.api.CustomStack;; |
||||||
|
import org.bukkit.Bukkit; |
||||||
|
import org.bukkit.ChatColor; |
||||||
|
import org.bukkit.entity.Player; |
||||||
|
import org.bukkit.event.Listener; |
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent; |
||||||
|
import org.bukkit.inventory.Inventory; |
||||||
|
import org.poopki.duckdns.user_db.Array.AccountArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.FarmArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.NationArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.SquadArray; |
||||||
|
import org.poopki.duckdns.user_db.GUI.ItemManager; |
||||||
|
import org.poopki.duckdns.user_db.UserInfoArray; |
||||||
|
import org.bukkit.inventory.ItemStack; |
||||||
|
import java.util.UUID; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.List; |
||||||
|
import org.apache.commons.lang.StringEscapeUtils; |
||||||
|
import java.util.stream.Stream; |
||||||
|
public class AccountGUI implements Listener{ |
||||||
|
private final Inventory inv; |
||||||
|
UUID m_uuid; |
||||||
|
ItemManager m_ItemManager = new ItemManager(); |
||||||
|
AccountArray m_AA; |
||||||
|
UserInfoArray m_UIA; |
||||||
|
FarmArray m_FA; |
||||||
|
NationArray m_NA; |
||||||
|
SquadArray m_SA; |
||||||
|
public AccountGUI(AccountArray AA, UserInfoArray UIA, FarmArray FA, NationArray NA, SquadArray SA, UUID uuid, InventoryClickEvent e) { |
||||||
|
m_uuid=uuid; |
||||||
|
this.inv = Bukkit.createInventory(null,54,":offset_-8::bank_main:"); |
||||||
|
m_AA = AA; |
||||||
|
m_UIA = UIA; |
||||||
|
m_FA = FA; |
||||||
|
m_NA = NA; |
||||||
|
m_SA = SA; |
||||||
|
initItemSetting(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initItemSetting() { |
||||||
|
/* |
||||||
|
inv.setItem(0,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_SA,m_uuid, "User")); |
||||||
|
inv.setItem(1,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_SA,m_uuid, "Nation")); |
||||||
|
inv.setItem(2,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_SA,m_uuid, "Farm")); |
||||||
|
|
||||||
|
inv.setItem(9, m_ItemManager.btn1); |
||||||
|
inv.setItem(18, m_ItemManager.btn2); |
||||||
|
inv.setItem(10, m_ItemManager.btn3); |
||||||
|
inv.setItem(19, m_ItemManager.btn4); |
||||||
|
inv.setItem(11, m_ItemManager.btn5); |
||||||
|
inv.setItem(20, m_ItemManager.btn6); |
||||||
|
|
||||||
|
CustomStack stack = CustomStack.getInstance("digits:digit-zero"); |
||||||
|
ItemStack itemStack = stack.getItemStack(); |
||||||
|
*/ |
||||||
|
List<String> strList = new ArrayList<String>(); |
||||||
|
|
||||||
|
String before = String.valueOf(m_AA.getAccountInfo(m_uuid)); |
||||||
|
strList.addAll(Arrays.asList(before.split(""))); |
||||||
|
|
||||||
|
int tmp = strList.size(); |
||||||
|
for(int i=0; i<8-tmp; i++) { |
||||||
|
strList.add(0, "0"); |
||||||
|
} |
||||||
|
|
||||||
|
for(int i = 0; i<strList.size(); i++){ |
||||||
|
inv.setItem(10+i, CustomStack.getInstance("digits:digit-"+strList.get(i)).getItemStack()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public void open(Player player){ |
||||||
|
player.openInventory(inv); |
||||||
|
} |
||||||
|
|
||||||
|
public void inven(InventoryClickEvent e){ |
||||||
|
Player p = (Player) e.getWhoClicked(); |
||||||
|
Inventory m_inv = e.getClickedInventory(); |
||||||
|
|
||||||
|
if (e.getInventory() != m_inv) return; |
||||||
|
/* |
||||||
|
switch(e.getCurrentItem().getType()){ |
||||||
|
case TORCH: |
||||||
|
e.setCancelled(true); |
||||||
|
p.sendMessage("10000원 증가"); |
||||||
|
m_AA.setAccountInfo(p.getUniqueId(), (long)m_AA.getAccountInfo(p.getUniqueId())+10000); |
||||||
|
initItemSetting(); |
||||||
|
p.openInventory(inv); |
||||||
|
break; |
||||||
|
case TORCH: |
||||||
|
e.setCancelled(true); |
||||||
|
p.sendMessage("10000원 감소"); |
||||||
|
m_AA.setAccountInfo(p.getUniqueId(), (long)m_AA.getAccountInfo(p.getUniqueId())-10000); |
||||||
|
initItemSetting(); |
||||||
|
p.openInventory(inv); |
||||||
|
break; |
||||||
|
case TORCH: |
||||||
|
e.setCancelled(true); |
||||||
|
p.sendMessage("국가 10000원 증가"+ m_AA.getAccountInfo(m_UIA.getUserGroupUUID(m_uuid, "Nation"))); |
||||||
|
m_AA.setAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Nation"), (long)m_AA.getAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Nation"))+10000); |
||||||
|
initItemSetting(); |
||||||
|
p.openInventory(inv); |
||||||
|
break; |
||||||
|
case GRASS: |
||||||
|
e.setCancelled(true); |
||||||
|
p.sendMessage("국가 10000원 감소"+ m_AA.getAccountInfo(m_UIA.getUserGroupUUID(m_uuid, "Nation"))); |
||||||
|
m_AA.setAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Nation"), (long)m_AA.getAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Nation"))-10000); |
||||||
|
initItemSetting(); |
||||||
|
p.openInventory(inv); |
||||||
|
break; |
||||||
|
case DIAMOND: |
||||||
|
e.setCancelled(true); |
||||||
|
p.sendMessage("농장 10000원 증가"+ m_AA.getAccountInfo(m_UIA.getUserGroupUUID(m_uuid, "Farm"))); |
||||||
|
m_AA.setAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Farm"), (long)m_AA.getAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Farm"))+10000); |
||||||
|
initItemSetting(); |
||||||
|
p.openInventory(inv); |
||||||
|
break; |
||||||
|
case IRON_INGOT: |
||||||
|
e.setCancelled(true); |
||||||
|
p.sendMessage("농장 10000원 감소"+ m_AA.getAccountInfo(m_UIA.getUserGroupUUID(m_uuid, "Farm"))); |
||||||
|
m_AA.setAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Farm"), (long)m_AA.getAccountInfo(m_UIA.getUserGroupUUID(p.getUniqueId(),"Farm"))-10000); |
||||||
|
initItemSetting(); |
||||||
|
p.openInventory(inv); |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
*/ |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
package org.poopki.duckdns.user_db.Bank; |
||||||
|
|
||||||
|
import org.bukkit.command.Command; |
||||||
|
import org.bukkit.command.CommandExecutor; |
||||||
|
import org.bukkit.command.CommandSender; |
||||||
|
import org.bukkit.entity.Player; |
||||||
|
import org.bukkit.event.EventHandler; |
||||||
|
import org.bukkit.event.Listener; |
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent; |
||||||
|
import org.poopki.duckdns.user_db.Array.AccountArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.FarmArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.NationArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.SquadArray; |
||||||
|
import org.poopki.duckdns.user_db.UserInfoArray; |
||||||
|
|
||||||
|
public class AccountGUIEvent implements Listener,CommandExecutor { |
||||||
|
AccountArray m_AccountArray; |
||||||
|
UserInfoArray m_UserInfoArray; |
||||||
|
FarmArray m_FarmArray; |
||||||
|
NationArray m_NationArray; |
||||||
|
SquadArray m_SquadArray; |
||||||
|
public AccountGUIEvent(UserInfoArray m_UIA, FarmArray FA, NationArray NA, SquadArray SA, AccountArray AA){ |
||||||
|
m_UserInfoArray = m_UIA; |
||||||
|
m_AccountArray = AA; |
||||||
|
m_FarmArray = FA; |
||||||
|
m_NationArray = NA; |
||||||
|
m_SquadArray = SA; |
||||||
|
} |
||||||
|
@Override |
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { |
||||||
|
if(sender instanceof Player){ |
||||||
|
Player player = (Player) sender; |
||||||
|
player.sendMessage("이벤트 발생"); |
||||||
|
AccountGUI inv = new AccountGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray,((Player) sender).getUniqueId(), null); |
||||||
|
inv.open(player); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
@EventHandler |
||||||
|
public boolean inven_Bank(InventoryClickEvent e){ |
||||||
|
Player player = (Player) e.getWhoClicked();; |
||||||
|
String name = e.getView().getTitle(); |
||||||
|
player.sendMessage("이벤트 발생B"); |
||||||
|
if(name.equals(":offset_-8::bank_main:")){ |
||||||
|
if(e.getCurrentItem()!=null){ |
||||||
|
e.setCancelled(true); |
||||||
|
AccountGUI inv = new AccountGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e); |
||||||
|
inv.inven(e); |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,4 @@ |
|||||||
|
package org.poopki.duckdns.user_db.Bank; |
||||||
|
|
||||||
|
public class Digit { |
||||||
|
} |
@ -0,0 +1,77 @@ |
|||||||
|
package org.poopki.duckdns.user_db.InfoGUI; |
||||||
|
|
||||||
|
import org.bukkit.Bukkit; |
||||||
|
import org.bukkit.ChatColor; |
||||||
|
import org.bukkit.entity.Player; |
||||||
|
import org.bukkit.scoreboard.*; |
||||||
|
import org.poopki.duckdns.user_db.Array.AccountArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.FarmArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.NationArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.SquadArray; |
||||||
|
import org.poopki.duckdns.user_db.UserInfoArray; |
||||||
|
|
||||||
|
import java.util.UUID; |
||||||
|
|
||||||
|
public class ScoreboardEvent { |
||||||
|
ScoreboardManager manager; |
||||||
|
Scoreboard scoreboard; |
||||||
|
UUID ZERO_UUID = new UUID(0,0); |
||||||
|
private UserInfoArray m_InfoArrayInstance; |
||||||
|
private AccountArray m_AccountArray; |
||||||
|
private FarmArray m_FarmArray; |
||||||
|
private NationArray m_NationArray; |
||||||
|
private SquadArray m_SquadArray; |
||||||
|
public ScoreboardEvent(UserInfoArray m_UIA, FarmArray FA, NationArray NA, SquadArray SA, AccountArray AA){ |
||||||
|
m_InfoArrayInstance = m_UIA; |
||||||
|
m_AccountArray = AA; |
||||||
|
m_FarmArray = FA; |
||||||
|
m_NationArray = NA; |
||||||
|
m_SquadArray = SA; |
||||||
|
} |
||||||
|
public void ScoreboardUpdate(Player player){ |
||||||
|
|
||||||
|
manager = Bukkit.getScoreboardManager(); |
||||||
|
scoreboard = manager.getNewScoreboard(); |
||||||
|
|
||||||
|
Objective score_obj = scoreboard.registerNewObjective("Scoreboard","dummy"); |
||||||
|
score_obj.setDisplaySlot(DisplaySlot.SIDEBAR); |
||||||
|
|
||||||
|
Score score = score_obj.getScore(ChatColor.BLUE + "==-=-=-=-=-=-=="); |
||||||
|
score.setScore(15); |
||||||
|
|
||||||
|
Score score1 = score_obj.getScore("계좌 잔액: "+m_AccountArray.getAccountInfo(player.getUniqueId())+"원"); |
||||||
|
score1.setScore(14); |
||||||
|
|
||||||
|
Score score3 = score_obj.getScore(ChatColor.BLUE + "==-=-=-=-=-=-=="); |
||||||
|
score3.setScore(15); |
||||||
|
|
||||||
|
if(ZERO_UUID.equals(m_InfoArrayInstance.getUserGroupUUID(player.getUniqueId(), "Farm"))) { |
||||||
|
Score score4 = score_obj.getScore("농장 이름: ----"); |
||||||
|
score4.setScore(14); |
||||||
|
} |
||||||
|
else{ |
||||||
|
Score score4 = score_obj.getScore("농장 이름: " + m_FarmArray.GetGroupName(m_InfoArrayInstance.getUserGroupUUID(player.getUniqueId(), "Farm"))); |
||||||
|
score4.setScore(14); |
||||||
|
} |
||||||
|
|
||||||
|
if(ZERO_UUID.equals(m_InfoArrayInstance.getUserGroupUUID(player.getUniqueId(), "Nation"))) { |
||||||
|
Score score5 = score_obj.getScore("국가 이름: ----"); |
||||||
|
score5.setScore(13); |
||||||
|
} |
||||||
|
else{ |
||||||
|
Score score5 = score_obj.getScore("국가 이름: "+m_NationArray.GetGroupName(m_InfoArrayInstance.getUserGroupUUID(player.getUniqueId(), "Nation"))); |
||||||
|
score5.setScore(13); |
||||||
|
} |
||||||
|
|
||||||
|
if(ZERO_UUID.equals(m_InfoArrayInstance.getUserGroupUUID(player.getUniqueId(), "Squad"))) { |
||||||
|
Score score6 = score_obj.getScore("분대 이름: ----"); |
||||||
|
score6.setScore(12); |
||||||
|
} |
||||||
|
else{ |
||||||
|
Score score6 = score_obj.getScore("분대 이름: "+m_SquadArray.GetGroupName(m_InfoArrayInstance.getUserGroupUUID(player.getUniqueId(), "Squad"))); |
||||||
|
score6.setScore(12); |
||||||
|
} |
||||||
|
|
||||||
|
player.setScoreboard(scoreboard); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,102 @@ |
|||||||
|
package org.poopki.duckdns.user_db.Research; |
||||||
|
|
||||||
|
import dev.lone.itemsadder.api.CustomStack; |
||||||
|
import org.bukkit.Bukkit; |
||||||
|
import org.bukkit.entity.Player; |
||||||
|
import org.bukkit.inventory.Inventory; |
||||||
|
import org.bukkit.inventory.ItemStack; |
||||||
|
import org.bukkit.plugin.Plugin; |
||||||
|
import org.bukkit.scheduler.BukkitRunnable; |
||||||
|
import org.bukkit.boss.*; |
||||||
|
import org.poopki.duckdns.user_db.Array.Account; |
||||||
|
import org.poopki.duckdns.user_db.Array.NationArray; |
||||||
|
import org.poopki.duckdns.user_db.UserInfoArray; |
||||||
|
|
||||||
|
import java.sql.SQLException; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
public class Research { |
||||||
|
public Inventory research_tab; |
||||||
|
public String m_title; |
||||||
|
public Double m_progress=0.0; |
||||||
|
public ArrayList <ItemStack> m_material = new ArrayList<ItemStack>(); |
||||||
|
public BossBar tech1_progressbar; |
||||||
|
public Integer research_point=0; |
||||||
|
public Research(String title, Plugin plugin, List<UUID>MemberList) { |
||||||
|
research_tab = Bukkit.createInventory(null, 54, title); |
||||||
|
tech1_progressbar = Bukkit.createBossBar(m_title, BarColor.BLUE,BarStyle.SOLID); |
||||||
|
new BukkitRunnable(){ |
||||||
|
@Override |
||||||
|
public void run(){ |
||||||
|
if(CheckItem()){ |
||||||
|
if(1<=m_progress) { |
||||||
|
research_point = research_point+1; |
||||||
|
m_progress = 0.0; |
||||||
|
for(UUID key: MemberList){ |
||||||
|
if(Bukkit.getPlayer(key) != null){ |
||||||
|
Bukkit.getPlayer(key).sendMessage("국가의 연구가 완료되었습니다."); |
||||||
|
} |
||||||
|
} |
||||||
|
}else{ |
||||||
|
System.out.println(m_progress); |
||||||
|
m_progress = m_progress + 0.2; |
||||||
|
} |
||||||
|
} |
||||||
|
tech1_progressbar.setProgress(m_progress); |
||||||
|
for(Player p: tech1_progressbar.getPlayers()){ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
}.runTaskTimer(plugin,0,20); |
||||||
|
} |
||||||
|
public void SetMaterials(ArrayList <ItemStack> m_material){ |
||||||
|
for(ItemStack Key: m_material){ |
||||||
|
this.m_material.add(Key); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public Inventory getInventory(){ |
||||||
|
return research_tab; |
||||||
|
} |
||||||
|
private boolean CheckItem() { |
||||||
|
if(0<m_material.size()&&m_material.size()<=3){ |
||||||
|
if(research_tab.containsAtLeast(m_material.get(0),1) &&research_tab.containsAtLeast(m_material.get(1),1) && research_tab.containsAtLeast(m_material.get(2),1)){ |
||||||
|
tech1_progressbar.setVisible(true); |
||||||
|
return true; |
||||||
|
} |
||||||
|
else{ |
||||||
|
tech1_progressbar.setVisible(false); |
||||||
|
return false; |
||||||
|
} |
||||||
|
} else if (0<m_material.size()&&m_material.size()<=6) { |
||||||
|
if(research_tab.containsAtLeast(m_material.get(0),1) &&research_tab.containsAtLeast(m_material.get(1),1) && research_tab.containsAtLeast(m_material.get(2),1) |
||||||
|
&& research_tab.containsAtLeast(m_material.get(3),1) &&research_tab.containsAtLeast(m_material.get(4),1) && research_tab.containsAtLeast(m_material.get(5),1)){ |
||||||
|
tech1_progressbar.setVisible(true); |
||||||
|
return true; |
||||||
|
} |
||||||
|
else{ |
||||||
|
tech1_progressbar.setVisible(false); |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
else if (0<m_material.size()&&m_material.size()<=9){ |
||||||
|
if(research_tab.containsAtLeast(m_material.get(0),1) &&research_tab.containsAtLeast(m_material.get(1),1) && research_tab.containsAtLeast(m_material.get(2),1) |
||||||
|
&& research_tab.containsAtLeast(m_material.get(3),1) &&research_tab.containsAtLeast(m_material.get(4),1) && research_tab.containsAtLeast(m_material.get(5),1) |
||||||
|
&& research_tab.containsAtLeast(m_material.get(6),1) &&research_tab.containsAtLeast(m_material.get(7),1) && research_tab.containsAtLeast(m_material.get(8),1)){ |
||||||
|
tech1_progressbar.setVisible(true); |
||||||
|
return true; |
||||||
|
} |
||||||
|
else{ |
||||||
|
tech1_progressbar.setVisible(false); |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
tech1_progressbar.setVisible(false); |
||||||
|
return false;} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
package org.poopki.duckdns.user_db.Research; |
||||||
|
|
||||||
|
import org.bukkit.command.Command; |
||||||
|
import org.bukkit.command.CommandExecutor; |
||||||
|
import org.bukkit.command.CommandSender; |
||||||
|
import org.bukkit.entity.Player; |
||||||
|
import org.bukkit.event.EventHandler; |
||||||
|
import org.bukkit.event.Listener; |
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent; |
||||||
|
import org.poopki.duckdns.user_db.Array.AccountArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.FarmArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.NationArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.SquadArray; |
||||||
|
import org.poopki.duckdns.user_db.Bank.AccountGUI; |
||||||
|
import org.poopki.duckdns.user_db.UserInfoArray; |
||||||
|
|
||||||
|
public class ResearchGUIEvent implements Listener,CommandExecutor { |
||||||
|
AccountArray m_AccountArray; |
||||||
|
UserInfoArray m_UserInfoArray; |
||||||
|
NationArray m_NationArray; |
||||||
|
public ResearchGUIEvent(UserInfoArray m_UIA, NationArray NA){ |
||||||
|
m_UserInfoArray = m_UIA; |
||||||
|
m_NationArray = NA; |
||||||
|
} |
||||||
|
@Override |
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { |
||||||
|
Player player = (Player) sender; |
||||||
|
if(sender instanceof Player){ |
||||||
|
switch(args[0]){ |
||||||
|
case "초기화": |
||||||
|
m_NationArray.m_NationArray.get(m_UserInfoArray.getUserGroupUUID(player.getUniqueId(),"Nation")).InitResearchItem(); |
||||||
|
case "고대": |
||||||
|
player.sendMessage("이벤트 발생"); |
||||||
|
player.openInventory(m_NationArray.getGroupTechInv(player, 0)); |
||||||
|
break; |
||||||
|
case "중세": |
||||||
|
player.sendMessage("이벤트 발생"); |
||||||
|
player.openInventory(m_NationArray.getGroupTechInv(player, 1)); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,91 @@ |
|||||||
|
package org.poopki.duckdns.user_db.TechTree; |
||||||
|
|
||||||
|
import dev.lone.itemsadder.api.CustomStack; |
||||||
|
import org.bukkit.Bukkit; |
||||||
|
import org.bukkit.entity.Player; |
||||||
|
import org.bukkit.event.Listener; |
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent; |
||||||
|
import org.bukkit.inventory.Inventory; |
||||||
|
import org.poopki.duckdns.user_db.Array.AccountArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.FarmArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.NationArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.SquadArray; |
||||||
|
import org.poopki.duckdns.user_db.GUI.ItemManager; |
||||||
|
import org.poopki.duckdns.user_db.UserInfoArray; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.List; |
||||||
|
import java.util.UUID; |
||||||
|
|
||||||
|
public class TechGUI implements Listener{ |
||||||
|
private final Inventory inv; |
||||||
|
UUID m_uuid; |
||||||
|
ItemManager m_ItemManager = new ItemManager(); |
||||||
|
AccountArray m_AA; |
||||||
|
UserInfoArray m_UIA; |
||||||
|
FarmArray m_FA; |
||||||
|
NationArray m_NA; |
||||||
|
SquadArray m_SA; |
||||||
|
public TechGUI(AccountArray AA, UserInfoArray UIA, FarmArray FA, NationArray NA, SquadArray SA, UUID uuid, InventoryClickEvent e) { |
||||||
|
m_uuid=uuid; |
||||||
|
this.inv = Bukkit.createInventory(null,54,":offset_-8::ancient_era:"); |
||||||
|
|
||||||
|
m_AA = AA; |
||||||
|
m_UIA = UIA; |
||||||
|
m_FA = FA; |
||||||
|
m_NA = NA; |
||||||
|
m_SA = SA; |
||||||
|
initItemSetting(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initItemSetting() { |
||||||
|
/* |
||||||
|
inv.setItem(0,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_SA,m_uuid, "User")); |
||||||
|
inv.setItem(1,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_SA,m_uuid, "Nation")); |
||||||
|
inv.setItem(2,m_ItemManager.GetBalance(m_AA, m_UIA, m_FA, m_NA,m_SA,m_uuid, "Farm")); |
||||||
|
|
||||||
|
inv.setItem(9, m_ItemManager.btn1); |
||||||
|
inv.setItem(18, m_ItemManager.btn2); |
||||||
|
inv.setItem(10, m_ItemManager.btn3); |
||||||
|
inv.setItem(19, m_ItemManager.btn4); |
||||||
|
inv.setItem(11, m_ItemManager.btn5); |
||||||
|
inv.setItem(20, m_ItemManager.btn6); |
||||||
|
|
||||||
|
CustomStack stack = CustomStack.getInstance("digits:digit-zero"); |
||||||
|
ItemStack itemStack = stack.getItemStack(); |
||||||
|
*/ |
||||||
|
|
||||||
|
inv.setItem(27, CustomStack.getInstance("techtree:agriculture_"+ Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"agriculture"))).getItemStack()); |
||||||
|
|
||||||
|
inv.setItem(20, CustomStack.getInstance("techtree:pottery_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"pottery"))).getItemStack()); |
||||||
|
inv.setItem(29, CustomStack.getInstance("techtree:archery_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"archery"))).getItemStack()); |
||||||
|
inv.setItem(38, CustomStack.getInstance("techtree:mining_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"mining"))).getItemStack()); |
||||||
|
|
||||||
|
inv.setItem(13, CustomStack.getInstance("techtree:animal_husbandry_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"animal_husbandry"))).getItemStack()); |
||||||
|
inv.setItem(22, CustomStack.getInstance("techtree:writing_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"writing"))).getItemStack()); |
||||||
|
inv.setItem(31, CustomStack.getInstance("techtree:masonry_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"masonry"))).getItemStack()); |
||||||
|
inv.setItem(40, CustomStack.getInstance("techtree:bronze_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"bronze"))).getItemStack()); |
||||||
|
|
||||||
|
inv.setItem(15, CustomStack.getInstance("techtree:calendar_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"calendar"))).getItemStack()); |
||||||
|
inv.setItem(24, CustomStack.getInstance("techtree:trapping_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"trapping"))).getItemStack()); |
||||||
|
inv.setItem(33, CustomStack.getInstance("techtree:writing_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"writing"))).getItemStack()); |
||||||
|
inv.setItem(42, CustomStack.getInstance("techtree:wheel_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"wheel"))).getItemStack()); |
||||||
|
inv.setItem(51, CustomStack.getInstance("techtree:optics_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"optics"))).getItemStack()); |
||||||
|
|
||||||
|
inv.setItem(17, CustomStack.getInstance("techtree:sailing_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"sailing"))).getItemStack()); |
||||||
|
inv.setItem(26, CustomStack.getInstance("techtree:mathematics_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"mathematics"))).getItemStack()); |
||||||
|
inv.setItem(35, CustomStack.getInstance("techtree:construction_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"construction"))).getItemStack()); |
||||||
|
inv.setItem(44, CustomStack.getInstance("techtree:horseback_"+Integer.toString(m_NA.GetGroupTechTree(m_UIA.getUserGroupUUID(m_uuid,"Nation"),"horseback"))).getItemStack()); |
||||||
|
} |
||||||
|
|
||||||
|
public void open(Player player){ |
||||||
|
player.openInventory(inv); |
||||||
|
} |
||||||
|
|
||||||
|
public void inven(InventoryClickEvent e){ |
||||||
|
Player p = (Player) e.getWhoClicked(); |
||||||
|
Inventory m_inv = e.getClickedInventory(); |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,237 @@ |
|||||||
|
package org.poopki.duckdns.user_db.TechTree; |
||||||
|
|
||||||
|
import dev.lone.itemsadder.api.CustomStack; |
||||||
|
import org.bukkit.command.Command; |
||||||
|
import org.bukkit.command.CommandExecutor; |
||||||
|
import org.bukkit.command.CommandSender; |
||||||
|
import org.bukkit.entity.Player; |
||||||
|
import org.bukkit.event.EventHandler; |
||||||
|
import org.bukkit.event.Listener; |
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent; |
||||||
|
import org.bukkit.inventory.ItemStack; |
||||||
|
import org.poopki.duckdns.user_db.Array.AccountArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.FarmArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.NationArray; |
||||||
|
import org.poopki.duckdns.user_db.Array.SquadArray; |
||||||
|
import org.poopki.duckdns.user_db.UserInfoArray; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
import java.util.UUID; |
||||||
|
|
||||||
|
|
||||||
|
public class TechGUIEvent implements Listener,CommandExecutor { |
||||||
|
AccountArray m_AccountArray; |
||||||
|
UserInfoArray m_UserInfoArray; |
||||||
|
FarmArray m_FarmArray; |
||||||
|
NationArray m_NationArray; |
||||||
|
SquadArray m_SquadArray; |
||||||
|
UUID ZERO_UUID = new UUID(0,0); |
||||||
|
ArrayList<String> PrevTech = new ArrayList<String>(); |
||||||
|
public TechGUIEvent(UserInfoArray m_UIA, FarmArray FA, NationArray NA, SquadArray SA, AccountArray AA){ |
||||||
|
m_UserInfoArray = m_UIA; |
||||||
|
m_AccountArray = AA; |
||||||
|
m_FarmArray = FA; |
||||||
|
m_NationArray = NA; |
||||||
|
m_SquadArray = SA; |
||||||
|
} |
||||||
|
@Override |
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { |
||||||
|
if(sender instanceof Player){ |
||||||
|
if(ZERO_UUID.equals(m_UserInfoArray.getUserGroupUUID(((Player) sender).getUniqueId(), "Nation"))){ |
||||||
|
Player player = (Player) sender; |
||||||
|
player.sendMessage("국가에 소속된 유저만 사용이 가능"); |
||||||
|
} |
||||||
|
else{ |
||||||
|
Player player = (Player) sender; |
||||||
|
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray,player.getUniqueId(), null); |
||||||
|
inv.open(player); |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
@EventHandler |
||||||
|
public boolean inven_Tech(InventoryClickEvent e){ |
||||||
|
Player player = (Player) e.getWhoClicked();; |
||||||
|
String name = e.getView().getTitle(); |
||||||
|
if(name.equals(":offset_-8::ancient_era:")){ |
||||||
|
if(CheckClickItem(e.getCurrentItem(),"techtree:agriculture_0")){ |
||||||
|
e.setCancelled(true); |
||||||
|
if(CheckPoint(player,0, "Nation")){ |
||||||
|
SelectTech(player, "Nation", "agriculture", 0); |
||||||
|
player.sendMessage("국가 테크를 선택하였습니다."); |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("테크 포인트가 부족합니다."); |
||||||
|
} |
||||||
|
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e); |
||||||
|
inv.open(player); |
||||||
|
return true; |
||||||
|
} |
||||||
|
if(CheckClickItem(e.getCurrentItem(),"techtree:pottery_0")){ |
||||||
|
e.setCancelled(true); |
||||||
|
PrevTech.add("agriculture"); |
||||||
|
if(CheckPoint(player,0, "Nation")){ |
||||||
|
if(CheckTechTree(player,"Nation",PrevTech)){ |
||||||
|
SelectTech(player, "Nation", "pottery", 0); |
||||||
|
player.sendMessage("국가 테크를 선택하였습니다."); |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("이전 테크를 선택하지 않았습니다."); |
||||||
|
} |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("테크 포인트가 부족합니다."); |
||||||
|
} |
||||||
|
PrevTech.clear(); |
||||||
|
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e); |
||||||
|
inv.open(player); |
||||||
|
return true; |
||||||
|
} |
||||||
|
if(CheckClickItem(e.getCurrentItem(),"techtree:mining_0")){ |
||||||
|
e.setCancelled(true); |
||||||
|
PrevTech.add("agriculture"); |
||||||
|
if(CheckPoint(player,0, "Nation")){ |
||||||
|
if(CheckTechTree(player,"Nation",PrevTech)){ |
||||||
|
SelectTech(player, "Nation", "mining", 0); |
||||||
|
player.sendMessage("국가 테크를 선택하였습니다."); |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("이전 테크를 선택하지 않았습니다."); |
||||||
|
} |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("테크 포인트가 부족합니다."); |
||||||
|
} |
||||||
|
PrevTech.clear(); |
||||||
|
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e); |
||||||
|
inv.open(player); |
||||||
|
return true; |
||||||
|
} |
||||||
|
if(CheckClickItem(e.getCurrentItem(),"techtree:archery_0")){ |
||||||
|
e.setCancelled(true); |
||||||
|
PrevTech.add("agriculture"); |
||||||
|
if(CheckPoint(player,0, "Nation")){ |
||||||
|
if(CheckTechTree(player,"Nation",PrevTech)){ |
||||||
|
SelectTech(player, "Nation", "archery", 0); |
||||||
|
player.sendMessage("국가 테크를 선택하였습니다."); |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("이전 테크를 선택하지 않았습니다."); |
||||||
|
} |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("테크 포인트가 부족합니다."); |
||||||
|
} |
||||||
|
PrevTech.clear(); |
||||||
|
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e); |
||||||
|
inv.open(player); |
||||||
|
return true; |
||||||
|
} |
||||||
|
if(CheckClickItem(e.getCurrentItem(),"techtree:animal_husbandry_0")){ |
||||||
|
e.setCancelled(true); |
||||||
|
PrevTech.add("pottery"); |
||||||
|
PrevTech.add("agriculture"); |
||||||
|
if(CheckPoint(player,0, "Nation")){ |
||||||
|
if(CheckTechTree(player,"Nation",PrevTech)){ |
||||||
|
SelectTech(player, "Nation", "animal_husbandry", 0); |
||||||
|
player.sendMessage("국가 테크를 선택하였습니다."); |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("이전 테크를 선택하지 않았습니다."); |
||||||
|
} |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("테크 포인트가 부족합니다."); |
||||||
|
} |
||||||
|
PrevTech.clear(); |
||||||
|
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e); |
||||||
|
inv.open(player); |
||||||
|
return true; |
||||||
|
} |
||||||
|
if(CheckClickItem(e.getCurrentItem(),"techtree:writing_0")){ |
||||||
|
e.setCancelled(true); |
||||||
|
PrevTech.add("pottery"); |
||||||
|
PrevTech.add("agriculture"); |
||||||
|
if(CheckPoint(player,0, "Nation")){ |
||||||
|
if(CheckTechTree(player,"Nation",PrevTech)){ |
||||||
|
SelectTech(player, "Nation", "writing", 0); |
||||||
|
player.sendMessage("국가 테크를 선택하였습니다."); |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("이전 테크를 선택하지 않았습니다."); |
||||||
|
} |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("테크 포인트가 부족합니다."); |
||||||
|
} |
||||||
|
PrevTech.clear(); |
||||||
|
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e); |
||||||
|
inv.open(player); |
||||||
|
return true; |
||||||
|
} |
||||||
|
if(CheckClickItem(e.getCurrentItem(),"techtree:masonry_0")){ |
||||||
|
e.setCancelled(true); |
||||||
|
PrevTech.add("archery"); |
||||||
|
PrevTech.add("agriculture"); |
||||||
|
if(CheckPoint(player,0, "Nation")){ |
||||||
|
if(CheckTechTree(player,"Nation",PrevTech)){ |
||||||
|
SelectTech(player, "Nation", "masonry", 0); |
||||||
|
player.sendMessage("국가 테크를 선택하였습니다."); |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("이전 테크를 선택하지 않았습니다."); |
||||||
|
} |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("테크 포인트가 부족합니다."); |
||||||
|
} |
||||||
|
PrevTech.clear(); |
||||||
|
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e); |
||||||
|
inv.open(player); |
||||||
|
return true; |
||||||
|
} |
||||||
|
if(CheckClickItem(e.getCurrentItem(),"techtree:bronze_0")){ |
||||||
|
e.setCancelled(true); |
||||||
|
PrevTech.add("mining"); |
||||||
|
PrevTech.add("agriculture"); |
||||||
|
if(CheckPoint(player,0, "Nation")){ |
||||||
|
if(CheckTechTree(player,"Nation",PrevTech)){ |
||||||
|
SelectTech(player, "Nation", "bronze", 0); |
||||||
|
player.sendMessage("국가 테크를 선택하였습니다."); |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("이전 테크를 선택하지 않았습니다."); |
||||||
|
} |
||||||
|
} |
||||||
|
else{ |
||||||
|
player.sendMessage("테크 포인트가 부족합니다."); |
||||||
|
} |
||||||
|
PrevTech.clear(); |
||||||
|
TechGUI inv = new TechGUI(m_AccountArray,m_UserInfoArray,m_FarmArray,m_NationArray, m_SquadArray, player.getUniqueId(), e); |
||||||
|
inv.open(player); |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
public boolean CheckClickItem(ItemStack ClickedItem, String Name){ |
||||||
|
return ClickedItem.getItemMeta().getDisplayName().equals(CustomStack.getInstance(Name).getItemStack().getItemMeta().getDisplayName()); |
||||||
|
} |
||||||
|
public boolean CheckPoint(Player p, Integer page, String Type){ |
||||||
|
return !m_NationArray.m_NationArray.get(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),Type)).m_ResearchArray.get(page).research_point.equals(0); |
||||||
|
} |
||||||
|
public boolean CheckTechTree(Player p, String Type, ArrayList<String> PrevTech){ |
||||||
|
for(String key: PrevTech){ |
||||||
|
if(m_NationArray.m_NationArray.get(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),Type)).GetTechTree(key)==0){ |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public void SelectTech(Player p, String Type, String TechName, Integer page){ |
||||||
|
m_NationArray.m_NationArray.get(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),Type)).SetTechTree(TechName, 1); |
||||||
|
m_NationArray.m_NationArray.get(m_UserInfoArray.getUserGroupUUID(p.getUniqueId(),Type)).m_ResearchArray.get(page).research_point--; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package org.poopki.duckdns.user_db.TechTree; |
||||||
|
|
||||||
|
import org.poopki.duckdns.user_db.UserInfo; |
||||||
|
|
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.UUID; |
||||||
|
|
||||||
|
public class TechStat { |
||||||
|
private Map<String, Integer> m_TechStat = new HashMap<String, Integer>(); |
||||||
|
|
||||||
|
public void InitTechTree(String A, Integer B){ |
||||||
|
m_TechStat.put(A,B); |
||||||
|
} |
||||||
|
public void SetTechTree(String TechName, Integer set){ |
||||||
|
m_TechStat.replace(TechName,set); |
||||||
|
} |
||||||
|
|
||||||
|
public int GetTechTree(String TechName){ |
||||||
|
return m_TechStat.get(TechName); |
||||||
|
} |
||||||
|
} |
@ -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