diff --git a/src/main/java/me/blackvein/quests/QuestData.java b/src/main/java/me/blackvein/quests/QuestData.java index 083e373a0..c1feae58e 100644 --- a/src/main/java/me/blackvein/quests/QuestData.java +++ b/src/main/java/me/blackvein/quests/QuestData.java @@ -292,9 +292,9 @@ public class QuestData { } }; - public LinkedHashMap itemsDelivered = new LinkedHashMap() { + public LinkedHashMap itemsCrafted = new LinkedHashMap() { - private static final long serialVersionUID = 2712497347022734646L; + private static final long serialVersionUID = 2774356294049526105L; @Override public Integer put(ItemStack key, Integer val) { @@ -362,6 +362,41 @@ public class QuestData { } }; + public LinkedHashMap itemsDelivered = new LinkedHashMap() { + + private static final long serialVersionUID = 2712497347022734646L; + + @Override + public Integer put(ItemStack key, Integer val) { + Integer data = super.put(key, val); + if (doJournalUpdate) + quester.updateJournal(); + return data; + } + + @Override + public Integer remove(Object key) { + Integer i = super.remove(key); + if (doJournalUpdate) + quester.updateJournal(); + return i; + } + + @Override + public void clear() { + super.clear(); + if (doJournalUpdate) + quester.updateJournal(); + } + + @Override + public void putAll(Map m) { + super.putAll(m); + if (doJournalUpdate) + quester.updateJournal(); + } + }; + public LinkedList mobsKilled = new LinkedList() { private static final long serialVersionUID = 8178007458817522183L; @@ -1000,7 +1035,6 @@ public class QuestData { } }; - //public Map mobsTamed = new EnumMap(EntityType.class) { public LinkedHashMap mobsTamed = new LinkedHashMap() { private static final long serialVersionUID = 3851959471748032699L; @@ -1036,7 +1070,6 @@ public class QuestData { } }; - //public Map sheepSheared = new EnumMap(DyeColor.class) { public LinkedHashMap sheepSheared = new LinkedHashMap() { private static final long serialVersionUID = -6016463677133534885L; diff --git a/src/main/java/me/blackvein/quests/QuestFactory.java b/src/main/java/me/blackvein/quests/QuestFactory.java index 99bd850e3..a8252817a 100644 --- a/src/main/java/me/blackvein/quests/QuestFactory.java +++ b/src/main/java/me/blackvein/quests/QuestFactory.java @@ -989,12 +989,13 @@ public class QuestFactory implements ConversationAbandonedListener { LinkedList cutIds; LinkedList cutAmounts; LinkedList cutDurability; - Integer fish; - Integer players; + LinkedList deliveryItems; LinkedList enchantments; LinkedList enchantmentIds; LinkedList enchantmentAmounts; - LinkedList deliveryItems; + Integer fish; + Integer players; + LinkedList craftItems; LinkedList deliveryNPCIds; LinkedList deliveryMessages; LinkedList npcTalkIds; @@ -1049,11 +1050,12 @@ public class QuestFactory implements ConversationAbandonedListener { cutIds = null; cutAmounts = null; cutDurability = null; - fish = null; - players = null; + craftItems = null; enchantments = null; enchantmentIds = null; enchantmentAmounts = null; + fish = null; + players = null; deliveryItems = null; deliveryNPCIds = null; deliveryMessages = null; @@ -1116,17 +1118,20 @@ public class QuestFactory implements ConversationAbandonedListener { cutAmounts = (LinkedList) cc.getSessionData(pref + CK.S_CUT_AMOUNTS); cutDurability = (LinkedList) cc.getSessionData(pref + CK.S_CUT_DURABILITY); } - if (cc.getSessionData(pref + CK.S_FISH) != null) { - fish = (Integer) cc.getSessionData(pref + CK.S_FISH); - } - if (cc.getSessionData(pref + CK.S_PLAYER_KILL) != null) { - players = (Integer) cc.getSessionData(pref + CK.S_PLAYER_KILL); + if (cc.getSessionData(pref + CK.S_CRAFT_ITEMS) != null) { + craftItems = (LinkedList) cc.getSessionData(pref + CK.S_CRAFT_ITEMS); } if (cc.getSessionData(pref + CK.S_ENCHANT_TYPES) != null) { enchantments = (LinkedList) cc.getSessionData(pref + CK.S_ENCHANT_TYPES); enchantmentIds = (LinkedList) cc.getSessionData(pref + CK.S_ENCHANT_NAMES); enchantmentAmounts = (LinkedList) cc.getSessionData(pref + CK.S_ENCHANT_AMOUNTS); } + if (cc.getSessionData(pref + CK.S_FISH) != null) { + fish = (Integer) cc.getSessionData(pref + CK.S_FISH); + } + if (cc.getSessionData(pref + CK.S_PLAYER_KILL) != null) { + players = (Integer) cc.getSessionData(pref + CK.S_PLAYER_KILL); + } if (cc.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null) { deliveryItems = (LinkedList) cc.getSessionData(pref + CK.S_DELIVERY_ITEMS); deliveryNPCIds = (LinkedList) cc.getSessionData(pref + CK.S_DELIVERY_NPCS); @@ -1231,11 +1236,20 @@ public class QuestFactory implements ConversationAbandonedListener { stage.set("cut-block-amounts", cutAmounts); stage.set("cut-block-durability", cutDurability); } - stage.set("fish-to-catch", fish); - stage.set("players-to-kill", players); + if (craftItems != null && craftItems.isEmpty() == false) { + LinkedList items = new LinkedList(); + for (ItemStack is : craftItems) { + items.add(ItemUtil.serializeItemStack(is)); + } + stage.set("items-to-craft", items); + } else { + stage.set("items-to-craft", null); + } stage.set("enchantments", enchantments); stage.set("enchantment-item-names", enchantmentIds); stage.set("enchantment-amounts", enchantmentAmounts); + stage.set("fish-to-catch", fish); + stage.set("players-to-kill", players); if (deliveryItems != null && deliveryItems.isEmpty() == false) { LinkedList items = new LinkedList(); for (ItemStack is : deliveryItems) { @@ -1536,11 +1550,12 @@ public class QuestFactory implements ConversationAbandonedListener { cc.setSessionData(pref + CK.S_CUT_AMOUNTS, amnts); cc.setSessionData(pref + CK.S_CUT_DURABILITY, durab); } - if (stage.fishToCatch != null) { - cc.setSessionData(pref + CK.S_FISH, stage.fishToCatch); - } - if (stage.playersToKill != null) { - cc.setSessionData(pref + CK.S_PLAYER_KILL, stage.playersToKill); + if (stage.getItemsToCraft().isEmpty() == false) { + LinkedList items = new LinkedList(); + for (ItemStack is : stage.getItemsToCraft()) { + items.add(is); + } + cc.setSessionData(pref + CK.S_CRAFT_ITEMS, items); } if (stage.itemsToEnchant.isEmpty() == false) { LinkedList enchants = new LinkedList(); @@ -1557,6 +1572,12 @@ public class QuestFactory implements ConversationAbandonedListener { cc.setSessionData(pref + CK.S_ENCHANT_NAMES, names); cc.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, amounts); } + if (stage.fishToCatch != null) { + cc.setSessionData(pref + CK.S_FISH, stage.fishToCatch); + } + if (stage.playersToKill != null) { + cc.setSessionData(pref + CK.S_PLAYER_KILL, stage.playersToKill); + } if (stage.getItemsToDeliver().isEmpty() == false) { LinkedList items = new LinkedList(); LinkedList npcs = new LinkedList(); diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java index cf8ff93da..394dd83d8 100644 --- a/src/main/java/me/blackvein/quests/Quester.java +++ b/src/main/java/me/blackvein/quests/Quester.java @@ -608,13 +608,18 @@ public class Quester { } } } - if (getCurrentStage(quest).fishToCatch != null) { - if (getQuestData(quest).getFishCaught() < getCurrentStage(quest).fishToCatch) { - unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "catchFish") + ChatColor.GREEN + ": " - + getQuestData(quest).getFishCaught() + "/" + getCurrentStage(quest).fishToCatch); + for (ItemStack is : getCurrentStage(quest).itemsToCraft) { + int crafted = 0; + if (getQuestData(quest).itemsCrafted.containsKey(is)) { + crafted = getQuestData(quest).itemsCrafted.get(is); + } + int amt = is.getAmount(); + if (crafted < amt) { + String obj = Lang.get(getPlayer(), "craft") + " " + ItemUtil.getName(is); + unfinishedObjectives.add(ChatColor.GREEN + obj + ": " + crafted + "/" + amt); } else { - finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "catchFish") + ChatColor.GRAY + ": " - + getQuestData(quest).getFishCaught() + "/" + getCurrentStage(quest).fishToCatch); + String obj = Lang.get(getPlayer(), "craft") + " " + ItemUtil.getName(is); + finishedObjectives.add(ChatColor.GRAY + obj + ": " + crafted + "/" + amt); } } Map set; @@ -660,6 +665,15 @@ public class Quester { } } } + if (getCurrentStage(quest).fishToCatch != null) { + if (getQuestData(quest).getFishCaught() < getCurrentStage(quest).fishToCatch) { + unfinishedObjectives.add(ChatColor.GREEN + Lang.get(getPlayer(), "catchFish") + ChatColor.GREEN + ": " + + getQuestData(quest).getFishCaught() + "/" + getCurrentStage(quest).fishToCatch); + } else { + finishedObjectives.add(ChatColor.GRAY + Lang.get(getPlayer(), "catchFish") + ChatColor.GRAY + ": " + + getQuestData(quest).getFishCaught() + "/" + getCurrentStage(quest).fishToCatch); + } + } for (EntityType e : getCurrentStage(quest).mobsToKill) { for (EntityType e2 : getQuestData(quest).mobsKilled) { if (e == e2) { @@ -905,10 +919,12 @@ public class Quester { return !getCurrentStage(quest).blocksToUse.isEmpty(); } else if (s.equalsIgnoreCase("cutBlock")) { return !getCurrentStage(quest).blocksToCut.isEmpty(); - } else if (s.equalsIgnoreCase("catchFish")) { - return getCurrentStage(quest).fishToCatch != null; + } else if (s.equalsIgnoreCase("craftItem")) { + return !getCurrentStage(quest).itemsToCraft.isEmpty(); } else if (s.equalsIgnoreCase("enchantItem")) { return !getCurrentStage(quest).itemsToEnchant.isEmpty(); + } else if (s.equalsIgnoreCase("catchFish")) { + return getCurrentStage(quest).fishToCatch != null; } else if (s.equalsIgnoreCase("killMob")) { return !getCurrentStage(quest).mobsToKill.isEmpty(); } else if (s.equalsIgnoreCase("deliverItem")) { @@ -1202,6 +1218,37 @@ public class Quester { } } } + + public void craftItem(Quest quest, ItemStack i) { + Player player = getPlayer(); + ItemStack found = null; + for (ItemStack is : getQuestData(quest).itemsCrafted.keySet()) { + if (ItemUtil.compareItems(i, is, true) == 0) { + found = is; + break; + } + } + if (found != null) { + int amount = getQuestData(quest).itemsCrafted.get(found); + if (getCurrentStage(quest).itemsToCraft.indexOf(found) < 0) { + plugin.getLogger().severe("Index out of bounds while crafting " + found.getType() + " x " + found.getAmount() + " for quest " + + quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already crafted. Int -amount- reports value of " + + + amount + ". Please report this error on Github!"); + player.sendMessage("Quests had a problem crafting your item, please contact an administrator!"); + return; + } + int req = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(found)).getAmount(); + Material m = i.getType(); + if (amount < req) { + if ((i.getAmount() + amount) >= req) { + getQuestData(quest).itemsCrafted.put(found, req); + finishObjective(quest, "craftItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); + } else { + getQuestData(quest).itemsCrafted.put(found, (amount + i.getAmount())); + } + } + } + } public void enchantItem(Quest quest, Enchantment e, Material m) { for (Entry, Integer> entry : getQuestData(quest).itemsEnchanted.entrySet()) { @@ -1279,6 +1326,54 @@ public class Quester { } } } + + + @SuppressWarnings("deprecation") + public void deliverItem(Quest quest, ItemStack i) { + Player player = getPlayer(); + ItemStack found = null; + for (ItemStack is : getQuestData(quest).itemsDelivered.keySet()) { + if (ItemUtil.compareItems(i, is, true) == 0) { + found = is; + break; + } + } + if (found != null) { + int amount = getQuestData(quest).itemsDelivered.get(found); + if (getCurrentStage(quest).itemsToDeliver.indexOf(found) < 0) { + plugin.getLogger().severe("Index out of bounds while delivering " + found.getType() + " x " + found.getAmount() + " for quest " + + quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already delivered. Int -amount- reports value of " + + + amount + ". Please report this error on Github!"); + player.sendMessage("Quests had a problem delivering your item, please contact an administrator!"); + return; + } + int req = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)).getAmount(); + Material m = i.getType(); + if (amount < req) { + if ((i.getAmount() + amount) > req) { + getQuestData(quest).itemsDelivered.put(found, req); + int index = player.getInventory().first(i); + i.setAmount(i.getAmount() - (req - amount)); // Take away the remaining amount needed to be delivered + player.getInventory().setItem(index, i); + player.updateInventory(); + finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); + } else if ((i.getAmount() + amount) == req) { + getQuestData(quest).itemsDelivered.put(found, req); + player.getInventory().setItem(player.getInventory().first(i), null); + player.updateInventory(); + finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); + } else { + getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount())); + player.getInventory().setItem(player.getInventory().first(i), null); + player.updateInventory(); + String message = Quests.parseString(getCurrentStage(quest).deliverMessages.get(new Random().nextInt( + getCurrentStage(quest).deliverMessages.size())), plugin.getDependencies().getCitizens().getNPCRegistry().getById( + getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)))); + player.sendMessage(message); + } + } + } + } public void interactWithNPC(Quest quest, NPC n) { if (getQuestData(quest).citizensInteracted.containsKey(n.getId())) { @@ -1353,53 +1448,6 @@ public class Quester { } } - @SuppressWarnings("deprecation") - public void deliverItem(Quest quest, ItemStack i) { - Player player = getPlayer(); - ItemStack found = null; - for (ItemStack is : getQuestData(quest).itemsDelivered.keySet()) { - if (ItemUtil.compareItems(i, is, true) == 0) { - found = is; - break; - } - } - if (found != null) { - int amount = getQuestData(quest).itemsDelivered.get(found); - if (getCurrentStage(quest).itemsToDeliver.indexOf(found) < 0) { - plugin.getLogger().severe("Index out of bounds while delivering " + found.getType() + " x " + found.getAmount() + " for quest " - + quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already delivered. Int -amount- reports value of " + - + amount + ". Please report this error on Github!"); - player.sendMessage("Quests had a problem delivering your item, please contact an administrator!"); - return; - } - int req = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)).getAmount(); - Material m = i.getType(); - if (amount < req) { - if ((i.getAmount() + amount) > req) { - getQuestData(quest).itemsDelivered.put(found, req); - int index = player.getInventory().first(i); - i.setAmount(i.getAmount() - (req - amount)); // Take away the remaining amount needed to be delivered from the item stack - player.getInventory().setItem(index, i); - player.updateInventory(); - finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); - } else if ((i.getAmount() + amount) == req) { - getQuestData(quest).itemsDelivered.put(found, req); - player.getInventory().setItem(player.getInventory().first(i), null); - player.updateInventory(); - finishObjective(quest, "deliverItem", new ItemStack(m, 1), found, null, null, null, null, null, null, null, null); - } else { - getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount())); - player.getInventory().setItem(player.getInventory().first(i), null); - player.updateInventory(); - String message = Quests.parseString(getCurrentStage(quest).deliverMessages.get(new Random().nextInt( - getCurrentStage(quest).deliverMessages.size())), plugin.getDependencies().getCitizens().getNPCRegistry().getById( - getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)))); - player.sendMessage(message); - } - } - } - } - public void sayPassword(Quest quest, AsyncPlayerChatEvent evt) { boolean done; for (LinkedList passes : getCurrentStage(quest).passwordPhrases) { @@ -1449,7 +1497,7 @@ public class Quester { * See CustomObjective class */ @SuppressWarnings("deprecation") - public void finishObjective(Quest quest, String objective, ItemStack itemStack, ItemStack delivery, Enchantment enchantment, + public void finishObjective(Quest quest, String objective, ItemStack increment, ItemStack goal, Enchantment enchantment, EntityType mob, String player, NPC npc, Location location, DyeColor color, String pass, CustomObjective co) { Player p = getPlayer(); if (getCurrentStage(quest).objectiveOverride != null) { @@ -1471,7 +1519,7 @@ public class Quester { String stack = getQuestData(quest).blocksBroken.toString(); String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", ""); message = message + " " + amount + "/" + amount; - plugin.getLocaleQuery().sendMessage(p, message, itemStack.getType(), itemStack.getDurability()); + plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability()); if (testComplete(quest)) { quest.nextStage(this); } @@ -1480,7 +1528,7 @@ public class Quester { String stack = getQuestData(quest).blocksDamaged.toString(); String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", ""); message = message + " " + amount + "/" + amount; - plugin.getLocaleQuery().sendMessage(p, message, itemStack.getType(), itemStack.getDurability()); + plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability()); if (testComplete(quest)) { quest.nextStage(this); } @@ -1489,7 +1537,7 @@ public class Quester { String stack = getQuestData(quest).blocksPlaced.toString(); String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", ""); message = message + " " + amount + "/" + amount; - plugin.getLocaleQuery().sendMessage(p, message, itemStack.getType(), itemStack.getDurability()); + plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability()); if (testComplete(quest)) { quest.nextStage(this); } @@ -1498,7 +1546,7 @@ public class Quester { String stack = getQuestData(quest).blocksUsed.toString(); String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", ""); message = message + " " + amount + "/" + amount; - plugin.getLocaleQuery().sendMessage(p, message, itemStack.getType(), itemStack.getDurability()); + plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability()); if (testComplete(quest)) { quest.nextStage(this); } @@ -1507,14 +1555,15 @@ public class Quester { String stack = getQuestData(quest).blocksCut.toString(); String amount = stack.substring(stack.lastIndexOf(" x ") + 3).replace("}]", ""); message = message + " " + amount + "/" + amount; - plugin.getLocaleQuery().sendMessage(p, message, itemStack.getType(), itemStack.getDurability()); + plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability()); if (testComplete(quest)) { quest.nextStage(this); } - } else if (objective.equalsIgnoreCase("catchFish")) { - String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "catchFish") + " "; - message = message + " " + getCurrentStage(quest).fishToCatch + "/" + getCurrentStage(quest).fishToCatch; - p.sendMessage(message); + } else if (objective.equalsIgnoreCase("craftItem")) { + ItemStack is = getCurrentStage(quest).itemsToCraft.get(getCurrentStage(quest).itemsToCraft.indexOf(goal)); + String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "craft") + " " + + is.getAmount() + "/" + is.getAmount(); + plugin.getLocaleQuery().sendMessage(p, message, goal.getType(), goal.getDurability()); if (testComplete(quest)) { quest.nextStage(this); } @@ -1527,19 +1576,26 @@ public class Quester { break; } } - plugin.getLocaleQuery().sendMessage(p, message, itemStack.getType(), itemStack.getDurability(), enchantment); + plugin.getLocaleQuery().sendMessage(p, message, increment.getType(), increment.getDurability(), enchantment); if (testComplete(quest)) { quest.nextStage(this); } } else if (objective.equalsIgnoreCase("deliverItem")) { String obj = Lang.get(p, "deliver"); - obj = obj.replace("", plugin.getNPCName(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(delivery)))); + obj = obj.replace("", plugin.getNPCName(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(goal)))); String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj; - ItemStack is = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(delivery)); + ItemStack is = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(goal)); plugin.getLocaleQuery().sendMessage(p, message, is.getType(), is.getDurability()); if (testComplete(quest)) { quest.nextStage(this); } + } else if (objective.equalsIgnoreCase("catchFish")) { + String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "catchFish") + " "; + message = message + " " + getCurrentStage(quest).fishToCatch + "/" + getCurrentStage(quest).fishToCatch; + p.sendMessage(message); + if (testComplete(quest)) { + quest.nextStage(this); + } } else if (objective.equalsIgnoreCase("killMob")) { String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + Lang.get(p, "kill") + " "; message = message + " " + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob)) + "/" + getCurrentStage(quest).mobNumToKill.get(getCurrentStage(quest).mobsToKill.indexOf(mob)); @@ -1689,7 +1745,11 @@ public class Quester { } } } - data.setFishCaught(0); + if (quest.getStage(stage).itemsToCraft.isEmpty() == false) { + for (ItemStack is : quest.getStage(stage).itemsToCraft) { + data.itemsCrafted.put(is, 0); + } + } if (quest.getStage(stage).itemsToEnchant.isEmpty() == false) { for (Entry, Integer> e : quest.getStage(stage).itemsToEnchant.entrySet()) { Map map = (Map) e.getKey(); @@ -1708,6 +1768,7 @@ public class Quester { } } } + data.setFishCaught(0); data.setPlayersKilled(0); if (quest.getStage(stage).itemsToDeliver.isEmpty() == false) { for (ItemStack is : quest.getStage(stage).itemsToDeliver) { @@ -1986,11 +2047,12 @@ public class Quester { questSec.set("blocks-cut-amounts", blockAmounts); questSec.set("blocks-cut-durability", blockDurability); } - if (getCurrentStage(quest).fishToCatch != null) { - questSec.set("fish-caught", questData.getFishCaught()); - } - if (getCurrentStage(quest).playersToKill != null) { - questSec.set("players-killed", questData.getPlayersKilled()); + if (questData.itemsCrafted.isEmpty() == false) { + LinkedList craftAmounts = new LinkedList(); + for (Entry e : questData.itemsCrafted.entrySet()) { + craftAmounts.add(e.getValue()); + } + questSec.set("item-craft-amounts", craftAmounts); } if (questData.itemsEnchanted.isEmpty() == false) { LinkedList enchantments = new LinkedList(); @@ -2008,6 +2070,12 @@ public class Quester { questSec.set("enchantment-item-names", itemNames); questSec.set("times-enchanted", enchAmounts); } + if (getCurrentStage(quest).fishToCatch != null) { + questSec.set("fish-caught", questData.getFishCaught()); + } + if (getCurrentStage(quest).playersToKill != null) { + questSec.set("players-killed", questData.getPlayersKilled()); + } if (questData.mobsKilled.isEmpty() == false) { LinkedList mobNames = new LinkedList(); LinkedList mobAmounts = new LinkedList(); @@ -2359,8 +2427,13 @@ public class Quester { getQuestData(quest).blocksCut.set(names.indexOf(s), is); } } - if (questSec.contains("fish-caught")) { - getQuestData(quest).setFishCaught(questSec.getInt("fish-caught")); + if (questSec.contains("item-craft-amounts")) { + List craftAmounts = questSec.getIntegerList("item-craft-amounts"); + for (int i = 0; i < craftAmounts.size(); i++) { + if (i < getCurrentStage(quest).itemsToCraft.size()) { + getQuestData(quest).itemsCrafted.put(getCurrentStage(quest).itemsToCraft.get(i), craftAmounts.get(i)); + } + } } if (questSec.contains("enchantments")) { LinkedList enchantments = new LinkedList(); @@ -2380,6 +2453,9 @@ public class Quester { getQuestData(quest).itemsEnchanted.put(map, amounts.get(enchantments.indexOf(e))); } } + if (questSec.contains("fish-caught")) { + getQuestData(quest).setFishCaught(questSec.getInt("fish-caught")); + } if (questSec.contains("mobs-killed")) { LinkedList mobs = new LinkedList(); List amounts = questSec.getIntegerList("mobs-killed-amounts"); diff --git a/src/main/java/me/blackvein/quests/Quests.java b/src/main/java/me/blackvein/quests/Quests.java index c1ce91622..fd6495cae 100644 --- a/src/main/java/me/blackvein/quests/Quests.java +++ b/src/main/java/me/blackvein/quests/Quests.java @@ -627,7 +627,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener // TODO ensure all applicable strings are translated String sbegin = obj.substring(obj.indexOf(ChatColor.AQUA.toString()) + 2); String serial = sbegin.substring(0, sbegin.indexOf(ChatColor.GREEN.toString())); - + System.out.println("0"); Stage stage = quester.getCurrentStage(quest); if (obj.contains(Lang.get(quester.getPlayer(), "break"))) { for (ItemStack is : stage.blocksToBreak) { @@ -674,6 +674,19 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } } } + } else if (obj.contains(Lang.get(quester.getPlayer(), "craft"))) { + System.out.println("1"); + for (ItemStack is : stage.getItemsToCraft()) { + System.out.println("2"); + if (Material.matchMaterial(serial) != null) { + System.out.println("3"); + if (Material.matchMaterial(serial).equals(is.getType())) { + System.out.println("4"); + localeQuery.sendMessage(quester.getPlayer(), obj.replace(serial, ""), is.getType(), is.getDurability()); + break; + } + } + } } //TODO find a better way to detect a deliver objective else if (obj.contains(Lang.get(quester.getPlayer(), "deliver").split(" ")[0])) { @@ -1318,14 +1331,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey + ".stages.ordered"); for (String s2 : questStages.getKeys(false)) { Stage oStage = new Stage(); - LinkedList mobsToKill = new LinkedList(); - LinkedList mobNumToKill = new LinkedList(); - LinkedList locationsToKillWithin = new LinkedList(); - LinkedList radiiToKillWithin = new LinkedList(); - LinkedList areaNames = new LinkedList(); - LinkedList enchantments = new LinkedList(); - LinkedList itemsToEnchant = new LinkedList(); - List amountsToEnchant = new LinkedList(); List breaknames = new LinkedList(); List breakamounts = new LinkedList(); List breakdurability = new LinkedList(); @@ -1341,6 +1346,21 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener List cutnames = new LinkedList(); List cutamounts = new LinkedList(); List cutdurability = new LinkedList(); + List mobsToKill = new LinkedList(); + List mobNumToKill = new LinkedList(); + List locationsToKillWithin = new LinkedList(); + List radiiToKillWithin = new LinkedList(); + List areaNames = new LinkedList(); + List itemsToCraft = new LinkedList(); + List enchantments = new LinkedList(); + List itemsToEnchant = new LinkedList(); + List amountsToEnchant = new LinkedList(); + List npcIdsToTalkTo = new LinkedList(); + List itemsToDeliver= new LinkedList(); + List itemDeliveryTargetIds = new LinkedList(); + List deliveryMessages = new LinkedList(); + List npcIdsToKill = new LinkedList(); + List npcAmountsToKill = new LinkedList(); // Denizen script load if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".script-to-run")) { if (ScriptRegistry.containsScript(config.getString("quests." + questKey + ".stages.ordered." + s2 + ".script-to-run"))) { @@ -1545,18 +1565,19 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener stageFailed("" + s + " inside cut-block-names: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a valid item name!"); } } - if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".fish-to-catch")) { - if (config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".fish-to-catch", -999) != -999) { - oStage.fishToCatch = config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".fish-to-catch"); + if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".items-to-craft")) { + if (checkList(config.getList("quests." + questKey + ".stages.ordered." + s2 + ".items-to-craft"), String.class)) { + itemsToCraft = config.getStringList("quests." + questKey + ".stages.ordered." + s2 + ".items-to-craft"); + for (String item : itemsToCraft) { + ItemStack is = ItemUtil.readItemStack("" + item); + if (is != null) { + oStage.getItemsToCraft().add(is); + } else { + stageFailed("" + item + " inside items-to-craft: inside Stage " + s2 + " of Quest " + quest.getName() + " is not formatted properly!"); + } + } } else { - stageFailed("fish-to-catch: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a number!"); - } - } - if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".players-to-kill")) { - if (config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".players-to-kill", -999) != -999) { - oStage.playersToKill = config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".players-to-kill"); - } else { - stageFailed("players-to-kill: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a number!"); + stageFailed("items-to-craft: in Stage " + s2 + " of Quest " + quest.getName() + " is not formatted properly!"); } } if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".enchantments")) { @@ -1597,7 +1618,20 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener stageFailed("Stage " + s2 + " of Quest " + quest.getName() + " is missing enchantment-amounts:"); } } - List npcIdsToTalkTo = null; + if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".fish-to-catch")) { + if (config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".fish-to-catch", -999) != -999) { + oStage.fishToCatch = config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".fish-to-catch"); + } else { + stageFailed("fish-to-catch: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a number!"); + } + } + if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".players-to-kill")) { + if (config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".players-to-kill", -999) != -999) { + oStage.playersToKill = config.getInt("quests." + questKey + ".stages.ordered." + s2 + ".players-to-kill"); + } else { + stageFailed("players-to-kill: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a number!"); + } + } if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-talk-to")) { if (checkList(config.getList("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-talk-to"), Integer.class)) { npcIdsToTalkTo = config.getIntegerList("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-talk-to"); @@ -1612,9 +1646,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener stageFailed("npc-ids-to-talk-to: in Stage " + s2 + " of Quest " + quest.getName() + " is not a list of numbers!"); } } - List itemsToDeliver; - List itemDeliveryTargetIds; - LinkedList deliveryMessages = new LinkedList(); if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".items-to-deliver")) { if (checkList(config.getList("quests." + questKey + ".stages.ordered." + s2 + ".items-to-deliver"), String.class)) { if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".npc-delivery-ids")) { @@ -1633,7 +1664,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (npc != null) { oStage.getItemsToDeliver().add(is); oStage.getItemDeliveryTargets().add(npcId); - oStage.deliverMessages = deliveryMessages; + oStage.deliverMessages.addAll(deliveryMessages); } else { stageFailed("" + npcId + " inside npc-delivery-ids: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a valid NPC id!"); } @@ -1654,22 +1685,20 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener stageFailed("items-to-deliver: in Stage " + s2 + " of Quest " + quest.getName() + " is not formatted properly!"); } } - List npcIds; - List npcAmounts; if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-kill")) { if (checkList(config.getList("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-kill"), Integer.class)) { if (config.contains("quests." + questKey + ".stages.ordered." + s2 + ".npc-kill-amounts")) { if (checkList(config.getList("quests." + questKey + ".stages.ordered." + s2 + ".npc-kill-amounts"), Integer.class)) { - npcIds = config.getIntegerList("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-kill"); - npcAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + s2 + ".npc-kill-amounts"); - for (int i : npcIds) { + npcIdsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." + s2 + ".npc-ids-to-kill"); + npcAmountsToKill = config.getIntegerList("quests." + questKey + ".stages.ordered." + s2 + ".npc-kill-amounts"); + for (int i : npcIdsToKill) { if (CitizensAPI.getNPCRegistry().getById(i) != null) { - if (npcAmounts.get(npcIds.indexOf(i)) > 0) { + if (npcAmountsToKill.get(npcIdsToKill.indexOf(i)) > 0) { oStage.citizensToKill.add(i); - oStage.citizenNumToKill.add(npcAmounts.get(npcIds.indexOf(i))); + oStage.citizenNumToKill.add(npcAmountsToKill.get(npcIdsToKill.indexOf(i))); questNpcs.add(CitizensAPI.getNPCRegistry().getById(i)); } else { - stageFailed("" + npcAmounts.get(npcIds.indexOf(i)) + " inside npc-kill-amounts: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a positive number!"); + stageFailed("" + npcAmountsToKill.get(npcIdsToKill.indexOf(i)) + " inside npc-kill-amounts: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a positive number!"); } } else { stageFailed("" + i + " inside npc-ids-to-kill: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a valid NPC id!"); @@ -1750,11 +1779,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener stageFailed("Stage " + s2 + " of Quest " + quest.getName() + " is missing kill-location-names:"); } } - oStage.mobsToKill = mobsToKill; - oStage.mobNumToKill = mobNumToKill; - oStage.locationsToKillWithin = locationsToKillWithin; - oStage.radiiToKillWithin = radiiToKillWithin; - oStage.killNames = areaNames; + oStage.mobsToKill.addAll(mobsToKill); + oStage.mobNumToKill.addAll(mobNumToKill); + oStage.locationsToKillWithin.addAll(locationsToKillWithin); + oStage.radiiToKillWithin.addAll(radiiToKillWithin); + oStage.killNames.addAll(areaNames); Map, Integer> enchants = new HashMap, Integer>(); for (Enchantment e : enchantments) { Map map = new HashMap(); diff --git a/src/main/java/me/blackvein/quests/Stage.java b/src/main/java/me/blackvein/quests/Stage.java index 44bdc890d..0819e4ae7 100644 --- a/src/main/java/me/blackvein/quests/Stage.java +++ b/src/main/java/me/blackvein/quests/Stage.java @@ -35,6 +35,7 @@ public class Stage { protected LinkedList blocksToCut = new LinkedList(); protected Integer fishToCatch; protected Integer playersToKill; + protected LinkedList itemsToCraft = new LinkedList(); protected Map, Integer> itemsToEnchant = new HashMap, Integer>(); protected LinkedList itemsToDeliver = new LinkedList(); protected LinkedList itemDeliveryTargets = new LinkedList() { @@ -181,6 +182,14 @@ public class Stage { public void setPlayersToKill(Integer playersToKill) { this.playersToKill = playersToKill; } + + public LinkedList getItemsToCraft() { + return itemsToCraft; + } + + public void setItemsToCraft(LinkedList itemsToCraft) { + this.itemsToCraft = itemsToCraft; + } public Map, Integer> getItemsToEnchant() { return itemsToEnchant; @@ -484,6 +493,7 @@ public class Stage { if (blocksToCut.isEmpty() == false) { return true; } if (fishToCatch != null) { return true; } if (playersToKill != null) { return true; } + if (itemsToCraft.isEmpty() == false) { return true; } if (itemsToEnchant.isEmpty() == false) { return true; } if (itemsToDeliver.isEmpty() == false) { return true; } if (citizensToInteract.isEmpty() == false) { return true; } diff --git a/src/main/java/me/blackvein/quests/listeners/PlayerListener.java b/src/main/java/me/blackvein/quests/listeners/PlayerListener.java index 30e648189..8642d9a30 100644 --- a/src/main/java/me/blackvein/quests/listeners/PlayerListener.java +++ b/src/main/java/me/blackvein/quests/listeners/PlayerListener.java @@ -44,6 +44,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityTameEvent; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; @@ -480,6 +481,21 @@ public class PlayerListener implements Listener { } } + + @EventHandler + public void onCraftItem(CraftItemEvent evt) { + if (evt.getWhoClicked() instanceof Player) { + if (plugin.checkQuester(evt.getWhoClicked().getUniqueId()) == false) { + Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId()); + for (Quest quest : quester.getCurrentQuests().keySet()) { + if (quester.containsObjective(quest, "craftItem")) { + quester.craftItem(quest, evt.getCurrentItem()); + } + } + } + } + } + @EventHandler public void onEnchantItem(EnchantItemEvent evt) { if (plugin.checkQuester(evt.getEnchanter().getUniqueId()) == false) { diff --git a/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java b/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java index feff3a35e..caa0564e1 100644 --- a/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java @@ -66,13 +66,13 @@ public class CreateStagePrompt extends FixedSetPrompt { hasObjective = true; text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorBlocks") + "\n"; } - if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null && context.getSessionData(pref + CK.S_DELIVERY_NPCS) == null) { + if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null && context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) { text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; } else { hasObjective = true; text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorItems") + "\n"; } - if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null && context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { + if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) == null && context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null && context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; } else { hasObjective = true; diff --git a/src/main/java/me/blackvein/quests/prompts/ItemsPrompt.java b/src/main/java/me/blackvein/quests/prompts/ItemsPrompt.java index d1847fa17..b549cac02 100644 --- a/src/main/java/me/blackvein/quests/prompts/ItemsPrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/ItemsPrompt.java @@ -19,6 +19,7 @@ import me.blackvein.quests.QuestFactory; import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; import me.blackvein.quests.util.CK; +import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.Lang; import org.bukkit.ChatColor; @@ -28,6 +29,7 @@ import org.bukkit.conversations.FixedSetPrompt; import org.bukkit.conversations.Prompt; import org.bukkit.conversations.StringPrompt; import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; public class ItemsPrompt extends FixedSetPrompt { private final Quests plugin; @@ -36,7 +38,7 @@ public class ItemsPrompt extends FixedSetPrompt { private final QuestFactory questFactory; public ItemsPrompt(Quests plugin, int stageNum, QuestFactory qf) { - super("1", "2"); + super("1", "2", "3"); this.plugin = plugin; this.stageNum = stageNum; this.pref = "stage" + stageNum; @@ -46,12 +48,35 @@ public class ItemsPrompt extends FixedSetPrompt { @SuppressWarnings("unchecked") @Override public String getPromptText(ConversationContext context) { + // Check/add newly made item + if (context.getSessionData("newItem") != null) { + if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) != null) { + List itemRews = getItems(context); + itemRews.add((ItemStack) context.getSessionData("tempStack")); + context.setSessionData(pref + CK.S_CRAFT_ITEMS, itemRews); + } else { + LinkedList itemRews = new LinkedList(); + itemRews.add((ItemStack) context.getSessionData("tempStack")); + context.setSessionData(pref + CK.S_CRAFT_ITEMS, itemRews); + } + context.setSessionData("newItem", null); + context.setSessionData("tempStack", null); + } context.setSessionData(pref, Boolean.TRUE); String text = ChatColor.AQUA + "- " + Lang.get("stageEditorItems") + " -\n"; - if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorEnchantItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null) { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorCraftItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorEnchantItems") + "\n"; + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorCraftItems") + "\n"; + LinkedList items = (LinkedList) context.getSessionData(pref + CK.S_CRAFT_ITEMS); + for (int i = 0; i < items.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n"; + } + } + if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorEnchantItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorEnchantItems") + "\n"; LinkedList enchants = (LinkedList) context.getSessionData(pref + CK.S_ENCHANT_TYPES); LinkedList names = (LinkedList) context.getSessionData(pref + CK.S_ENCHANT_NAMES); LinkedList amnts = (LinkedList) context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS); @@ -59,14 +84,15 @@ public class ItemsPrompt extends FixedSetPrompt { text += ChatColor.GRAY + " - " + ChatColor.BLUE + Quester.prettyItemString(names.get(i)) + ChatColor.GRAY + " " + Lang.get("with") + " " + ChatColor.AQUA + Quester.prettyEnchantmentString(Quests.getEnchantment(enchants.get(i))) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n"; } } - - text += ChatColor.GREEN + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("done") + "\n"; + text += ChatColor.GREEN + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("done") + "\n"; return text; } @Override protected Prompt acceptValidatedInput(ConversationContext context, String input) { if (input.equalsIgnoreCase("1")) { + return new ItemStackPrompt(this); + } else if (input.equalsIgnoreCase("2")) { return new EnchantmentListPrompt(); } try { @@ -76,6 +102,11 @@ public class ItemsPrompt extends FixedSetPrompt { return Prompt.END_OF_CONVERSATION; } } + + @SuppressWarnings("unchecked") + private List getItems(ConversationContext context) { + return (List) context.getSessionData(pref + CK.S_CRAFT_ITEMS); + } private class EnchantmentListPrompt extends FixedSetPrompt { diff --git a/src/main/java/me/blackvein/quests/prompts/NPCsPrompt.java b/src/main/java/me/blackvein/quests/prompts/NPCsPrompt.java index fe643f584..f1d42b943 100644 --- a/src/main/java/me/blackvein/quests/prompts/NPCsPrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/NPCsPrompt.java @@ -215,7 +215,7 @@ public class NPCsPrompt extends FixedSetPrompt { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDeliveryMessage")); return new DeliveryListPrompt(); } else { - return new ItemsPrompt(plugin, stageNum, questFactory); + return new NPCsPrompt(plugin, stageNum, questFactory); } } else { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorDeliveriesNotSameSize")); diff --git a/src/main/java/me/blackvein/quests/util/CK.java b/src/main/java/me/blackvein/quests/util/CK.java index 2a7610bac..c22b55c3c 100644 --- a/src/main/java/me/blackvein/quests/util/CK.java +++ b/src/main/java/me/blackvein/quests/util/CK.java @@ -62,6 +62,7 @@ public class CK { public static final String S_CUT_DURABILITY = "cutDurability"; public static final String S_FISH = "fish"; public static final String S_PLAYER_KILL = "playerKill"; + public static final String S_CRAFT_ITEMS = "craftItems"; public static final String S_ENCHANT_TYPES = "enchantTypes"; public static final String S_ENCHANT_NAMES = "enchantNames"; public static final String S_ENCHANT_AMOUNTS = "enchantAmounts"; diff --git a/src/main/resources/strings.yml b/src/main/resources/strings.yml index 3e106633b..5c46c1fb5 100644 --- a/src/main/resources/strings.yml +++ b/src/main/resources/strings.yml @@ -116,9 +116,10 @@ stageEditorPlaceBlocks: "Place blocks" stageEditorUseBlocks: "Use blocks" stageEditorCutBlocks: "Cut blocks" stageEditorItems: "Items" +stageEditorCraftItems: "Craft items" stageEditorEnchantItems: "Enchant items" -stageEditorDeliverItems: "Deliver items" stageEditorNPCs: "NPCs" +stageEditorDeliverItems: "Deliver items" stageEditorTalkToNPCs: "Talk to NPCs" stageEditorKillNPCs: "Kill NPCs" stageEditorMobs: "Mobs" @@ -654,8 +655,9 @@ damage: "Damage" place: "Place" use: "Use" cut: "Cut" -catchFish: "Catch Fish" +craft: "Craft" enchantItem: "Enchant with " +catchFish: "Catch Fish" kill: "Kill" killAtLocation: "Kill at " killPlayer: "Kill a Player"