diff --git a/src/me/blackvein/quests/Quest.java b/src/me/blackvein/quests/Quest.java index 9ea37523e..6057dc96f 100644 --- a/src/me/blackvein/quests/Quest.java +++ b/src/me/blackvein/quests/Quest.java @@ -86,6 +86,36 @@ public class Quest { q.currentStage = stages.get(stages.indexOf(q.currentStage) + 1); q.addEmpties(); + for (Entry e : q.currentStage.itemsToCollect.entrySet()) { + + if ((Boolean) e.getValue() == true) { + + Map tempMap = (Map) e.getKey(); + for (Entry e2 : tempMap.entrySet()) { + + questItems.put((Material) e2.getKey(), (Integer) e2.getValue()); + + } + + } + + } + + for (Entry e : q.currentStage.itemsToCraft.entrySet()) { + + if ((Boolean) e.getValue() == true) { + + Map tempMap = (Map) e.getKey(); + for (Entry e2 : tempMap.entrySet()) { + + questItems.put((Material) e2.getKey(), (Integer) e2.getValue()); + + } + + } + + } + player.sendMessage(ChatColor.GOLD + "---(Objectives)---"); for(String s : q.getObjectives()){ diff --git a/src/me/blackvein/quests/Quester.java b/src/me/blackvein/quests/Quester.java index 8c0c116cc..f8dea679e 100644 --- a/src/me/blackvein/quests/Quester.java +++ b/src/me/blackvein/quests/Quester.java @@ -101,298 +101,23 @@ public class Quester { public LinkedList getObjectives() { - if(delayStartTime == 0){ - - LinkedList unfinishedObjectives = new LinkedList(); - LinkedList finishedObjectives = new LinkedList(); - LinkedList objectives = new LinkedList(); + LinkedList unfinishedObjectives = new LinkedList(); + LinkedList finishedObjectives = new LinkedList(); + LinkedList objectives = new LinkedList(); - for (Entry e : currentStage.blocksToDamage.entrySet()) { + for (Entry e : currentStage.blocksToDamage.entrySet()) { - for (Entry e2 : blocksDamaged.entrySet()) { + for (Entry e2 : blocksDamaged.entrySet()) { - if (((Material) e2.getKey()).equals((Material) e.getKey())) { + if (((Material) e2.getKey()).equals((Material) e.getKey())) { - if (((Integer) e2.getValue()) < ((Integer) e.getValue())) { + if (((Integer) e2.getValue()) < ((Integer) e.getValue())) { - unfinishedObjectives.add(ChatColor.GREEN + "Damage " + Quester.prettyItemString(((Material) e2.getKey()).getId()) + ": " + (Integer) e2.getValue() + "/" + ((Integer) e.getValue())); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Damage " + Quester.prettyItemString(((Material) e2.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } - - } - - } - - } - - for (Entry e : currentStage.blocksToBreak.entrySet()) { - - for (Entry e2 : blocksBroken.entrySet()) { - - if (((Material) e2.getKey()).equals((Material) e.getKey())) { - - if (((Integer) e2.getValue()) < ((Integer) e.getValue())) { - - unfinishedObjectives.add(ChatColor.GREEN + "Break " + Quester.prettyItemString(((Material) e2.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Break " + Quester.prettyItemString(((Material) e2.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } - - } - - } - - } - - for (Entry e : currentStage.blocksToPlace.entrySet()) { - - for (Entry e2 : blocksPlaced.entrySet()) { - - if (((Material) e2.getKey()).equals((Material) e.getKey())) { - - if (((Integer) e2.getValue()) < ((Integer) e.getValue())) { - - unfinishedObjectives.add(ChatColor.GREEN + "Place " + Quester.prettyItemString(((Material) e2.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Place " + Quester.prettyItemString(((Material) e2.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } - - } - - } - - } - - for (Entry e : currentStage.itemsToCollect.entrySet()) { - - Map map = (Map) e.getKey(); - - for (Entry e2 : map.entrySet()) { - - for (Entry e3 : itemsCollected.entrySet()) { - - if (((Material) e3.getKey()).equals((Material) e2.getKey())) { - - if (((Integer) e3.getValue()) < ((Integer) e2.getValue())) { - - unfinishedObjectives.add(ChatColor.GREEN + "Collect " + Quester.prettyItemString(((Material) e3.getKey()).getId()) + ": " + ((Integer) e3.getValue()) + "/" + ((Integer) e2.getValue())); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Collect " + Quester.prettyItemString(((Material) e3.getKey()).getId()) + ": " + ((Integer) e3.getValue()) + "/" + ((Integer) e2.getValue())); - - } - - } - - } - - } - - } - - for (Entry e : currentStage.blocksToUse.entrySet()) { - - for (Entry e2 : blocksUsed.entrySet()) { - - if (((Material) e2.getKey()).equals((Material) e.getKey())) { - - if (((Integer) e2.getValue()) < ((Integer) e.getValue())) { - - unfinishedObjectives.add(ChatColor.GREEN + "Use " + Quester.prettyItemString(((Material) e2.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Use " + Quester.prettyItemString(((Material) e2.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } - - } - - } - - } - - for (Entry e : currentStage.blocksToCut.entrySet()) { - - for (Entry e2 : blocksCut.entrySet()) { - - if (((Material) e2.getKey()).equals((Material) e.getKey())) { - - if (((Integer) e2.getValue()) < ((Integer) e.getValue())) { - - unfinishedObjectives.add(ChatColor.GREEN + "Cut " + Quester.prettyItemString(((Material) e2.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Cut " + Quester.prettyItemString(((Material) e2.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } - - } - - } - - } - - if (currentStage.fishToCatch != null) { - - if (fishCaught < currentStage.fishToCatch) { - - unfinishedObjectives.add(ChatColor.GREEN + "Catch Fish: " + fishCaught + "/" + currentStage.fishToCatch); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Catch Fish: " + fishCaught + "/" + currentStage.fishToCatch); - - } - - } - - Map set; - Map set2; - Set enchantSet; - Set enchantSet2; - Collection matSet; - Enchantment enchantment = null; - Enchantment enchantment2 = null; - Material mat = null; - int num1; - int num2; - - for (Entry e : currentStage.itemsToEnchant.entrySet()) { - - for (Entry e2 : itemsEnchanted.entrySet()) { - - set = (Map) e2.getKey(); - set2 = (Map) e.getKey(); - enchantSet = (Set) set.keySet(); - enchantSet2 = (Set) set2.keySet(); - for (Object o : enchantSet.toArray()) { - - enchantment = (Enchantment) o; - - } - for (Object o : enchantSet2.toArray()) { - - enchantment2 = (Enchantment) o; - - } - num1 = (Integer) e2.getValue(); - num2 = (Integer) e.getValue(); - - matSet = (Collection) set.values(); - - for (Object o : matSet.toArray()) { - - mat = (Material) o; - - } - - if (enchantment2 == enchantment) { - - if (num1 < num2) { - - unfinishedObjectives.add(ChatColor.GREEN + "Enchant " + Quester.prettyItemString(mat.getId()) + " with " + Quester.prettyEnchantmentString(enchantment) + ": " + num1 + "/" + num2); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Enchant " + Quester.prettyItemString(mat.getId()) + " with " + Quester.prettyEnchantmentString(enchantment) + ": " + num1 + "/" + num2); - - } - - } - - } - - } - - for (EntityType e : currentStage.mobsToKill) { - - for (EntityType e2 : mobsKilled) { - - if (e == e2) { - - if (mobNumKilled.get(mobsKilled.indexOf(e2)) < currentStage.mobNumToKill.get(currentStage.mobsToKill.indexOf(e))) { - - if (currentStage.locationsToKillWithin.isEmpty()) { - unfinishedObjectives.add(ChatColor.GREEN + "Kill " + Quester.prettyMobString(e) + ": " + (mobNumKilled.get(mobsKilled.indexOf(e2))) + "/" + (currentStage.mobNumToKill.get(currentStage.mobsToKill.indexOf(e)))); - } else { - unfinishedObjectives.add(ChatColor.GREEN + "Kill " + Quester.prettyMobString(e) + " at " + currentStage.areaNames.get(currentStage.mobsToKill.indexOf(e)) + ": " + (mobNumKilled.get(mobsKilled.indexOf(e2))) + "/" + (currentStage.mobNumToKill.get(currentStage.mobsToKill.indexOf(e)))); - } - } else { - - if (currentStage.locationsToKillWithin.isEmpty()) { - finishedObjectives.add(ChatColor.GRAY + "Kill " + Quester.prettyMobString(e) + ": " + (mobNumKilled.get(mobsKilled.indexOf(e2))) + "/" + (currentStage.mobNumToKill.get(currentStage.mobsToKill.indexOf(e)))); - } else { - finishedObjectives.add(ChatColor.GRAY + "Kill " + Quester.prettyMobString(e) + " at " + currentStage.areaNames.get(currentStage.mobsToKill.indexOf(e)) + ": " + (mobNumKilled.get(mobsKilled.indexOf(e2))) + "/" + (currentStage.mobNumToKill.get(currentStage.mobsToKill.indexOf(e)))); - } - - } - - } - - } - - } - - if (currentStage.playersToKill != null) { - - if (playersKilled < currentStage.playersToKill) { - - unfinishedObjectives.add(ChatColor.GREEN + "Kill a Player: " + playersKilled + "/" + currentStage.playersToKill); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Kill a Player: " + playersKilled + "/" + currentStage.playersToKill); - - } - - } - - for (NPC n : currentStage.citizensToInteract) { - - for (Entry e : citizensInteracted.entrySet()) { - - if (((NPC) e.getKey()).equals(n)) { - - if (((Boolean) e.getValue()) == false) { - - unfinishedObjectives.add(ChatColor.GREEN + "Talk to " + n.getFullName()); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Talk to " + n.getName()); - - } - - } - - } - - } - - for (NPC n : currentStage.citizensToKill) { - - for (NPC n2 : citizensKilled) { - - if (citizenNumKilled.get(citizensKilled.indexOf(n2)) < currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n))) { - - unfinishedObjectives.add(ChatColor.GREEN + "Kill " + n.getFullName() + ChatColor.GREEN + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n))); + unfinishedObjectives.add(ChatColor.GREEN + "Damage " + Quester.prettyItemString(((Material) e2.getKey()).getId()) + ": " + (Integer) e2.getValue() + "/" + ((Integer) e.getValue())); } else { - finishedObjectives.add(ChatColor.GRAY + "Kill " + n.getName() + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n))); + finishedObjectives.add(ChatColor.GRAY + "Damage " + Quester.prettyItemString(((Material) e2.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); } @@ -400,125 +125,372 @@ public class Quester { } - for (Entry e : currentStage.mobsToTame.entrySet()) { - - for (Entry e2 : mobsTamed.entrySet()) { - - if (e.getKey().equals(e2.getKey())) { - - if ((Integer) e2.getValue() < (Integer) e.getValue()) { - - unfinishedObjectives.add(ChatColor.GREEN + "Tame " + getCapitalized(((EntityType) e.getKey()).getName()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Tame " + getCapitalized(((EntityType) e.getKey()).getName()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } - - } - - } - - } - - for (Entry e : currentStage.sheepToShear.entrySet()) { - - for (Entry e2 : sheepSheared.entrySet()) { - - if (e.getKey().equals(e2.getKey())) { - - if ((Integer) e2.getValue() < (Integer) e.getValue()) { - - unfinishedObjectives.add(ChatColor.GREEN + "Shear " + ((DyeColor) e.getKey()).name().toString().toLowerCase() + " sheep: " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Shear " + ((DyeColor) e.getKey()).name().toString().toLowerCase() + " sheep: " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } - - } - - } - - } - - for (Entry e : currentStage.itemsToCraft.entrySet()) { - - for (Entry e2 : itemsCrafted.entrySet()) { - - if (e.getKey().equals(e2.getKey())) { - - if ((Integer) e2.getValue() < (Integer) e.getValue()) { - - unfinishedObjectives.add(ChatColor.GREEN + "Craft " + prettyItemString(((Material) e.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Craft " + prettyItemString(((Material) e.getKey()).getId()) + ": " + ((Integer) e2.getValue()) + "/" + ((Integer) e.getValue())); - - } - - } - - } - - } - - for (Location l : currentStage.locationsToReach) { - - for (Location l2 : locationsReached) { - - if (l.equals(l2)) { - - if (hasReached.get(locationsReached.indexOf(l2)) == false) { - - unfinishedObjectives.add(ChatColor.GREEN + "Go to " + currentStage.locationNames.get(currentStage.locationsToReach.indexOf(l))); - - } else { - - finishedObjectives.add(ChatColor.GRAY + "Go to " + currentStage.locationNames.get(currentStage.locationsToReach.indexOf(l))); - - } - - } - - } - - } - - objectives.addAll(unfinishedObjectives); - objectives.addAll(finishedObjectives); - - return objectives; - - }else{ - - long time; - if(delayTimeLeft > -1) - time = delayTimeLeft - (System.currentTimeMillis() - delayStartTime); - else - time = currentStage.delay - (System.currentTimeMillis() - delayStartTime); - - LinkedList obj = new LinkedList(); - String s; - - if(currentStage.delayMessage != null){ - - s = currentStage.delayMessage; - - s = plugin.parseString(s, currentQuest); - s = s.replaceAll("