diff --git a/src/main/java/de/fanta/challenges/challenges/AllItemsChallenge.java b/src/main/java/de/fanta/challenges/challenges/AllItemsChallenge.java index c77445e..46b2a5d 100644 --- a/src/main/java/de/fanta/challenges/challenges/AllItemsChallenge.java +++ b/src/main/java/de/fanta/challenges/challenges/AllItemsChallenge.java @@ -27,6 +27,9 @@ private static final Challenges plugin = Challenges.getPlugin(); + private static int itemcount = 0; + private static boolean itemcountboolean = false; + public static void start() { if (items.isEmpty()) { for (Material mat : Material.values()) { @@ -64,7 +67,17 @@ next(pp, false); } } - bossBar.setTitle(ChatUtil.GREEN + "Item » " + ChatUtil.BLUE + item.toString().replace("_", " ") + ChatUtil.BLUE + " (" + ChatUtil.GREEN + items.size() + ChatUtil.BLUE + ")"); + + if (!itemcountboolean) { + for (Material mat : Material.values()) { + if (mat.isItem() && !mat.isAir() && !plugin.getNotAvailableMaterials().contains(mat)) + itemcount++; + } + itemcountboolean = true; + } + + + bossBar.setTitle(ChatUtil.GREEN + "Item » " + ChatUtil.BLUE + item.toString().replace("_", " ") + ChatUtil.BLUE + " (" + ChatUtil.GREEN + (itemcount - items.size()) + "/" + itemcount + ChatUtil.BLUE + ")"); } else { bossBar.setTitle(ChatUtil.GREEN + "Alle Items gesammelt!"); ChatUtil.sendBrodcastMessage("Alle Items gesammelt!"); @@ -87,20 +100,11 @@ Random r = new Random(); item = Material.valueOf(items.get(r.nextInt((items.size() - 1) + 1))); GUIUtils.setConfig("allitemscurrentitem", new ItemStack(item)); - FileConfiguration config = Challenges.getPlugin().getAllItemsConfig(); if (skipped) { ChatUtil.sendBrodcastMessage("Item: " + ChatUtil.BLUE + old.toString().replace("_", " ") + ChatUtil.GREEN + " wurde von " + p.getName() + " übersprungen."); - config.set(old.toString(), new ItemStack(old)); - try { - config.save(Challenges.getPlugin().getAllItemsConfigFile()); - } catch (IOException e) { - e.printStackTrace(); - } - } else { ChatUtil.sendBrodcastMessage("Item: " + ChatUtil.BLUE + old.toString().replace("_", " ") + ChatUtil.GREEN + " wurde von " + p.getName() + " Registriert."); } - ChatUtil.sendBrodcastMessage("Neues Item: " + ChatUtil.BLUE + item.toString().replace("_", " ") + ChatUtil.GREEN + " (Es fehlen noch " + ChatUtil.BLUE + (items.size()) + ChatUtil.GREEN + " Items)"); for (Player pp : Bukkit.getOnlinePlayers()) { pp.playSound(pp.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1, 1);