From 4df924e3ce412809f3eca0ef741bf03f18125c3f Mon Sep 17 00:00:00 2001 From: NK Date: Wed, 16 Nov 2022 22:48:06 +0000 Subject: [PATCH] fix miner --- .../nullvalkyrie/commands/MinerCommand.java | 4 +-- .../night/nullvalkyrie/miners/MinerGUI.java | 32 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/me/night/nullvalkyrie/commands/MinerCommand.java b/src/main/java/me/night/nullvalkyrie/commands/MinerCommand.java index 1e92a16..d9b2df4 100644 --- a/src/main/java/me/night/nullvalkyrie/commands/MinerCommand.java +++ b/src/main/java/me/night/nullvalkyrie/commands/MinerCommand.java @@ -12,7 +12,7 @@ import static me.night.nullvalkyrie.miners.CryptoMiner.generate; import static me.night.nullvalkyrie.miners.CryptoMiner.getMiner; public class MinerCommand extends Command { - private Main main; + private final Main main; public MinerCommand(Main main) { super( "miner", @@ -28,7 +28,7 @@ public class MinerCommand extends Command { if(sender instanceof Player) { Player player = (Player) sender; 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); generate(50, seconds); } diff --git a/src/main/java/me/night/nullvalkyrie/miners/MinerGUI.java b/src/main/java/me/night/nullvalkyrie/miners/MinerGUI.java index d6213cd..8e0ece5 100644 --- a/src/main/java/me/night/nullvalkyrie/miners/MinerGUI.java +++ b/src/main/java/me/night/nullvalkyrie/miners/MinerGUI.java @@ -12,15 +12,12 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class MinerGUI { - private Main main; - private FileConfiguration file; + private final FileConfiguration file; private Inventory inv; public MinerGUI(Main main, Player player) { - this.main = main; if(!main.getDataFolder().exists()) main.getDataFolder().mkdir(); file = CustomItemManager.loadConfig("miners.yml"); createUI(); @@ -35,23 +32,26 @@ public class MinerGUI { ItemStack close = new ItemStack(Material.BARRIER); ItemMeta closemeta = close.getItemMeta(); 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); 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 ind = 0; for(String c : file.getKeys(false)) { - ItemStack item = new ItemStack(Material.matchMaterial(file.getString(c + ".material"))); - ItemMeta itemMeta = item.getItemMeta(); - itemMeta.setDisplayName(file.getString(c + ".name")); - List lore = new ArrayList<>(); - lore.add("Level: " + file.getString(c + ".level")); - lore.add("Rate: " + file.getString(c + ".rate")); - boolean b = file.getBoolean(c + ".rate") ? lore.add(ChatColor.GRAY + "Click to enable miner!") : lore.add(ChatColor.RED + "Click to disable miner!"); - itemMeta.setLore(lore); - item.setItemMeta(itemMeta); - inv.setItem(a[ind], item); - ind++; + if (ind <= 20) { + ItemStack item = new ItemStack(Material.matchMaterial(file.getString(c + ".material"))); + ItemMeta itemMeta = item.getItemMeta(); + itemMeta.setDisplayName(file.getString(c + ".name")); + List lore = new ArrayList<>(); + lore.add("Level: " + file.getString(c + ".level")); + lore.add("Rate: " + file.getString(c + ".rate")); + boolean b = file.getBoolean(c + ".rate") ? lore.add(ChatColor.GRAY + "Click to enable miner!") : lore.add(ChatColor.RED + "Click to disable miner!"); + itemMeta.setLore(lore); + item.setItemMeta(itemMeta); + inv.setItem(a[ind], item); + ind++; + } + } }