You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
4.1 KiB
102 lines
4.1 KiB
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;} |
|
|
|
} |
|
|
|
}
|
|
|