fix miner
This commit is contained in:
parent
bcdf49e996
commit
4df924e3ce
2 changed files with 18 additions and 18 deletions
|
@ -12,7 +12,7 @@ import static me.night.nullvalkyrie.miners.CryptoMiner.generate;
|
||||||
import static me.night.nullvalkyrie.miners.CryptoMiner.getMiner;
|
import static me.night.nullvalkyrie.miners.CryptoMiner.getMiner;
|
||||||
|
|
||||||
public class MinerCommand extends Command {
|
public class MinerCommand extends Command {
|
||||||
private Main main;
|
private final Main main;
|
||||||
public MinerCommand(Main main) {
|
public MinerCommand(Main main) {
|
||||||
super(
|
super(
|
||||||
"miner",
|
"miner",
|
||||||
|
@ -28,7 +28,7 @@ public class MinerCommand extends Command {
|
||||||
if(sender instanceof Player) {
|
if(sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
new MinerGUI(main, player);
|
new MinerGUI(main, player);
|
||||||
int seconds = Math.round((new Date().getTime() - getMiner("1").getLastclaim()) / 1000);
|
int seconds = Math.round((new Date().getTime() - (long) getMiner("1").get("lastclaim")) / 1000);
|
||||||
System.out.println("Seconds" + seconds);
|
System.out.println("Seconds" + seconds);
|
||||||
generate(50, seconds);
|
generate(50, seconds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,15 +12,12 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MinerGUI {
|
public class MinerGUI {
|
||||||
private Main main;
|
private final FileConfiguration file;
|
||||||
private FileConfiguration file;
|
|
||||||
private Inventory inv;
|
private Inventory inv;
|
||||||
public MinerGUI(Main main, Player player) {
|
public MinerGUI(Main main, Player player) {
|
||||||
this.main = main;
|
|
||||||
if(!main.getDataFolder().exists()) main.getDataFolder().mkdir();
|
if(!main.getDataFolder().exists()) main.getDataFolder().mkdir();
|
||||||
file = CustomItemManager.loadConfig("miners.yml");
|
file = CustomItemManager.loadConfig("miners.yml");
|
||||||
createUI();
|
createUI();
|
||||||
|
@ -35,23 +32,26 @@ public class MinerGUI {
|
||||||
ItemStack close = new ItemStack(Material.BARRIER);
|
ItemStack close = new ItemStack(Material.BARRIER);
|
||||||
ItemMeta closemeta = close.getItemMeta();
|
ItemMeta closemeta = close.getItemMeta();
|
||||||
closemeta.setDisplayName(ChatColor.WHITE + "Close the menu");
|
closemeta.setDisplayName(ChatColor.WHITE + "Close the menu");
|
||||||
closemeta.setLore(Arrays.asList(ChatColor.GRAY + "Close the menu"));
|
closemeta.setLore(List.of(ChatColor.GRAY + "Close the menu"));
|
||||||
close.setItemMeta(closemeta);
|
close.setItemMeta(closemeta);
|
||||||
inv.setItem(0, close);
|
inv.setItem(0, close);
|
||||||
int[] a = new int[]{10,11,12,13,14,15,16,19,20,21,22,23,24,25,28,29,30,31,32,33,34};
|
int[] a = new int[]{10,11,12,13,14,15,16,19,20,21,22,23,24,25,28,29,30,31,32,33,34};
|
||||||
int ind = 0;
|
int ind = 0;
|
||||||
for(String c : file.getKeys(false)) {
|
for(String c : file.getKeys(false)) {
|
||||||
ItemStack item = new ItemStack(Material.matchMaterial(file.getString(c + ".material")));
|
if (ind <= 20) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemStack item = new ItemStack(Material.matchMaterial(file.getString(c + ".material")));
|
||||||
itemMeta.setDisplayName(file.getString(c + ".name"));
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
List<String> lore = new ArrayList<>();
|
itemMeta.setDisplayName(file.getString(c + ".name"));
|
||||||
lore.add("Level: " + file.getString(c + ".level"));
|
List<String> lore = new ArrayList<>();
|
||||||
lore.add("Rate: " + file.getString(c + ".rate"));
|
lore.add("Level: " + file.getString(c + ".level"));
|
||||||
boolean b = file.getBoolean(c + ".rate") ? lore.add(ChatColor.GRAY + "Click to enable miner!") : lore.add(ChatColor.RED + "Click to disable miner!");
|
lore.add("Rate: " + file.getString(c + ".rate"));
|
||||||
itemMeta.setLore(lore);
|
boolean b = file.getBoolean(c + ".rate") ? lore.add(ChatColor.GRAY + "Click to enable miner!") : lore.add(ChatColor.RED + "Click to disable miner!");
|
||||||
item.setItemMeta(itemMeta);
|
itemMeta.setLore(lore);
|
||||||
inv.setItem(a[ind], item);
|
item.setItemMeta(itemMeta);
|
||||||
ind++;
|
inv.setItem(a[ind], item);
|
||||||
|
ind++;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue