From 0fec3b35fe0c8e73348d8e9667b5bf5aba51fc1a Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Sat, 14 Mar 2020 19:59:30 -0400 Subject: [PATCH] Revise override capabilities. Add permission world prompt, fixes #1113 --- .../main/java/me/blackvein/quests/Quest.java | 372 +++++++------ .../me/blackvein/quests/QuestFactory.java | 40 +- .../java/me/blackvein/quests/Quester.java | 46 +- .../main/java/me/blackvein/quests/Quests.java | 522 ++++++++---------- .../me/blackvein/quests/Requirements.java | 10 +- .../java/me/blackvein/quests/Rewards.java | 7 + .../main/java/me/blackvein/quests/Stage.java | 10 +- .../me/blackvein/quests/actions/Action.java | 3 +- .../quests/QuestsEditorStringPrompt.java | 1 + .../convo/quests/prompts/ItemStackPrompt.java | 18 +- .../convo/quests/prompts/OptionsPrompt.java | 19 + .../convo/quests/prompts/OverridePrompt.java | 85 +++ .../quests/prompts/QuestOfferPrompt.java | 4 +- .../quests/prompts/RequirementsPrompt.java | 77 +-- .../convo/quests/prompts/RewardsPrompt.java | 381 +++++++++---- .../convo/quests/prompts/StageMainPrompt.java | 485 ++++++++-------- .../blackvein/quests/tasks/ActionTimer.java | 5 +- .../java/me/blackvein/quests/util/CK.java | 2 + main/src/main/resources/strings.yml | 38 +- 19 files changed, 1171 insertions(+), 954 deletions(-) create mode 100644 main/src/main/java/me/blackvein/quests/convo/quests/prompts/OverridePrompt.java diff --git a/main/src/main/java/me/blackvein/quests/Quest.java b/main/src/main/java/me/blackvein/quests/Quest.java index 1d9ee7a13..2953f8805 100644 --- a/main/src/main/java/me/blackvein/quests/Quest.java +++ b/main/src/main/java/me/blackvein/quests/Quest.java @@ -440,10 +440,8 @@ public class Quest { q.timers.remove(entry.getKey()); } } - String none = null; if (player.isOnline()) { Player p = (Player)player; - none = ChatColor.GRAY + "- (" + Lang.get(p, "none") + ")"; final String[] ps = ConfigUtil.parseStringWithPossibleLineBreaks(ChatColor.AQUA + finished, this, p); Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { @@ -453,10 +451,6 @@ public class Quest { } }, 40); } - if (rews.getMoney() > 0 && plugin.getDependencies().getVaultEconomy() != null) { - plugin.getDependencies().getVaultEconomy().depositPlayer(player, rews.getMoney()); - none = null; - } if (pln.getCooldown() > -1) { q.completedTimes.put(this.name, System.currentTimeMillis()); if (q.amountsCompleted.containsKey(this.name)) { @@ -465,6 +459,13 @@ public class Quest { q.amountsCompleted.put(this.name, 1); } } + + // Issue rewards + boolean issuedReward = false; + if (rews.getMoney() > 0 && plugin.getDependencies().getVaultEconomy() != null) { + plugin.getDependencies().getVaultEconomy().depositPlayer(player, rews.getMoney()); + issuedReward = true; + } if (player.isOnline()) { Player p = (Player)player; for (ItemStack i : rews.getItems()) { @@ -476,7 +477,7 @@ public class Quest { p.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. " + "Please contact an administrator."); } - none = null; + issuedReward = true; } } for (String s : rews.getCommands()) { @@ -496,25 +497,24 @@ public class Quest { } }); } - none = null; + issuedReward = true; } for (int i = 0; i < rews.getPermissions().size(); i++) { if (plugin.getDependencies().getVaultPermission() != null) { String perm = rews.getPermissions().get(i); - plugin.getDependencies().getVaultPermission().playerAdd(null, player, perm); - /*String world = rews.getPermissionWorlds().get(i); - if (world == null) { + String world = rews.getPermissionWorlds().get(i); + if (world == null || world.equals("null")) { plugin.getDependencies().getVaultPermission().playerAdd(null, player, perm); } else { plugin.getDependencies().getVaultPermission().playerAdd(world, player, perm); - }*/ + } } - none = null; + issuedReward = true; } for (String s : rews.getMcmmoSkills()) { UserManager.getOfflinePlayer(player).getProfile().addLevels(Quests.getMcMMOSkill(s), rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s))); - none = null; + issuedReward = true; } if (player.isOnline()) { for (String s : rews.getHeroesClasses()) { @@ -522,7 +522,7 @@ public class Quest { hero.addExp(rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)), plugin.getDependencies().getHeroes().getClassManager().getClass(s), ((Player)player).getLocation()); - none = null; + issuedReward = true; } } LinkedList phatLootItems = new LinkedList(); @@ -566,17 +566,25 @@ public class Quest { if (lb.getMessageList().isEmpty() == false) { phatLootMessages.addAll(lb.getMessageList()); } + issuedReward = true; } if (rews.getExp() > 0 && player.isOnline()) { ((Player)player).giveExp(rews.getExp()); - none = null; + issuedReward = true; } + if (rews.getQuestPoints() > 0) { + q.questPoints += rews.getQuestPoints(); + issuedReward = true; + } + if (rews.getCustomRewards().isEmpty() == false) { + issuedReward = true; + } + + // Inform player if (player.isOnline()) { Player p = (Player)player; - String complete = Lang.get(p, "questCompleteTitle"); - complete = complete.replace("", ChatColor.YELLOW + name + ChatColor.GOLD); - p.sendMessage(ChatColor.GOLD + complete); - p.sendMessage(ChatColor.GREEN + Lang.get(p, "questRewardsTitle")); + p.sendMessage(ChatColor.GOLD + Lang.get(p, "questCompleteTitle").replace("", ChatColor.YELLOW + name + + ChatColor.GOLD)); if (plugin.getSettings().canShowQuestTitles()) { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + p.getName() + " title " + "{\"text\":\"" + Lang.get(p, "quest") + " " + Lang.get(p, "complete") @@ -584,177 +592,189 @@ public class Quest { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "title " + p.getName() + " subtitle " + "{\"text\":\"" + name + "\",\"color\":\"yellow\"}"); } - if (rews.getQuestPoints() > 0) { - p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " " - + Lang.get(p, "questPoints")); - q.questPoints += rews.getQuestPoints(); - none = null; - } - for (ItemStack i : rews.getItems()) { - String text = "error"; - if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) { - if (i.getEnchantments().isEmpty()) { - text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() - + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount(); - } else { - text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() - + ChatColor.RESET; - try { - if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) { - text += ChatColor.GRAY + " " + Lang.get(p, "with") + ChatColor.DARK_PURPLE; - for (Entry e : i.getEnchantments().entrySet()) { - text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue(); + p.sendMessage(ChatColor.GREEN + Lang.get(p, "questRewardsTitle")); + if (!issuedReward) { + p.sendMessage(ChatColor.GRAY + "- (" + Lang.get("none") + ")"); + } else if (!rews.getDetailsOverride().isEmpty()) { + for (String s: rews.getDetailsOverride()) { + String message = ChatColor.DARK_GREEN + ConfigUtil.parseString( + ChatColor.translateAlternateColorCodes('&', s)); + if (plugin.getDependencies().getPlaceholderApi() != null) { + message = PlaceholderAPI.setPlaceholders(p, message); + } + p.sendMessage("- " + message); + } + } else { + if (rews.getQuestPoints() > 0) { + p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getQuestPoints() + " " + + Lang.get(p, "questPoints")); + } + for (ItemStack i : rews.getItems()) { + String text = "error"; + if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) { + if (i.getEnchantments().isEmpty()) { + text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount(); + } else { + text = "- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + + ChatColor.RESET; + try { + if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) { + text += ChatColor.GRAY + " " + Lang.get(p, "with") + ChatColor.DARK_PURPLE; + for (Entry e : i.getEnchantments().entrySet()) { + text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue(); + } } + } catch (Throwable tr) { + // Do nothing, hasItemFlag() not introduced until 1.8.6 } - } catch (Throwable tr) { - // Do nothing, hasItemFlag() not introduced until 1.8.6 + text += ChatColor.GRAY + " x " + i.getAmount(); } - text += ChatColor.GRAY + " x " + i.getAmount(); - } - } else if (i.getDurability() != 0) { - if (i.getEnchantments().isEmpty()) { - text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY - + " x " + i.getAmount(); - } else { - text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY - + " " + Lang.get(p, "with"); - for (Entry e : i.getEnchantments().entrySet()) { - text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue(); + } else if (i.getDurability() != 0) { + if (i.getEnchantments().isEmpty()) { + text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + + " x " + i.getAmount(); + } else { + text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + ChatColor.GRAY + + " " + Lang.get(p, "with"); + for (Entry e : i.getEnchantments().entrySet()) { + text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue(); + } + text += ChatColor.GRAY + " x " + i.getAmount(); } - text += ChatColor.GRAY + " x " + i.getAmount(); - } - } else { - if (i.getEnchantments().isEmpty()) { - text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount(); } else { - text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i); - try { - if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) { - text += ChatColor.GRAY + " " + Lang.get(p, "with"); - for (Entry e : i.getEnchantments().entrySet()) { - text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue(); + if (i.getEnchantments().isEmpty()) { + text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + i.getAmount(); + } else { + text = "- " + ChatColor.DARK_GREEN + ItemUtil.getName(i); + try { + if (!i.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) { + text += ChatColor.GRAY + " " + Lang.get(p, "with"); + for (Entry e : i.getEnchantments().entrySet()) { + text += " " + ItemUtil.getPrettyEnchantmentName(e.getKey()) + ":" + e.getValue(); + } } + } catch (Throwable tr) { + // Do nothing, hasItemFlag() not introduced until 1.8.6 } - } catch (Throwable tr) { - // Do nothing, hasItemFlag() not introduced until 1.8.6 + text += ChatColor.GRAY + " x " + i.getAmount(); } - text += ChatColor.GRAY + " x " + i.getAmount(); } + p.sendMessage(text); } - p.sendMessage(text); - none = null; - } - for (ItemStack i : phatLootItems) { - if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) { - if (i.getEnchantments().isEmpty()) { - p.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() - + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount()); - } else { - p.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() - + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " - + Lang.get(p, "enchantedItem")); - } - } else if (i.getDurability() != 0) { - if (i.getEnchantments().isEmpty()) { - p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() - + ChatColor.GRAY + " x " + i.getAmount()); - } else { - p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() - + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " - + Lang.get(p, "enchantedItem")); - } - } else { - if (i.getEnchantments().isEmpty()) { - p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " - + i.getAmount()); - } else { - p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " - + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get(p, "enchantedItem")); - } - } - none = null; - } - if (rews.getMoney() > 1) { - p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE - + plugin.getDependencies().getCurrency(true)); - none = null; - } else if (rews.getMoney() == 1) { - p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE - + plugin.getDependencies().getCurrency(false)); - none = null; - } - if (rews.getExp() > 0 || phatLootExp > 0) { - int tot = rews.getExp() + phatLootExp; - p.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " " - + Lang.get(p, "experience")); - none = null; - } - if (rews.getCommands().isEmpty() == false) { - int index = 0; - for (String s : rews.getCommands()) { - if (rews.getCommandsOverrideDisplay().isEmpty() == false && rews.getCommandsOverrideDisplay().size() - > index) { - if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) { - p.sendMessage("- " + ChatColor.DARK_GREEN - + rews.getCommandsOverrideDisplay().get(index)); + for (ItemStack i : phatLootItems) { + if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) { + if (i.getEnchantments().isEmpty()) { + p.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount()); + } else { + p.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + + Lang.get(p, "enchantedItem")); + } + } else if (i.getDurability() != 0) { + if (i.getEnchantments().isEmpty()) { + p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + + ChatColor.GRAY + " x " + i.getAmount()); + } else { + p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ":" + i.getDurability() + + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + + Lang.get(p, "enchantedItem")); } } else { - p.sendMessage("- " + ChatColor.DARK_GREEN + s); - } - index++; - } - none = null; - } - if (rews.getMcmmoSkills().isEmpty() == false) { - for (String s : rews.getMcmmoSkills()) { - p.sendMessage("- " + ChatColor.DARK_GREEN - + rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)) + " " + ChatColor.DARK_PURPLE - + s + " " + Lang.get(p, "experience")); - } - none = null; - } - if (rews.getHeroesClasses().isEmpty() == false) { - for (String s : rews.getHeroesClasses()) { - p.sendMessage("- " + ChatColor.AQUA - + rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)) + " " + ChatColor.BLUE - + s + " " + Lang.get(p, "experience")); - } - none = null; - } - if (phatLootMessages.isEmpty() == false) { - for (String s : phatLootMessages) { - p.sendMessage("- " + s); - } - none = null; - } - for (String s : rews.getCustomRewards().keySet()) { - CustomReward found = null; - for (CustomReward cr : plugin.getCustomRewards()) { - if (cr.getName().equalsIgnoreCase(s)) { - found = cr; - break; - } - } - if (found != null) { - Map datamap = rews.getCustomRewards().get(found.getName()); - String message = found.getRewardName(); - if (message != null) { - for (String key : datamap.keySet()) { - message = message.replace("%" + key + "%", datamap.get(key).toString()); + if (i.getEnchantments().isEmpty()) { + p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + + i.getAmount()); + } else { + p.sendMessage("- " + ChatColor.DARK_GREEN + ItemUtil.getName(i) + ChatColor.GRAY + " x " + + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get(p, "enchantedItem")); } - p.sendMessage("- " + ChatColor.GOLD + message); - } else { - plugin.getLogger().warning("Failed to notify player: Custom Reward does not have an assigned name"); } - found.giveReward(p, rews.getCustomRewards().get(s)); - } else { - plugin.getLogger().warning("Quester \"" + player.getName() + "\" completed the Quest \"" + name - + "\", but the Custom Reward \"" + s + "\" could not be found. Does it still exist?"); } - none = null; - } - if (none != null) { - p.sendMessage(none); + if (rews.getMoney() > 1) { + p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE + + plugin.getDependencies().getCurrency(true)); + } else if (rews.getMoney() == 1) { + p.sendMessage("- " + ChatColor.DARK_GREEN + rews.getMoney() + " " + ChatColor.DARK_PURPLE + + plugin.getDependencies().getCurrency(false)); + } + if (rews.getExp() > 0 || phatLootExp > 0) { + int tot = rews.getExp() + phatLootExp; + p.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " " + + Lang.get(p, "experience")); + } + if (rews.getCommands().isEmpty() == false) { + int index = 0; + for (String s : rews.getCommands()) { + if (rews.getCommandsOverrideDisplay().isEmpty() == false && rews.getCommandsOverrideDisplay().size() + > index) { + if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) { + p.sendMessage("- " + ChatColor.DARK_GREEN + + rews.getCommandsOverrideDisplay().get(index)); + } + } else { + p.sendMessage("- " + ChatColor.DARK_GREEN + s); + } + index++; + } + } + if (rews.getPermissions().isEmpty() == false) { + int index = 0; + for (String s : rews.getPermissions()) { + if (rews.getPermissionWorlds() != null) { + p.sendMessage("- " + ChatColor.DARK_GREEN + s + " (" + rews.getPermissionWorlds().get(index) + + ")"); + } else { + p.sendMessage("- " + ChatColor.DARK_GREEN + s); + + } + index++; + } + } + if (rews.getMcmmoSkills().isEmpty() == false) { + for (String s : rews.getMcmmoSkills()) { + p.sendMessage("- " + ChatColor.DARK_GREEN + + rews.getMcmmoAmounts().get(rews.getMcmmoSkills().indexOf(s)) + " " + ChatColor.DARK_PURPLE + + s + " " + Lang.get(p, "experience")); + } + } + if (rews.getHeroesClasses().isEmpty() == false) { + for (String s : rews.getHeroesClasses()) { + p.sendMessage("- " + ChatColor.AQUA + + rews.getHeroesAmounts().get(rews.getHeroesClasses().indexOf(s)) + " " + ChatColor.BLUE + + s + " " + Lang.get(p, "experience")); + } + } + if (phatLootMessages.isEmpty() == false) { + for (String s : phatLootMessages) { + p.sendMessage("- " + s); + } + } + for (String s : rews.getCustomRewards().keySet()) { + CustomReward found = null; + for (CustomReward cr : plugin.getCustomRewards()) { + if (cr.getName().equalsIgnoreCase(s)) { + found = cr; + break; + } + } + if (found != null) { + Map datamap = rews.getCustomRewards().get(found.getName()); + String message = found.getRewardName(); + if (message != null) { + for (String key : datamap.keySet()) { + message = message.replace("%" + key + "%", datamap.get(key).toString()); + } + p.sendMessage("- " + ChatColor.GOLD + message); + } else { + plugin.getLogger().warning("Failed to notify player: Custom Reward does not have an assigned name"); + } + found.giveReward(p, rews.getCustomRewards().get(s)); + } else { + plugin.getLogger().warning("Quester \"" + player.getName() + "\" completed the Quest \"" + name + + "\", but the Custom Reward \"" + s + "\" could not be found. Does it still exist?"); + } + } } } q.saveData(); diff --git a/main/src/main/java/me/blackvein/quests/QuestFactory.java b/main/src/main/java/me/blackvein/quests/QuestFactory.java index 181ae2b8c..d93ec4ba8 100644 --- a/main/src/main/java/me/blackvein/quests/QuestFactory.java +++ b/main/src/main/java/me/blackvein/quests/QuestFactory.java @@ -648,8 +648,8 @@ public class QuestFactory implements ConversationAbandonedListener { context.setSessionData(CK.REQ_CUSTOM, list); context.setSessionData(CK.REQ_CUSTOM_DATA, datamapList); } - if (reqs.getFailRequirements() != null) { - context.setSessionData(CK.REQ_FAIL_MESSAGE, reqs.getFailRequirements()); + if (reqs.getDetailsOverride().isEmpty() == false) { + context.setSessionData(CK.REQ_FAIL_MESSAGE, reqs.getDetailsOverride()); } Rewards rews = q.getRewards(); if (rews.getMoney() != 0) { @@ -673,6 +673,9 @@ public class QuestFactory implements ConversationAbandonedListener { if (rews.getPermissions().isEmpty() == false) { context.setSessionData(CK.REW_PERMISSION, rews.getPermissions()); } + if (rews.getPermissions().isEmpty() == false) { + context.setSessionData(CK.REW_PERMISSION_WORLDS, rews.getPermissionWorlds()); + } if (rews.getMcmmoSkills().isEmpty() == false) { context.setSessionData(CK.REW_MCMMO_SKILLS, rews.getMcmmoSkills()); context.setSessionData(CK.REW_MCMMO_AMOUNTS, rews.getMcmmoAmounts()); @@ -688,6 +691,9 @@ public class QuestFactory implements ConversationAbandonedListener { context.setSessionData(CK.REW_CUSTOM, new LinkedList(rews.getCustomRewards().keySet())); context.setSessionData(CK.REW_CUSTOM_DATA, new LinkedList(rews.getCustomRewards().values())); } + if (rews.getDetailsOverride().isEmpty() == false) { + context.setSessionData(CK.REW_DETAILS_OVERRIDE, rews.getDetailsOverride()); + } Planner pln = q.getPlanner(); if (pln.getStart() != null) { context.setSessionData(CK.PLN_START_DATE, pln.getStart()); @@ -962,8 +968,8 @@ public class QuestFactory implements ConversationAbandonedListener { if (stage.startMessage != null) { context.setSessionData(pref + CK.S_START_MESSAGE, stage.startMessage); } - if (stage.objectiveOverride != null) { - context.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, stage.objectiveOverride); + if (stage.objectiveOverrides.isEmpty() == false) { + context.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, stage.objectiveOverrides); } } } @@ -1547,7 +1553,7 @@ public class QuestFactory implements ConversationAbandonedListener { String heroesSecondaryReq = null; LinkedList customReqs = null; LinkedList> customReqsData = null; - String failMessage = null; + List detailsOverrideReqs = null; Integer moneyRew = null; Integer questPointsRew = null; List itemRews = null; @@ -1557,6 +1563,7 @@ public class QuestFactory implements ConversationAbandonedListener { List commandRews = null; List commandDisplayOverrideRews = null; List permRews = null; + List permWorldRews = null; List mcMMOSkillRews = null; List mcMMOSkillAmounts = null; List heroesClassRews = null; @@ -1564,6 +1571,7 @@ public class QuestFactory implements ConversationAbandonedListener { List phatLootRews = null; LinkedList customRews = null; LinkedList> customRewsData = null; + List detailsOverrideRews = null; String startDatePln = null; String endDatePln = null; Long repeatCyclePln = null; @@ -1621,7 +1629,8 @@ public class QuestFactory implements ConversationAbandonedListener { customReqsData = (LinkedList>) context.getSessionData(CK.REQ_CUSTOM_DATA); } if (context.getSessionData(CK.REQ_FAIL_MESSAGE) != null) { - failMessage = (String) context.getSessionData(CK.REQ_FAIL_MESSAGE); + detailsOverrideReqs = new LinkedList(); + detailsOverrideReqs.addAll((List)context.getSessionData(CK.REQ_FAIL_MESSAGE)); } if (context.getSessionData(CK.Q_INITIAL_EVENT) != null) { initialEvent = (String) context.getSessionData(CK.Q_INITIAL_EVENT); @@ -1656,6 +1665,10 @@ public class QuestFactory implements ConversationAbandonedListener { permRews = new LinkedList(); permRews.addAll((List) context.getSessionData(CK.REW_PERMISSION)); } + if (context.getSessionData(CK.REW_PERMISSION_WORLDS) != null) { + permWorldRews = new LinkedList(); + permWorldRews.addAll((List) context.getSessionData(CK.REW_PERMISSION_WORLDS)); + } if (context.getSessionData(CK.REW_MCMMO_SKILLS) != null) { mcMMOSkillRews = new LinkedList(); mcMMOSkillAmounts = new LinkedList(); @@ -1676,6 +1689,10 @@ public class QuestFactory implements ConversationAbandonedListener { customRews = (LinkedList) context.getSessionData(CK.REW_CUSTOM); customRewsData = (LinkedList>) context.getSessionData(CK.REW_CUSTOM_DATA); } + if (context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null) { + detailsOverrideRews = new LinkedList(); + detailsOverrideRews.addAll((List)context.getSessionData(CK.REW_DETAILS_OVERRIDE)); + } if (context.getSessionData(CK.PLN_START_DATE) != null) { startDatePln = (String) context.getSessionData(CK.PLN_START_DATE); } @@ -1740,7 +1757,7 @@ public class QuestFactory implements ConversationAbandonedListener { customReqSec.set("data", customReqsData.get(i)); } } - reqs.set("fail-requirement-message", failMessage); + reqs.set("fail-requirement-message", detailsOverrideReqs); } else { cs.set("requirements", null); } @@ -1804,7 +1821,7 @@ public class QuestFactory implements ConversationAbandonedListener { LinkedList commandEvents; LinkedList commandEventTriggers; Long delay; - String overrideDisplay; + LinkedList overrideDisplay; String delayMessage; String startMessage; String completeMessage; @@ -1992,7 +2009,7 @@ public class QuestFactory implements ConversationAbandonedListener { script = (String) context.getSessionData(pref + CK.S_DENIZEN); } if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) != null) { - overrideDisplay = (String) context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY); + overrideDisplay = (LinkedList) context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY); } if (context.getSessionData(pref + CK.S_START_MESSAGE) != null) { startMessage = (String) context.getSessionData(pref + CK.S_START_MESSAGE); @@ -2124,8 +2141,7 @@ public class QuestFactory implements ConversationAbandonedListener { stage.set("delay", delay.intValue() / 1000); } stage.set("delay-message", delayMessage == null ? delayMessage : delayMessage.replace("\\n", "\n")); - stage.set("objective-override", overrideDisplay == null ? overrideDisplay - : overrideDisplay.replace("\\n", "\n")); + stage.set("objective-override", overrideDisplay); stage.set("start-message", startMessage == null ? startMessage : startMessage.replace("\\n", "\n")); stage.set("complete-message", completeMessage == null ? completeMessage : completeMessage.replace("\\n", "\n")); @@ -2144,6 +2160,7 @@ public class QuestFactory implements ConversationAbandonedListener { rews.set("quest-points", questPointsRew); rews.set("exp", expRew); rews.set("permissions", permRews); + rews.set("permission-worlds", permWorldRews); rews.set("commands", commandRews); rews.set("commands-override-display", commandDisplayOverrideRews); rews.set("mcmmo-skills", mcMMOSkillRews); @@ -2161,6 +2178,7 @@ public class QuestFactory implements ConversationAbandonedListener { customRewSec.set("data", customRewsData.get(i)); } } + rews.set("details-override", detailsOverrideRews); } else { cs.set("rewards", null); } diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index 696002dae..2bfcb62a8 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -638,15 +638,17 @@ public class Quester { } Requirements reqs = quest.getRequirements(); if (!ignoreOverrides) { - if (reqs.getFailRequirements() != null) { + if (reqs.getDetailsOverride() != null) { LinkedList requirements = new LinkedList(); - String message = ChatColor.RED + ConfigUtil.parseString( - ChatColor.translateAlternateColorCodes('&', reqs.getFailRequirements()), - quest, getPlayer()); - if (plugin.getDependencies().getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(getPlayer(), message); + for (String s : reqs.getDetailsOverride()) { + String message = ChatColor.RED + ConfigUtil.parseString( + ChatColor.translateAlternateColorCodes('&', s), quest, getPlayer()); + if (plugin.getDependencies().getPlaceholderApi() != null) { + message = PlaceholderAPI.setPlaceholders(getPlayer(), message); + } + requirements.add(message); + } - requirements.add(message); return requirements; } } @@ -770,15 +772,16 @@ public class Quester { public LinkedList getCurrentObjectives(Quest quest, boolean ignoreOverrides) { if (!ignoreOverrides) { if (getCurrentStage(quest) != null) { - if (getCurrentStage(quest).objectiveOverride != null) { + if (getCurrentStage(quest).objectiveOverrides.isEmpty() == false) { LinkedList objectives = new LinkedList(); - String message = ChatColor.GREEN + ConfigUtil.parseString( - ChatColor.translateAlternateColorCodes('&', getCurrentStage(quest).objectiveOverride), - quest, getPlayer()); - if (plugin.getDependencies().getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(getPlayer(), message); + for (String s: getCurrentStage(quest).objectiveOverrides) { + String message = ChatColor.GREEN + ConfigUtil.parseString( + ChatColor.translateAlternateColorCodes('&', s), quest, getPlayer()); + if (plugin.getDependencies().getPlaceholderApi() != null) { + message = PlaceholderAPI.setPlaceholders(getPlayer(), message); + } + objectives.add(message); } - objectives.add(message); return objectives; } } @@ -2226,14 +2229,15 @@ public class Quester { Enchantment enchantment, EntityType mob, String extra, NPC npc, Location location, DyeColor color, String pass, CustomObjective co) { Player p = getPlayer(); - if (getCurrentStage(quest).objectiveOverride != null) { - String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " - + ConfigUtil.parseString(ChatColor.translateAlternateColorCodes('&', - getCurrentStage(quest).objectiveOverride), quest, p); - if (plugin.getDependencies().getPlaceholderApi() != null) { - message = PlaceholderAPI.setPlaceholders(p, message); + if (getCurrentStage(quest).objectiveOverrides.isEmpty() == false) { + for (String s: getCurrentStage(quest).objectiveOverrides) { + String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + + ConfigUtil.parseString(ChatColor.translateAlternateColorCodes('&', s), quest, p); + if (plugin.getDependencies().getPlaceholderApi() != null) { + message = PlaceholderAPI.setPlaceholders(p, message); + } + p.sendMessage(message); } - p.sendMessage(message); } else if (objective.equalsIgnoreCase("password")) { String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + pass; p.sendMessage(message); diff --git a/main/src/main/java/me/blackvein/quests/Quests.java b/main/src/main/java/me/blackvein/quests/Quests.java index 878c3d108..23b59e124 100644 --- a/main/src/main/java/me/blackvein/quests/Quests.java +++ b/main/src/main/java/me/blackvein/quests/Quests.java @@ -646,16 +646,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener getLogger().warning("Current stage was null when showing objectives for " + quest.getName()); return; } - if (!ignoreOverrides) { - if (quester.getCurrentStage(quest).objectiveOverride != null) { - String message = ChatColor.GREEN + ConfigUtil.parseString(ChatColor.translateAlternateColorCodes('&', - quester.getCurrentStage(quest).objectiveOverride), quest, quester.getPlayer()); + if (!ignoreOverrides && !quester.getCurrentStage(quest).objectiveOverrides.isEmpty()) { + for (String s: quester.getCurrentStage(quest).objectiveOverrides) { + String message = ChatColor.GREEN + ConfigUtil.parseString( + ChatColor.translateAlternateColorCodes('&', s), quest, quester.getPlayer()); if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } quester.getPlayer().sendMessage(message); - return; } + return; } QuestData data = quester.getQuestData(quest); Stage stage = quester.getCurrentStage(quest); @@ -663,14 +663,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener for (ItemStack e2 : data.blocksBroken) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "break") + " " + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } else { - message = color + Lang.get(quester.getPlayer(), "break") + " " - + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -686,14 +680,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener for (ItemStack e2 : data.blocksDamaged) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "damage") + " " + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } else { - message = color + Lang.get(quester.getPlayer(), "damage") + " " - + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -709,14 +697,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener for (ItemStack e2 : data.blocksPlaced) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "place") + " " + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } else { - message = color + Lang.get(quester.getPlayer(), "place") + " " - + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -732,14 +714,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener for (ItemStack e2 : data.blocksUsed) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "use") + " " + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } else { - message = color + Lang.get(quester.getPlayer(), "use") + " " - + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -755,14 +731,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener for (ItemStack e2 : data.blocksCut) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "cut") + " " + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } else { - message = color + Lang.get(quester.getPlayer(), "cut") + " " - + color + ": " + e2.getAmount() + "/" + e.getAmount(); - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -781,14 +751,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } int amt = is.getAmount(); ChatColor color = crafted < amt ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "craft") + " " + color + ": " + crafted + "/" + is.getAmount(); - } else { - message = color + Lang.get(quester.getPlayer(), "craft") + " " - + color + ": " + crafted + "/" + is.getAmount(); - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -806,14 +770,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } int amt = is.getAmount(); ChatColor color = smelted < amt ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "smelt") + " " + color + ": " + smelted + "/" + is.getAmount(); - } else { - message = color + Lang.get(quester.getPlayer(), "smelt") + " " - + color + ": " + smelted + "/" + is.getAmount(); - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -854,14 +812,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } if (enchantment2 == enchantment) { ChatColor color = num1 < num2 ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "enchantItem") + color + ": " + num1 + "/" + num2; - } else { - message = color + Lang.get(quester.getPlayer(), "enchantItem") - + color + ": " + num1 + "/" + num2; - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -884,14 +836,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } int amt = is.getAmount(); ChatColor color = brewed < amt ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "brew") + " " + color + ": " + brewed + "/" + is.getAmount(); - } else { - message = color + Lang.get(quester.getPlayer(), "brew") + " " - + color + ": " + brewed + "/" + is.getAmount(); - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -911,14 +857,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } if (stage.cowsToMilk != null) { ChatColor color = data.getCowsMilked() < stage.cowsToMilk ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "milkCow") + color + ": " + data.getCowsMilked() + "/" + stage.cowsToMilk; - } else { - message = color + Lang.get(quester.getPlayer(), "milkCow") - + color + ": " + data.getCowsMilked() + "/" + stage.cowsToMilk; - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -926,14 +866,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } if (stage.fishToCatch != null) { ChatColor color = data.getFishCaught() < stage.fishToCatch ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "catchFish") + color + ": " + data.getFishCaught() + "/" + stage.fishToCatch; - } else { - message = color + Lang.get(quester.getPlayer(), "catchFish") - + color + ": " + data.getFishCaught() + "/" + stage.fishToCatch; - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -948,23 +882,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener < stage.mobNumToKill.get(stage.mobsToKill.indexOf(e)) ? ChatColor.GREEN : ChatColor.GRAY; String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride - + color + ": " + (data.mobNumKilled.get(data.mobsKilled.indexOf(e2))) + if (stage.locationsToKillWithin.isEmpty()) { + message = color + Lang.get(quester.getPlayer(), "kill") + " " + + ChatColor.AQUA + "" + color + ": " + + (data.mobNumKilled.get(data.mobsKilled.indexOf(e2))) + "/" + (stage.mobNumToKill.get(stage.mobsToKill.indexOf(e))); } else { - if (stage.locationsToKillWithin.isEmpty()) { - message = color + Lang.get(quester.getPlayer(), "kill") + " " - + ChatColor.AQUA + "" + color + ": " - + (data.mobNumKilled.get(data.mobsKilled.indexOf(e2))) - + "/" + (stage.mobNumToKill.get(stage.mobsToKill.indexOf(e))); - } else { - message = color + Lang.get(quester.getPlayer(), "killAtLocation") + color + ": " - + (data.mobNumKilled.get(data.mobsKilled.indexOf(e2))) + "/" - + (stage.mobNumToKill.get(stage.mobsToKill.indexOf(e))); - message = message.replace("", - stage.killNames.get(stage.mobsToKill.indexOf(e))); - } + message = color + Lang.get(quester.getPlayer(), "killAtLocation") + color + ": " + + (data.mobNumKilled.get(data.mobsKilled.indexOf(e2))) + "/" + + (stage.mobNumToKill.get(stage.mobsToKill.indexOf(e))); + message = message.replace("", + stage.killNames.get(stage.mobsToKill.indexOf(e))); } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); @@ -980,14 +908,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } if (stage.playersToKill != null) { ChatColor color = data.getPlayersKilled() < stage.playersToKill ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "killPlayer") + color + ": " + data.getPlayersKilled() + "/" + stage.playersToKill; - } else { - message = color + Lang.get(quester.getPlayer(), "killPlayer") - + color + ": " + data.getPlayersKilled() + "/" + stage.playersToKill; - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -1003,14 +925,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener Integer npc = stage.itemDeliveryTargets.get(index); index++; ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "deliver") + color + ": " + delivered + "/" + toDeliver; - } else { - message = color + Lang.get(quester.getPlayer(), "deliver") - + color + ": " + delivered + "/" + toDeliver; - } message = message.replace("", depends.getNPCName(npc)); if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); @@ -1026,12 +942,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener for (Entry e : data.citizensInteracted.entrySet()) { if (e.getKey().equals(n)) { ChatColor color = e.getValue() == false ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride; - } else { - message = color + Lang.get(quester.getPlayer(), "talkTo"); - } + String message = color + Lang.get(quester.getPlayer(), "talkTo"); message = message.replace("", depends.getNPCName(n)); if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); @@ -1048,16 +959,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener ChatColor color = data.citizenNumKilled.get(data.citizensKilled.indexOf(n2)) < stage.citizenNumToKill.get(stage.citizensToKill.indexOf(n)) == false ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "kill") + " " + depends.getNPCName(n) + color + " " + data.citizenNumKilled.get(stage.citizensToKill.indexOf(n)) + "/" + stage.citizenNumToKill.get(stage.citizensToKill.indexOf(n)); - } else { - message = color + Lang.get(quester.getPlayer(), "kill") + " " + depends.getNPCName(n) - + color + " " + data.citizenNumKilled.get(stage.citizensToKill.indexOf(n)) + "/" - + stage.citizenNumToKill.get(stage.citizensToKill.indexOf(n)); - } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } @@ -1070,14 +974,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener for (Entry e2 : data.mobsTamed.entrySet()) { if (e.getKey().equals(e2.getKey())) { ChatColor color = e2.getValue() < e.getValue() == false ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "tame") + " " + "" + color + ": " + e2.getValue() + "/" + e.getValue(); - } else { - message = color + Lang.get(quester.getPlayer(), "tame") + " " + "" - + color + ": " + e2.getValue() + "/" + e.getValue(); - } if (getSettings().canTranslateNames()) { localeQuery.sendMessage(quester.getPlayer(), message, e.getKey(), null); } else { @@ -1091,14 +989,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener for (Entry e2 : data.sheepSheared.entrySet()) { if (e.getKey().equals(e2.getKey())) { ChatColor color = e2.getValue() < e.getValue() == false ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride + String message = color + Lang.get(quester.getPlayer(), "shearSheep") + color + ": " + e2.getValue() + "/" + e.getValue(); - } else { - message = color + Lang.get(quester.getPlayer(), "shearSheep") - + color + ": " + e2.getValue() + "/" + e.getValue(); - } message = message.replace("", e.getKey().name().toLowerCase()); quester.getPlayer().sendMessage(message); } @@ -1110,12 +1002,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (!data.hasReached.isEmpty()) { ChatColor color = data.hasReached.get(data.locationsReached.indexOf(l2)) == false ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride; - } else { - message = color + Lang.get(quester.getPlayer(), "goTo"); - } + String message = color + Lang.get(quester.getPlayer(), "goTo"); message = message.replace("", stage.locationNames.get(stage.locationsToReach.indexOf(l))); quester.getPlayer().sendMessage(message); @@ -1127,12 +1014,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (data.passwordsSaid.containsKey(s)) { Boolean b = data.passwordsSaid.get(s); ChatColor color = b != null && !b == false ? ChatColor.GREEN : ChatColor.GRAY; - String message = ""; - if (!ignoreOverrides && quester.getCurrentStage(quest).objectiveOverride != null) { - message = color + quester.getCurrentStage(quest).objectiveOverride; - } else { - message = color + s; - } + String message = color + s; quester.getPlayer().sendMessage(message); } } @@ -1468,7 +1350,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener loadQuestOptions(config, questsSection, quest, questKey); } quest.plugin = this; - processStages(quest, config, questKey); + loadQuestStages(quest, config, questKey); loadQuestRewards(config, quest, questKey); quests.add(quest); if (needsSaving) { @@ -1497,7 +1379,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener private void loadQuestRewards(FileConfiguration config, Quest quest, String questKey) throws QuestFormatException { Rewards rews = quest.getRewards(); if (config.contains("quests." + questKey + ".rewards.items")) { - LinkedList temp = new LinkedList(); // TODO - should maybe be = rews.getItems() ? + LinkedList temp = new LinkedList(); List stackList = (List) config.get("quests." + questKey + ".rewards.items"); if (ConfigUtil.checkList(stackList, ItemStack.class)) { for (ItemStack stack : stackList) { @@ -1516,11 +1398,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener temp.add(stack); } } catch (Exception e) { - skipQuestProcess("items has invalid formatting for " + item, questKey); + skipQuestProcess("Reward items has invalid formatting for " + item, questKey); } } } else { - skipQuestProcess("items has invalid formatting", questKey); + skipQuestProcess("Reward items has invalid formatting", questKey); } } rews.setItems(temp); @@ -1529,44 +1411,53 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (config.getInt("quests." + questKey + ".rewards.money", -999) != -999) { rews.setMoney(config.getInt("quests." + questKey + ".rewards.money")); } else { - skipQuestProcess("money is not a number", questKey); + skipQuestProcess("Reward money is not a number", questKey); } } if (config.contains("quests." + questKey + ".rewards.exp")) { if (config.getInt("quests." + questKey + ".rewards.exp", -999) != -999) { rews.setExp(config.getInt("quests." + questKey + ".rewards.exp")); } else { - skipQuestProcess("exp is not a number", questKey); + skipQuestProcess("Reward exp is not a number", questKey); } } if (config.contains("quests." + questKey + ".rewards.commands")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".rewards.commands"), String.class)) { rews.setCommands(config.getStringList("quests." + questKey + ".rewards.commands")); } else { - skipQuestProcess("commands is not a list of commands", questKey); + skipQuestProcess("Reward commands is not a list of commands", questKey); } } if (config.contains("quests." + questKey + ".rewards.commands-override-display")) { + // Legacy if (ConfigUtil.checkList(config.getList("quests." + questKey + ".rewards.commands-override-display"), String.class)) { rews.setCommandsOverrideDisplay(config.getStringList("quests." + questKey + ".rewards.commands-override-display")); } else { - skipQuestProcess("commands-override-display is not a list of strings", questKey); + skipQuestProcess("Reward commands-override-display is not a list of strings", questKey); } } if (config.contains("quests." + questKey + ".rewards.permissions")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".rewards.permissions"), String.class)) { rews.setPermissions(config.getStringList("quests." + questKey + ".rewards.permissions")); } else { - skipQuestProcess("permissions is not a list of permissions", questKey); + skipQuestProcess("Reward permissions is not a list of permissions", questKey); + } + } + if (config.contains("quests." + questKey + ".rewards.permission-worlds")) { + if (ConfigUtil.checkList(config.getList("quests." + questKey + + ".rewards.permission-worlds"), String.class)) { + rews.setPermissionWorlds(config.getStringList("quests." + questKey + ".rewards.permission-worlds")); + } else { + skipQuestProcess("Reward permissions is not a list of worlds", questKey); } } if (config.contains("quests." + questKey + ".rewards.quest-points")) { if (config.getInt("quests." + questKey + ".rewards.quest-points", -999) != -999) { rews.setQuestPoints(config.getInt("quests." + questKey + ".rewards.quest-points")); } else { - skipQuestProcess("quest-points is not a number", questKey); + skipQuestProcess("Reward quest-points is not a number", questKey); } } if (depends.isPluginAvailable("mcMMO")) { @@ -1578,21 +1469,21 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener Integer.class)) { for (String skill : config.getStringList("quests." + questKey + ".rewards.mcmmo-skills")) { if (depends.getMcmmoClassic() == null) { - skipQuestProcess("mcMMO not found for mcmmo-skills", questKey); + skipQuestProcess("Reward mcMMO not found for mcmmo-skills", questKey); } else if (Quests.getMcMMOSkill(skill) == null) { - skipQuestProcess("mcmmo-skillsis has invalid skill name " + skill, questKey); + skipQuestProcess("Reward mcmmo-skills has invalid skill name " + skill, questKey); } } rews.setMcmmoSkills(config.getStringList("quests." + questKey + ".rewards.mcmmo-skills")); rews.setMcmmoAmounts(config.getIntegerList("quests." + questKey + ".rewards.mcmmo-levels")); } else { - skipQuestProcess("mcmmo-levels is not a list of numbers", questKey); + skipQuestProcess("Reward mcmmo-levels is not a list of numbers", questKey); } } else { - skipQuestProcess("mcmmo-levels is missing!", questKey); + skipQuestProcess("Reward mcmmo-levels is missing!", questKey); } } else { - skipQuestProcess("mcmmo-skills is not a list of mcMMO skill names", questKey); + skipQuestProcess("Reward mcmmo-skills is not a list of mcMMO skill names", questKey); } } } @@ -1608,7 +1499,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (depends.getHeroes() == null) { skipQuestProcess("Heroes not found for heroes-exp-classes", questKey); } else if (depends.getHeroes().getClassManager().getClass(heroClass) == null) { - skipQuestProcess("heroes-exp-classes has invalid class name " + heroClass, questKey); + skipQuestProcess("Reward heroes-exp-classes has invalid class name " + + heroClass, questKey); } } rews.setHeroesClasses(config.getStringList("quests." + questKey @@ -1616,13 +1508,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener rews.setHeroesAmounts(config.getDoubleList("quests." + questKey + ".rewards.heroes-exp-amounts")); } else { - skipQuestProcess("heroes-exp-amounts is not a list of decimal numbers", questKey); + skipQuestProcess("Reward heroes-exp-amounts is not a list of decimal numbers", questKey); } } else { - skipQuestProcess("heroes-exp-amounts is missing", questKey); + skipQuestProcess("Reward heroes-exp-amounts is missing", questKey); } } else { - skipQuestProcess("heroes-exp-classes is not a list of Heroes classes", questKey); + skipQuestProcess("Reward heroes-exp-classes is not a list of Heroes classes", questKey); } } } @@ -1633,15 +1525,23 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (depends.getPhatLoots() == null) { skipQuestProcess("PhatLoots not found for phat-loots", questKey); } else if (PhatLootsAPI.getPhatLoot(loot) == null) { - skipQuestProcess("phat-loots has invalid PhatLoot name " + loot, questKey); + skipQuestProcess("Reward phat-loots has invalid PhatLoot name " + loot, questKey); } } rews.setPhatLoots(config.getStringList("quests." + questKey + ".rewards.phat-loots")); } else { - skipQuestProcess("phat-loots is not a list of PhatLoots", questKey); + skipQuestProcess("Reward phat-loots is not a list of PhatLoots", questKey); } } } + if (config.contains("quests." + questKey + ".rewards.details-override")) { + if (ConfigUtil.checkList(config.getList("quests." + questKey + + ".rewards.details-override"), String.class)) { + rews.setDetailsOverride(config.getStringList("quests." + questKey + ".rewards.details-override")); + } else { + skipQuestProcess("Reward details-override is not a list of strings", questKey); + } + } } @SuppressWarnings("unchecked") @@ -1649,13 +1549,21 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener String questKey) throws QuestFormatException { Requirements reqs = quest.getRequirements(); if (config.contains("quests." + questKey + ".requirements.fail-requirement-message")) { - reqs.setFailRequirements(ConfigUtil.parseString(config.getString("quests." + questKey - + ".requirements.fail-requirement-message"), quest)); + Object o = config.get("quests." + questKey + ".requirements.fail-requirement-message"); + if (o instanceof List) { + reqs.setDetailsOverride(config.getStringList("quests." + questKey + + ".requirements.fail-requirement-message")); + } else { + // Legacy + List override = new LinkedList(); + override.add((String) o); + reqs.setDetailsOverride(override); + } } if (config.contains("quests." + questKey + ".requirements.items")) { - List temp = reqs.getItems(); // TODO - should maybe be = new LinkedList() ? + List temp = new LinkedList(); List stackList = (List) config.get("quests." + questKey + ".requirements.items"); - if (checkList(stackList, ItemStack.class)) { + if (ConfigUtil.checkList(stackList, ItemStack.class)) { for (ItemStack stack : stackList) { if (stack != null) { temp.add(stack); @@ -1664,7 +1572,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } else { // Legacy List items = config.getStringList("quests." + questKey + ".requirements.items"); - if (checkList(items, String.class)) { + if (ConfigUtil.checkList(items, String.class)) { for (String item : items) { try { ItemStack stack = ItemUtil.readItemStack(item); @@ -1781,7 +1689,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener List amounts = config.getIntegerList("quests." + questKey + ".requirements.mcmmo-amounts"); if (skills.size() != amounts.size()) { - skipQuestProcess("Requirement mcmmo-skills: and mcmmo-amounts are not the same size", questKey); + skipQuestProcess("Requirement mcmmo-skills: and mcmmo-amounts are not the same size", + questKey); } reqs.setMcmmoSkills(skills); reqs.setMcmmoAmounts(amounts); @@ -1817,6 +1726,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener skipQuestProcess("Requirement heroes-secondary-class has invalid Heroes class", questKey); } } + if (config.contains("quests." + questKey + ".requirements.details-override")) { + if (ConfigUtil.checkList(config.getList("quests." + questKey + + ".requirements.details-override"), String.class)) { + reqs.setDetailsOverride(config.getStringList("quests." + questKey + ".requirements.details-override")); + } else { + skipQuestProcess("Requirement details-override is not a list of strings", questKey); + } + } } private void loadQuestPlanner(FileConfiguration config, ConfigurationSection questsSection, Quest quest, @@ -1878,7 +1795,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } @SuppressWarnings({ "unchecked", "unused" }) - private void processStages(Quest quest, FileConfiguration config, String questKey) throws StageFormatException { + private void loadQuestStages(Quest quest, FileConfiguration config, String questKey) throws StageFormatException { ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey + ".stages.ordered"); for (String stageNum : questStages.getKeys(false)) { Stage oStage = new Stage(); @@ -1920,7 +1837,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener + ".stages.ordered." + stageNum + ".script-to-run"))) { oStage.script = config.getString("quests." + questKey + ".stages.ordered." + stageNum + ".script-to-run"); } else { - failStageProcess("script-to-run is not a valid Denizen script", quest, stageNum); + failStageLoad("script-to-run is not a valid Denizen script", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-names")) { @@ -1929,7 +1846,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener breakNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-names"); } else { - failStageProcess("break-block-names is not a list of strings", quest, stageNum); + failStageLoad("break-block-names is not a list of strings", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-amounts")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -1937,10 +1854,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener breakAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-amounts"); } else { - failStageProcess("break-block-amounts is not a list of numbers", quest, stageNum); + failStageLoad("break-block-amounts is not a list of numbers", quest, stageNum); } } else { - failStageProcess("break-block-amounts is missing", quest, stageNum); + failStageLoad("break-block-amounts is missing", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-durability")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -1948,10 +1865,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener breakDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum + ".break-block-durability"); } else { - failStageProcess("break-block-durability is not a list of numbers", quest, stageNum); + failStageLoad("break-block-durability is not a list of numbers", quest, stageNum); } } else { - failStageProcess("break-block-durability is missing", quest, stageNum); + failStageLoad("break-block-durability is missing", quest, stageNum); } } int breakIndex = 0; @@ -1966,7 +1883,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (Material.matchMaterial(s) != null) { oStage.blocksToBreak.add(is); } else { - failStageProcess("break-block-names has invalid item name " + s, quest, stageNum); + failStageLoad("break-block-names has invalid item name " + s, quest, stageNum); } breakIndex++; } @@ -1976,18 +1893,18 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener damageNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum + ".damage-block-names"); } else { - failStageProcess("damage-block-names is not a list of strings", quest, stageNum); + failStageLoad("damage-block-names is not a list of strings", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".damage-block-amounts")) { - if (checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum + if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum + ".damage-block-amounts"), Integer.class)) { damageAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum + ".damage-block-amounts"); } else { - failStageProcess("damage-block-amounts is not a list of numbers", quest, stageNum); + failStageLoad("damage-block-amounts is not a list of numbers", quest, stageNum); } } else { - failStageProcess("damage-block-amounts is missing", quest, stageNum); + failStageLoad("damage-block-amounts is missing", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".damage-block-durability")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -1995,10 +1912,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener damageDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum + ".damage-block-durability"); } else { - failStageProcess("damage-block-durability is not a list of numbers", quest, stageNum); + failStageLoad("damage-block-durability is not a list of numbers", quest, stageNum); } } else { - failStageProcess("damage-block-durability is missing", quest, stageNum); + failStageLoad("damage-block-durability is missing", quest, stageNum); } } int damageIndex = 0; @@ -2014,7 +1931,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (Material.matchMaterial(s) != null) { oStage.blocksToDamage.add(is); } else { - failStageProcess("damage-block-names has invalid item name " + s, quest, stageNum); + failStageLoad("damage-block-names has invalid item name " + s, quest, stageNum); } damageIndex++; } @@ -2024,7 +1941,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener placeNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum + ".place-block-names"); } else { - failStageProcess("place-block-names is not a list of strings", quest, stageNum); + failStageLoad("place-block-names is not a list of strings", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".place-block-amounts")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -2032,10 +1949,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener placeAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum + ".place-block-amounts"); } else { - failStageProcess("place-block-amounts is not a list of numbers", quest, stageNum); + failStageLoad("place-block-amounts is not a list of numbers", quest, stageNum); } } else { - failStageProcess("place-block-amounts is missing", quest, stageNum); + failStageLoad("place-block-amounts is missing", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".place-block-durability")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -2043,10 +1960,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener placeDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum + ".place-block-durability"); } else { - failStageProcess("place-block-durability is not a list of numbers", quest, stageNum); + failStageLoad("place-block-durability is not a list of numbers", quest, stageNum); } } else { - failStageProcess("place-block-durability is missing", quest, stageNum); + failStageLoad("place-block-durability is missing", quest, stageNum); } } int placeIndex = 0; @@ -2061,7 +1978,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (Material.matchMaterial(s) != null) { oStage.blocksToPlace.add(is); } else { - failStageProcess("place-block-names has invalid item name " + s, quest, stageNum); + failStageLoad("place-block-names has invalid item name " + s, quest, stageNum); } placeIndex++; } @@ -2071,18 +1988,18 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener useNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-names"); } else { - failStageProcess("use-block-names is not a list of strings", quest, stageNum); + failStageLoad("use-block-names is not a list of strings", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-amounts")) { - if (checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-amounts"), - Integer.class)) { + if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum + + ".use-block-amounts"),Integer.class)) { useAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-amounts"); } else { - failStageProcess("use-block-amounts is not a list of numbers", quest, stageNum); + failStageLoad("use-block-amounts is not a list of numbers", quest, stageNum); } } else { - failStageProcess("use-block-amounts is missing", quest, stageNum); + failStageLoad("use-block-amounts is missing", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-durability")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -2090,10 +2007,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener useDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum + ".use-block-durability"); } else { - failStageProcess("use-block-durability is not a list of numbers", quest, stageNum); + failStageLoad("use-block-durability is not a list of numbers", quest, stageNum); } } else { - failStageProcess("use-block-durability is missing", quest, stageNum); + failStageLoad("use-block-durability is missing", quest, stageNum); } } int useIndex = 0; @@ -2108,7 +2025,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (Material.matchMaterial(s) != null) { oStage.blocksToUse.add(is); } else { - failStageProcess("use-block-names has invalid item name " + s, quest, stageNum); + failStageLoad("use-block-names has invalid item name " + s, quest, stageNum); } useIndex++; } @@ -2118,7 +2035,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener cutNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum + ".cut-block-names"); } else { - failStageProcess("cut-block-names is not a list of strings", quest, stageNum); + failStageLoad("cut-block-names is not a list of strings", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cut-block-amounts")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -2126,10 +2043,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener cutAmounts = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum + ".cut-block-amounts"); } else { - failStageProcess("cut-block-amounts is not a list of numbers", quest, stageNum); + failStageLoad("cut-block-amounts is not a list of numbers", quest, stageNum); } } else { - failStageProcess("cut-block-amounts is missing", quest, stageNum); + failStageLoad("cut-block-amounts is missing", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cut-block-durability")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -2137,10 +2054,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener cutDurability = config.getShortList("quests." + questKey + ".stages.ordered." + stageNum + ".cut-block-durability"); } else { - failStageProcess("cut-block-durability is not a list of numbers", quest, stageNum); + failStageLoad("cut-block-durability is not a list of numbers", quest, stageNum); } } else { - failStageProcess("cut-block-durability is missing", quest, stageNum); + failStageLoad("cut-block-durability is missing", quest, stageNum); } } int cutIndex = 0; @@ -2155,7 +2072,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (Material.matchMaterial(s) != null) { oStage.blocksToCut.add(is); } else { - failStageProcess("cut-block-names has invalid item name " + s, quest, stageNum); + failStageLoad("cut-block-names has invalid item name " + s, quest, stageNum); } cutIndex++; } @@ -2167,7 +2084,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (stack != null) { oStage.itemsToCraft.add(stack); } else { - failStageProcess("items-to-craft has invalid formatting " + stack, quest, stageNum); + failStageLoad("items-to-craft has invalid formatting " + stack, quest, stageNum); } } } else { @@ -2180,11 +2097,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (is != null) { oStage.itemsToCraft.add(is); } else { - failStageProcess("Legacy items-to-craft has invalid formatting " + item, quest, stageNum); + failStageLoad("Legacy items-to-craft has invalid formatting " + item, quest, stageNum); } } } else { - failStageProcess("items-to-craft is not formatted properly", quest, stageNum); + failStageLoad("items-to-craft is not formatted properly", quest, stageNum); } } } @@ -2196,7 +2113,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (stack != null) { oStage.itemsToSmelt.add(stack); } else { - failStageProcess("items-to-smelt has invalid formatting " + stack, quest, stageNum); + failStageLoad("items-to-smelt has invalid formatting " + stack, quest, stageNum); } } } else { @@ -2209,11 +2126,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (is != null) { oStage.itemsToSmelt.add(is); } else { - failStageProcess("Legacy items-to-smelt has invalid formatting " + item, quest, stageNum); + failStageLoad("Legacy items-to-smelt has invalid formatting " + item, quest, stageNum); } } } else { - failStageProcess("items-to-smelt is not formatted properly", quest, stageNum); + failStageLoad("items-to-smelt is not formatted properly", quest, stageNum); } } } @@ -2226,11 +2143,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (e != null) { enchantments.add(e); } else { - failStageProcess("enchantments has invalid enchantment " + enchant, quest, stageNum); + failStageLoad("enchantments has invalid enchantment " + enchant, quest, stageNum); } } } else { - failStageProcess("enchantments is not a list of enchantment names", quest, stageNum); + failStageLoad("enchantments is not a list of enchantment names", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".enchantment-item-names")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -2240,14 +2157,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (Material.matchMaterial(item) != null) { itemsToEnchant.add(Material.matchMaterial(item)); } else { - failStageProcess("enchantment-item-names has invalid item name " + item, quest, stageNum); + failStageLoad("enchantment-item-names has invalid item name " + item, quest, stageNum); } } } else { - failStageProcess("enchantment-item-names has invalid item name", quest, stageNum); + failStageLoad("enchantment-item-names has invalid item name", quest, stageNum); } } else { - failStageProcess("enchantment-item-names is missing", quest, stageNum); + failStageLoad("enchantment-item-names is missing", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".enchantment-amounts")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -2255,10 +2172,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener amountsToEnchant = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum + ".enchantment-amounts"); } else { - failStageProcess("enchantment-amounts is not a list of numbers", quest, stageNum); + failStageLoad("enchantment-amounts is not a list of numbers", quest, stageNum); } } else { - failStageProcess("enchantment-amounts is missing", quest, stageNum); + failStageLoad("enchantment-amounts is missing", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-brew")) { @@ -2269,7 +2186,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (stack != null) { oStage.itemsToBrew.add(stack); } else { - failStageProcess("items-to-brew has invalid formatting " + stack, quest, stageNum); + failStageLoad("items-to-brew has invalid formatting " + stack, quest, stageNum); } } } else { @@ -2282,11 +2199,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (is != null) { oStage.itemsToBrew.add(is); } else { - failStageProcess("Legacy items-to-brew has invalid formatting " + item, quest, stageNum); + failStageLoad("Legacy items-to-brew has invalid formatting " + item, quest, stageNum); } } } else { - failStageProcess("items-to-brew has invalid formatting", quest, stageNum); + failStageLoad("items-to-brew has invalid formatting", quest, stageNum); } } } @@ -2295,7 +2212,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.cowsToMilk = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".cows-to-milk"); } else { - failStageProcess("cows-to-milk is not a number", quest, stageNum); + failStageLoad("cows-to-milk is not a number", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch")) { @@ -2303,7 +2220,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.fishToCatch = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch"); } else { - failStageProcess("fish-to-catch is not a number", quest, stageNum); + failStageLoad("fish-to-catch is not a number", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill")) { @@ -2311,7 +2228,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.playersToKill = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill"); } else { - failStageProcess("players-to-kill is not a number", quest, stageNum); + failStageLoad("players-to-kill is not a number", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-ids-to-talk-to")) { @@ -2324,15 +2241,15 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (CitizensAPI.getNPCRegistry().getById(i) != null) { questNpcs.add(CitizensAPI.getNPCRegistry().getById(i)); } else { - failStageProcess("npc-ids-to-talk-to has invalid NPC ID of " + i, quest, stageNum); + failStageLoad("npc-ids-to-talk-to has invalid NPC ID of " + i, quest, stageNum); } } else { - failStageProcess("Citizens not found for npc-ids-to-talk-to", quest, stageNum); + failStageLoad("Citizens not found for npc-ids-to-talk-to", quest, stageNum); } } } else { - failStageProcess("npc-ids-to-talk-to is not a list of numbers", quest, stageNum); + failStageLoad("npc-ids-to-talk-to is not a list of numbers", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".items-to-deliver")) { @@ -2360,13 +2277,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.itemDeliveryTargets.add(npcId); oStage.deliverMessages.addAll(deliveryMessages); } else { - failStageProcess("Citizens not found for npc-delivery-ids", quest, stageNum); + failStageLoad("Citizens not found for npc-delivery-ids", quest, stageNum); } } else { - failStageProcess("npc-delivery-ids has invalid NPC ID of " + npcId, quest, stageNum); + failStageLoad("npc-delivery-ids has invalid NPC ID of " + npcId, quest, stageNum); } } else { - failStageProcess("items-to-deliver has invalid formatting " + stack, quest, stageNum); + failStageLoad("items-to-deliver has invalid formatting " + stack, quest, stageNum); } } } @@ -2387,25 +2304,25 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.itemDeliveryTargets.add(npcId); oStage.deliverMessages.addAll(deliveryMessages); } else { - failStageProcess("npc-delivery-ids has invalid NPC ID of " + npcId, quest, stageNum); + failStageLoad("npc-delivery-ids has invalid NPC ID of " + npcId, quest, stageNum); } } else { - failStageProcess("Citizens was not found installed for npc-delivery-ids", quest, stageNum); + failStageLoad("Citizens was not found installed for npc-delivery-ids", quest, stageNum); } } else { - failStageProcess("items-to-deliver has invalid formatting " + item, quest, stageNum); + failStageLoad("items-to-deliver has invalid formatting " + item, quest, stageNum); } } } else { - failStageProcess("items-to-deliver has invalid formatting", quest, stageNum); + failStageLoad("items-to-deliver has invalid formatting", quest, stageNum); } } } } else { - failStageProcess("npc-delivery-ids is not a list of numbers", quest, stageNum); + failStageLoad("npc-delivery-ids is not a list of numbers", quest, stageNum); } } else { - failStageProcess("npc-delivery-id is missing", quest, stageNum); + failStageLoad("npc-delivery-id is missing", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".npc-ids-to-kill")) { @@ -2425,20 +2342,20 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.citizenNumToKill.add(npcAmountsToKill.get(npcIdsToKill.indexOf(i))); questNpcs.add(CitizensAPI.getNPCRegistry().getById(i)); } else { - failStageProcess("npc-kill-amounts is not a positive number", quest, stageNum); + failStageLoad("npc-kill-amounts is not a positive number", quest, stageNum); } } else { - failStageProcess("npc-ids-to-kill has invalid NPC ID of " + i, quest, stageNum); + failStageLoad("npc-ids-to-kill has invalid NPC ID of " + i, quest, stageNum); } } } else { - failStageProcess("npc-kill-amounts is not a list of numbers", quest, stageNum); + failStageLoad("npc-kill-amounts is not a list of numbers", quest, stageNum); } } else { - failStageProcess("npc-kill-amounts is missing", quest, stageNum); + failStageLoad("npc-kill-amounts is missing", quest, stageNum); } } else { - failStageProcess("npc-ids-to-kill is not a list of numbers", quest, stageNum); + failStageLoad("npc-ids-to-kill is not a list of numbers", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mobs-to-kill")) { @@ -2451,11 +2368,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (type != null) { mobsToKill.add(type); } else { - failStageProcess("mobs-to-kill has invalid mob name " + mob, quest, stageNum); + failStageLoad("mobs-to-kill has invalid mob name " + mob, quest, stageNum); } } } else { - failStageProcess("mobs-to-kill is not a list of mob names", quest, stageNum); + failStageLoad("mobs-to-kill is not a list of mob names", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mob-amounts")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -2465,10 +2382,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener mobNumToKill.add(i); } } else { - failStageProcess("mob-amounts is not a list of numbers", quest, stageNum); + failStageLoad("mob-amounts is not a list of numbers", quest, stageNum); } } else { - failStageProcess("mob-amounts is missing", quest, stageNum); + failStageLoad("mob-amounts is missing", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".locations-to-kill")) { @@ -2480,11 +2397,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (ConfigUtil.getLocation(loc) != null) { locationsToKillWithin.add(ConfigUtil.getLocation(loc)); } else { - failStageProcess("locations-to-kill has invalid formatting " + loc, quest, stageNum); + failStageLoad("locations-to-kill has invalid formatting " + loc, quest, stageNum); } } } else { - failStageProcess("locations-to-kill is not a list of locations", quest, stageNum); + failStageLoad("locations-to-kill is not a list of locations", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".kill-location-radii")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -2495,10 +2412,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener radiiToKillWithin.add(i); } } else { - failStageProcess("kill-location-radii is not a list of numbers", quest, stageNum); + failStageLoad("kill-location-radii is not a list of numbers", quest, stageNum); } } else { - failStageProcess("kill-location-radii is missing", quest, stageNum); + failStageLoad("kill-location-radii is missing", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".kill-location-names")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -2509,10 +2426,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener areaNames.add(name); } } else { - failStageProcess("kill-location-names is not a list of names", quest, stageNum); + failStageLoad("kill-location-names is not a list of names", quest, stageNum); } } else { - failStageProcess("kill-location-names is missing", quest, stageNum); + failStageLoad("kill-location-names is missing", quest, stageNum); } } oStage.mobsToKill.addAll(mobsToKill); @@ -2536,11 +2453,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (ConfigUtil.getLocation(loc) != null) { oStage.locationsToReach.add(ConfigUtil.getLocation(loc)); } else { - failStageProcess("locations-to-reach has invalid formatting" + loc, quest, stageNum); + failStageLoad("locations-to-reach has invalid formatting" + loc, quest, stageNum); } } } else { - failStageProcess("locations-to-reach is not a list of locations", quest, stageNum); + failStageLoad("locations-to-reach is not a list of locations", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".reach-location-radii")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -2551,10 +2468,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.radiiToReachWithin.add(i); } } else { - failStageProcess("reach-location-radii is not a list of numbers", quest, stageNum); + failStageLoad("reach-location-radii is not a list of numbers", quest, stageNum); } } else { - failStageProcess("reach-location-radii is missing", quest, stageNum); + failStageLoad("reach-location-radii is missing", quest, stageNum); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".reach-location-names")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum @@ -2565,10 +2482,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.locationNames.add(name); } } else { - failStageProcess("reach-location-names is not a list of names", quest, stageNum); + failStageLoad("reach-location-names is not a list of names", quest, stageNum); } } else { - failStageProcess("reach-location-names is missing", quest, stageNum); + failStageLoad("reach-location-names is missing", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mobs-to-tame")) { @@ -2587,17 +2504,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.mobsToTame.put(EntityType.valueOf(mob.toUpperCase()), mobAmounts.get(mobs.indexOf(mob))); } else { - failStageProcess("mobs-to-tame has invalid tameable mob " + mob, quest, stageNum); + failStageLoad("mobs-to-tame has invalid tameable mob " + mob, quest, stageNum); } } } else { - failStageProcess("mob-tame-amounts is not a list of numbers", quest, stageNum); + failStageLoad("mob-tame-amounts is not a list of numbers", quest, stageNum); } } else { - failStageProcess("mob-tame-amounts is missing", quest, stageNum); + failStageLoad("mob-tame-amounts is missing", quest, stageNum); } } else { - failStageProcess("mobs-to-tame is not a list of mob names", quest, stageNum); + failStageLoad("mobs-to-tame is not a list of mob names", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".sheep-to-shear")) { @@ -2657,17 +2574,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.sheepToShear.put(DyeColor.YELLOW, shearAmounts.get(sheep.indexOf(color))); // <-- Legacy end } else { - failStageProcess("sheep-to-shear has invalid color " + color, quest, stageNum); + failStageLoad("sheep-to-shear has invalid color " + color, quest, stageNum); } } } else { - failStageProcess("sheep-amounts is not a list of numbers", quest, stageNum); + failStageLoad("sheep-amounts is not a list of numbers", quest, stageNum); } } else { - failStageProcess("sheep-amounts is missing", quest, stageNum); + failStageLoad("sheep-amounts is missing", quest, stageNum); } } else { - failStageProcess("sheep-to-shear is not a list of colors", quest, stageNum); + failStageLoad("sheep-to-shear is not a list of colors", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".password-displays")) { @@ -2684,15 +2601,25 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.passwordPhrases.add(answers); } } else { - failStageProcess("password-displays and password-phrases are not the same size", quest, stageNum); + failStageLoad("password-displays and password-phrases are not the same size", quest, + stageNum); } } else { - failStageProcess("password-phrases is missing", quest, stageNum); + failStageLoad("password-phrases is missing", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".objective-override")) { - oStage.objectiveOverride = config.getString("quests." + questKey + ".stages.ordered." + stageNum + Object o = config.get("quests." + questKey + ".stages.ordered." + stageNum + ".objective-override"); + if (o instanceof List) { + oStage.objectiveOverrides.addAll(config.getStringList("quests." + questKey + + ".stages.ordered." + stageNum + ".objective-override")); + } else { + // Legacy + String s = config.getString("quests." + questKey + ".stages.ordered." + stageNum + + ".objective-override"); + oStage.objectiveOverrides.add(s); + } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".start-event")) { Action evt = Action.loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum @@ -2700,7 +2627,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (evt != null) { oStage.startAction = evt; } else { - failStageProcess("start-event failed to load", quest, stageNum); + failStageLoad("start-event failed to load", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".finish-event")) { @@ -2709,7 +2636,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (evt != null) { oStage.finishAction = evt; } else { - failStageProcess("finish-event failed to load", quest, stageNum); + failStageLoad("finish-event failed to load", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".death-event")) { @@ -2718,7 +2645,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (evt != null) { oStage.deathAction = evt; } else { - failStageProcess("death-event failed to load", quest, stageNum); + failStageLoad("death-event failed to load", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".disconnect-event")) { @@ -2727,7 +2654,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (evt != null) { oStage.disconnectAction = evt; } else { - failStageProcess("disconnect-event failed to load", quest, stageNum); + failStageLoad("disconnect-event failed to load", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".chat-events")) { @@ -2745,20 +2672,20 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.chatActions.put(chatEventTriggers.get(i), evt); } else { loadEventFailed = true; - failStageProcess("chat-events failed to load " + chatEvents.get(i), quest, stageNum); + failStageLoad("chat-events failed to load " + chatEvents.get(i), quest, stageNum); } } if (loadEventFailed) { break; } } else { - failStageProcess("chat-event-triggers is not in list format", quest, stageNum); + failStageLoad("chat-event-triggers is not in list format", quest, stageNum); } } else { - failStageProcess("chat-event-triggers is missing", quest, stageNum); + failStageLoad("chat-event-triggers is missing", quest, stageNum); } } else { - failStageProcess("chat-events is not in list format", quest, stageNum); + failStageLoad("chat-events is not in list format", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".command-events")) { @@ -2776,27 +2703,27 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener oStage.commandActions.put(commandEventTriggers.get(i), evt); } else { loadEventFailed = true; - failStageProcess("command-events failed to load " + commandEvents.get(i), quest, stageNum); + failStageLoad("command-events failed to load " + commandEvents.get(i), quest, stageNum); } } if (loadEventFailed) { break; } } else { - failStageProcess("command-event-triggers is not in list format", quest, stageNum); + failStageLoad("command-event-triggers is not in list format", quest, stageNum); } } else { - failStageProcess("command-event-triggers is missing", quest, stageNum); + failStageLoad("command-event-triggers is missing", quest, stageNum); } } else { - failStageProcess("command-events is not in list format", quest, stageNum); + failStageLoad("command-events is not in list format", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay")) { if (config.getLong("quests." + questKey + ".stages.ordered." + stageNum + ".delay", -999) != -999) { oStage.delay = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".delay") * 1000; } else { - failStageProcess("delay is not a number", quest, stageNum); + failStageLoad("delay is not a number", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay-message")) { @@ -2962,6 +2889,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener ? value : new String()); } + // TODO - move to exception itself, pass msg to super() /** * Throw exception for failing to properly load Stage * @param msg Error message @@ -2969,7 +2897,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener * @param stageNum Stage number involved * @throws StageFormatException */ - private void failStageProcess(String msg, Quest quest, String stageNum) throws StageFormatException { + private void failStageLoad(String msg, Quest quest, String stageNum) throws StageFormatException { int stage = 0; try { stage = Integer.valueOf(stageNum); @@ -3120,20 +3048,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener } return true; } - - /** - * Checks whether items in a list are instances of a class

- * - * Does NOT check whether list objects are null - * - * @deprecated Use ConfigUtil.checkList(List, Class) - * @param list The list to check objects of - * @param clazz The class to compare against - * @return false if list is null or list object does not match - */ - public static boolean checkList(List list, Class clazz) { - return ConfigUtil.checkList(list, clazz); - } /** * Get a Quest by ID diff --git a/main/src/main/java/me/blackvein/quests/Requirements.java b/main/src/main/java/me/blackvein/quests/Requirements.java index ada8e70a8..57a718cba 100644 --- a/main/src/main/java/me/blackvein/quests/Requirements.java +++ b/main/src/main/java/me/blackvein/quests/Requirements.java @@ -32,7 +32,7 @@ public class Requirements { private String heroesPrimaryClass = null; private String heroesSecondaryClass = null; private Map> customRequirements = new HashMap>(); - private String failRequirements = null; + private List detailsOverride = new LinkedList(); public int getMoney() { return money; @@ -106,10 +106,10 @@ public class Requirements { protected void setCustomRequirements(Map> customRequirements) { this.customRequirements = customRequirements; } - public String getFailRequirements() { - return failRequirements; + public List getDetailsOverride() { + return detailsOverride; } - public void setFailRequirements(String failRequirements) { - this.failRequirements = failRequirements; + public void setDetailsOverride(List detailsOverride) { + this.detailsOverride = detailsOverride; } } diff --git a/main/src/main/java/me/blackvein/quests/Rewards.java b/main/src/main/java/me/blackvein/quests/Rewards.java index 4e2c06932..393b7b50c 100644 --- a/main/src/main/java/me/blackvein/quests/Rewards.java +++ b/main/src/main/java/me/blackvein/quests/Rewards.java @@ -34,6 +34,7 @@ public class Rewards { private List heroesAmounts = new LinkedList(); private List phatLoots = new LinkedList(); private Map> customRewards = new HashMap>(); + private List detailsOverride = new LinkedList(); public int getMoney() { return money; @@ -119,4 +120,10 @@ public class Rewards { protected void setCustomRewards(Map> customRewards) { this.customRewards = customRewards; } + public List getDetailsOverride() { + return detailsOverride; + } + public void setDetailsOverride(List detailsOverride) { + this.detailsOverride = detailsOverride; + } } diff --git a/main/src/main/java/me/blackvein/quests/Stage.java b/main/src/main/java/me/blackvein/quests/Stage.java index 9bf3c80c5..9919bb687 100644 --- a/main/src/main/java/me/blackvein/quests/Stage.java +++ b/main/src/main/java/me/blackvein/quests/Stage.java @@ -127,7 +127,7 @@ public class Stage { protected String delayMessage = null; protected String completeMessage = null; protected String startMessage = null; - protected String objectiveOverride = null; + protected LinkedList objectiveOverrides = new LinkedList(); protected LinkedList customObjectives = new LinkedList(); protected LinkedList customObjectiveCounts = new LinkedList(); protected LinkedList customObjectiveDisplays = new LinkedList(); @@ -470,12 +470,12 @@ public class Stage { this.startMessage = startMessage; } - public String getObjectiveOverride() { - return objectiveOverride; + public LinkedList getObjectiveOverrides() { + return objectiveOverrides; } - public void setObjectiveOverride(String objectiveOverride) { - this.objectiveOverride = objectiveOverride; + public void setObjectiveOverrides(LinkedList objectiveOverrides) { + this.objectiveOverrides = objectiveOverrides; } public LinkedList getCustomObjectives() { diff --git a/main/src/main/java/me/blackvein/quests/actions/Action.java b/main/src/main/java/me/blackvein/quests/actions/Action.java index 22a98fcc2..58184a110 100644 --- a/main/src/main/java/me/blackvein/quests/actions/Action.java +++ b/main/src/main/java/me/blackvein/quests/actions/Action.java @@ -364,7 +364,8 @@ public class Action { quest.failQuest(quester); } if (timer > 0) { - player.sendMessage(Lang.get(player, "timerStart").replace("

+ * Stores name in "tempName" context data

+ * Stores amount in "tempAmount" context data

+ * Stores durability in "tempData" context data

+ * Stores enchantments in "tempEnchantments" context data

+ * Stores display name in "tempDisplay" context data

+ * Stores lore in "tempLore" context data

+ * Stores metadata in "tempMeta" context data + */ public class ItemStackPrompt extends FixedSetPrompt { - // Stores ItemStack in "tempStack" context data - // Stores name in "tempName" - // Stores amount in "tempAmount" - // Stores durability in "tempData" - // Stores enchantments in "tempEnchantments" - // Stores display name in "tempDisplay" - // Stores lore in "tempLore" - // Stores metadata in "tempMeta" private final Prompt oldPrompt; public ItemStackPrompt(Prompt old) { diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/OptionsPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/OptionsPrompt.java index 419c99256..bbfe7068b 100644 --- a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/OptionsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/OptionsPrompt.java @@ -41,14 +41,17 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt { private final int size = 3; + @Override public int getSize() { return size; } + @Override public String getTitle(ConversationContext context) { return Lang.get("optionsTitle").replace("", (String) context.getSessionData(CK.Q_NAME)); } + @Override public ChatColor getNumberColor(ConversationContext context, int number) { switch (number) { case 1: @@ -62,6 +65,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt { } } + @Override public String getSelectionText(ConversationContext context, int number) { switch (number) { case 1: @@ -75,6 +79,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt { } } + @Override public String getAdditionalText(ConversationContext context, int number) { return null; } @@ -120,10 +125,12 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt { return size; } + @Override public String getTitle(ConversationContext context) { return null; } + @Override public String getQueryText(ConversationContext context) { String text = "Select '' or ''"; text = text.replace("", Lang.get("true")); @@ -191,10 +198,12 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt { return size; } + @Override public String getTitle(ConversationContext context) { return null; } + @Override public String getQueryText(ConversationContext context) { return "Pick level of progress sharing"; } @@ -281,14 +290,17 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt { private final int size = 3; + @Override public int getSize() { return size; } + @Override public String getTitle(ConversationContext context) { return ChatColor.DARK_GREEN + Lang.get("optGeneral"); } + @Override public ChatColor getNumberColor(ConversationContext context, int number) { switch (number) { case 1: @@ -302,6 +314,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt { } } + @Override public String getSelectionText(ConversationContext context, int number) { switch (number) { case 1: @@ -315,6 +328,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt { } } + @Override public String getAdditionalText(ConversationContext context, int number) { switch (number) { case 1: @@ -395,14 +409,17 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt { private final int size = 5; + @Override public int getSize() { return size; } + @Override public String getTitle(ConversationContext context) { return ChatColor.DARK_GREEN + Lang.get("optMultiplayer"); } + @Override public ChatColor getNumberColor(ConversationContext context, int number) { switch (number) { case 1: @@ -420,6 +437,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt { } } + @Override public String getSelectionText(ConversationContext context, int number) { switch (number) { case 1: @@ -437,6 +455,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt { } } + @Override public String getAdditionalText(ConversationContext context, int number) { switch (number) { case 1: diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/OverridePrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/OverridePrompt.java new file mode 100644 index 000000000..f5e53647d --- /dev/null +++ b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/OverridePrompt.java @@ -0,0 +1,85 @@ +package me.blackvein.quests.convo.quests.prompts; + +import org.bukkit.ChatColor; +import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.Prompt; + +import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenStringPromptEvent; +import me.blackvein.quests.util.Lang; + +public class OverridePrompt extends QuestsEditorStringPrompt { + private final Prompt oldPrompt; + private String promptText; + private String classPrefix; + + public OverridePrompt(ConversationContext context, Prompt old, String promptText) { + super(context, null); + oldPrompt = old; + classPrefix = old.getClass().getSimpleName(); + this.promptText = promptText; + } + + private final int size = 1; + + public int getSize() { + return size; + } + + @Override + public String getTitle(ConversationContext context) { + return null; + } + + @Override + public String getQueryText(ConversationContext context) { + return null; + } + + @Override + public String getPromptText(ConversationContext context) { + QuestsEditorPostOpenStringPromptEvent event + = new QuestsEditorPostOpenStringPromptEvent(context, null, this); + context.getPlugin().getServer().getPluginManager().callEvent(event); + + String text = ChatColor.YELLOW + promptText + "\n";; + return text; + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false + && input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + context.setSessionData(classPrefix + "-override", input); + } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { + context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("cleared")); + context.setSessionData(classPrefix + "-override", null); + } + return oldPrompt; + } + + public static class Builder { + private ConversationContext context; + private Prompt oldPrompt; + private String promptText = "Enter input"; + + public Builder context(ConversationContext context) { + this.context = context; + return this; + } + + public Builder source(Prompt prompt) { + this.oldPrompt = prompt; + return this; + } + + public Builder promptText(String text) { + this.promptText = text; + return this; + } + + public OverridePrompt build() { + return new OverridePrompt(context, oldPrompt, promptText); + } + } +} diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/QuestOfferPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/QuestOfferPrompt.java index fdf47ea3c..4a6bfacf2 100644 --- a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/QuestOfferPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/QuestOfferPrompt.java @@ -127,7 +127,9 @@ public class QuestOfferPrompt extends StringPrompt { plugin.getConversationFactory().buildConversation((Conversable) player).begin(); } } else { - player.sendMessage(q.getRequirements().getFailRequirements()); + for (String msg : q.getRequirements().getDetailsOverride()) { + player.sendMessage(msg); + } } } else if (quester.getCurrentQuests().containsKey(q) == false) { String msg = Lang.get("questMaxAllowed"); diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/RequirementsPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/RequirementsPrompt.java index 5e972baee..2d7cec099 100644 --- a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/RequirementsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/RequirementsPrompt.java @@ -43,6 +43,7 @@ import me.blackvein.quests.util.MiscUtil; public class RequirementsPrompt extends QuestsEditorNumericPrompt { private final Quests plugin; + private final String classPrefix; private final QuestFactory factory; private boolean hasRequirement = false; private final int size = 11; @@ -50,6 +51,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt { public RequirementsPrompt(Quests plugin, ConversationContext context, QuestFactory qf) { super(context, qf); this.plugin = plugin; + this.classPrefix = getClass().getSimpleName(); this.factory = qf; } @@ -91,6 +93,16 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt { return ChatColor.BLUE; } case 11: + if (context.getSessionData(CK.REQ_FAIL_MESSAGE) == null) { + if (!hasRequirement) { + return ChatColor.GRAY; + } else { + return ChatColor.BLUE; + } + } else { + return ChatColor.BLUE; + } + case 12: return ChatColor.GREEN; default: return null; @@ -119,9 +131,9 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt { return ChatColor.DARK_PURPLE + Lang.get("reqSetCustom"); case 10: if (!hasRequirement) { - return ChatColor.GRAY + Lang.get("reqSetFail"); + return ChatColor.GRAY + Lang.get("overrideCreateAdd"); } else { - return ChatColor.YELLOW + Lang.get("reqSetFail"); + return ChatColor.YELLOW + Lang.get("overrideCreateAdd"); } case 11: return ChatColor.YELLOW + Lang.get("done"); @@ -251,22 +263,34 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } } else { - return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(CK.REQ_FAIL_MESSAGE)+ "\"" - + ChatColor.GRAY + ")"; + String text = "\n"; + LinkedList overrides = new LinkedList(); + overrides.addAll((List) context.getSessionData(CK.REQ_FAIL_MESSAGE)); + for (int i = 0; i < overrides.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + overrides.get(i) + "\n"; + } + return text; } case 11: - case 12: - case 13: - case 14: - case 15: return ""; default: return null; } } + @SuppressWarnings("unchecked") @Override public String getPromptText(ConversationContext context) { + // Checkadd newly made override + if (context.getSessionData(classPrefix + "-override") != null) { + LinkedList overrides = new LinkedList(); + if (context.getSessionData(CK.REQ_FAIL_MESSAGE) != null) { + overrides.addAll((List) context.getSessionData(CK.REQ_FAIL_MESSAGE)); + } + overrides.add((String) context.getSessionData(classPrefix + "-override")); + context.setSessionData(CK.REQ_FAIL_MESSAGE, overrides); + context.setSessionData(classPrefix + "-override", null); + } checkRequirement(context); QuestsEditorPostOpenNumericPromptEvent event @@ -314,7 +338,10 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt { return new CustomRequirementsPrompt(); case 10: if (hasRequirement) { - return new FailMessagePrompt(); + return new OverridePrompt.Builder() + .source(this) + .promptText(Lang.get("overrideCreateEnter")) + .build(); } else { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); return new RequirementsPrompt(plugin, context, factory); @@ -326,7 +353,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt { } } - public void checkRequirement(ConversationContext context) { + public boolean checkRequirement(ConversationContext context) { if (context.getSessionData(CK.REQ_MONEY) != null || context.getSessionData(CK.REQ_QUEST_POINTS) != null || context.getSessionData(CK.REQ_ITEMS) != null @@ -338,7 +365,9 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt { || context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null || context.getSessionData(CK.REQ_CUSTOM) != null) { hasRequirement = true; + return true; } + return false; } private class MoneyPrompt extends StringPrompt { @@ -573,13 +602,13 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt { // Check/add newly made item if (context.getSessionData("newItem") != null) { if (context.getSessionData(CK.REQ_ITEMS) != null) { - List itemRews = getItems(context); - itemRews.add((ItemStack) context.getSessionData("tempStack")); - context.setSessionData(CK.REQ_ITEMS, itemRews); + List itemReqs = getItems(context); + itemReqs.add((ItemStack) context.getSessionData("tempStack")); + context.setSessionData(CK.REQ_ITEMS, itemReqs); } else { - LinkedList itemRews = new LinkedList(); - itemRews.add((ItemStack) context.getSessionData("tempStack")); - context.setSessionData(CK.REQ_ITEMS, itemRews); + LinkedList itemReqs = new LinkedList(); + itemReqs.add((ItemStack) context.getSessionData("tempStack")); + context.setSessionData(CK.REQ_ITEMS, itemReqs); } context.setSessionData("newItem", null); context.setSessionData("tempStack", null); @@ -1162,20 +1191,4 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt { } } } - - private class FailMessagePrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - return ChatColor.YELLOW + Lang.get("reqFailMessagePrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get(Lang.get("cancel"))) == false) { - context.setSessionData(CK.REQ_FAIL_MESSAGE, input); - } - return new RequirementsPrompt(plugin, context, factory); - } - } } diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/RewardsPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/RewardsPrompt.java index 960f40f14..e4ef0aa26 100644 --- a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/RewardsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/RewardsPrompt.java @@ -43,12 +43,15 @@ import me.blackvein.quests.util.MiscUtil; public class RewardsPrompt extends QuestsEditorNumericPrompt { private final Quests plugin; + private final String classPrefix; private final QuestFactory factory; - private final int size = 11; + private boolean hasReward = false; + private final int size = 12; public RewardsPrompt(Quests plugin, ConversationContext context, QuestFactory qf) { super(context, qf); this.plugin = plugin; + this.classPrefix = getClass().getSimpleName(); factory = qf; } @@ -63,6 +66,11 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { public ChatColor getNumberColor(ConversationContext context, int number) { switch (number) { case 1: + if (plugin.getDependencies().getVaultEconomy() != null) { + return ChatColor.BLUE; + } else { + return ChatColor.GRAY; + } case 2: case 3: case 4: @@ -90,6 +98,16 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { case 10: return ChatColor.BLUE; case 11: + if (context.getSessionData(CK.REW_DETAILS_OVERRIDE) == null) { + if (!hasReward) { + return ChatColor.GRAY; + } else { + return ChatColor.BLUE; + } + } else { + return ChatColor.BLUE; + } + case 12: return ChatColor.GREEN; default: return null; @@ -119,6 +137,12 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { case 10: return ChatColor.DARK_PURPLE + Lang.get("rewSetCustom"); case 11: + if (!hasReward) { + return ChatColor.GRAY + Lang.get("overrideCreateAdd"); + } else { + return ChatColor.YELLOW + Lang.get("overrideCreateAdd"); + } + case 12: return ChatColor.YELLOW + Lang.get("done"); default: return null; @@ -129,13 +153,18 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { public String getAdditionalText(ConversationContext context, int number) { switch (number) { case 1: - if (context.getSessionData(CK.REW_MONEY) == null) { - return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + + if (plugin.getDependencies().getVaultEconomy() != null) { + if (context.getSessionData(CK.REW_MONEY) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + int moneyRew = (Integer) context.getSessionData(CK.REW_MONEY); + return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyRew + " " + + (moneyRew > 1 ? plugin.getDependencies().getCurrency(true) + : plugin.getDependencies().getCurrency(false)) + ChatColor.GRAY + ")"; + } } else { - int moneyRew = (Integer) context.getSessionData(CK.REW_MONEY); - return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyRew + " " - + (moneyRew > 1 ? plugin.getDependencies().getCurrency(true) - : plugin.getDependencies().getCurrency(false)) + ChatColor.GRAY + ")"; + return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")"; } case 2: if (context.getSessionData(CK.REW_QUEST_POINTS) == null) { @@ -148,7 +177,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { if (context.getSessionData(CK.REW_ITEMS) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { - String text = ""; + String text = "\n"; LinkedList items = (LinkedList) context.getSessionData(CK.REW_ITEMS); for (int i = 0; i < items.size(); i++) { text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) @@ -167,7 +196,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { if (context.getSessionData(CK.REW_COMMAND) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { - String text = ""; + String text = "\n"; List commands = (List) context.getSessionData(CK.REW_COMMAND); List overrides = (List) context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY); int index = 0; @@ -188,10 +217,20 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { if (context.getSessionData(CK.REW_PERMISSION) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { - String text = ""; + String text = "\n"; List permissions = (List) context.getSessionData(CK.REW_PERMISSION); + List worlds = (List) context.getSessionData(CK.REW_PERMISSION_WORLDS); + int index = 0; for (String perm : permissions) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + perm + "\n"; + text += ChatColor.GRAY + " - " + ChatColor.AQUA + perm; + if (worlds != null) { + if (index < worlds.size()) { + text += ChatColor.GRAY + "[" + ChatColor.DARK_AQUA + worlds.get(index) + + ChatColor.GRAY + "]"; + } + } + text += "\n"; + index++; } return text; } @@ -200,7 +239,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { if (context.getSessionData(CK.REW_MCMMO_SKILLS) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { - String text = ""; + String text = "\n"; List skills = (List) context.getSessionData(CK.REW_MCMMO_SKILLS); List amounts = (List) context.getSessionData(CK.REW_MCMMO_AMOUNTS); for (String skill : skills) { @@ -217,7 +256,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { if (context.getSessionData(CK.REW_HEROES_CLASSES) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { - String text = ""; + String text = "\n"; List heroClasses = (List) context.getSessionData(CK.REW_HEROES_CLASSES); List amounts = (List) context.getSessionData(CK.REW_HEROES_AMOUNTS); for (String heroClass : heroClasses) { @@ -235,7 +274,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { if (context.getSessionData(CK.REW_PHAT_LOOTS) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { - String text = ""; + String text = "\n"; List phatLoots = (List) context.getSessionData(CK.REW_PHAT_LOOTS); for (String phatLoot : phatLoots) { text += ChatColor.GRAY + " - " + ChatColor.AQUA + phatLoot + "\n"; @@ -249,7 +288,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { if (context.getSessionData(CK.REW_CUSTOM) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { - String text = ""; + String text = "\n"; LinkedList customRews = (LinkedList) context.getSessionData(CK.REW_CUSTOM); for (String s : customRews) { text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s @@ -258,18 +297,43 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { return text; } case 11: + if (context.getSessionData(CK.REW_DETAILS_OVERRIDE) == null) { + if (!hasReward) { + return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")"; + } else { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } + } else { + String text = "\n"; + LinkedList overrides = new LinkedList(); + overrides.addAll((List) context.getSessionData(CK.REW_DETAILS_OVERRIDE)); + for (int i = 0; i < overrides.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + overrides.get(i) + "\n"; + } + return text; + } case 12: - case 13: - case 14: - case 15: return ""; default: return null; } } + @SuppressWarnings("unchecked") @Override public String getPromptText(ConversationContext context) { + // Check/add newly made override + if (context.getSessionData(classPrefix + "-override") != null) { + LinkedList overrides = new LinkedList(); + if (context.getSessionData(CK.REW_DETAILS_OVERRIDE) != null) { + overrides.addAll((List) context.getSessionData(CK.REW_DETAILS_OVERRIDE)); + } + overrides.add((String) context.getSessionData(classPrefix + "-override")); + context.setSessionData(CK.REW_DETAILS_OVERRIDE, overrides); + context.setSessionData(classPrefix + "-override", null); + } + checkReward(context); + QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, factory, this); plugin.getServer().getPluginManager().callEvent(event); @@ -288,7 +352,11 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { protected Prompt acceptValidatedInput(ConversationContext context, Number input) { switch (input.intValue()) { case 1: - return new MoneyPrompt(); + if (plugin.getDependencies().getVaultEconomy() != null) { + return new MoneyPrompt(); + } else { + return new RewardsPrompt(plugin, context, factory); + } case 2: return new QuestPointsPrompt(); case 3: @@ -296,9 +364,9 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { case 4: return new ExperiencePrompt(); case 5: - return new CommandsListPrompt(); + return new CommandsPrompt(); case 6: - return new PermissionsPrompt(); + return new PermissionsListPrompt(context, factory); case 7: if (plugin.getDependencies().getMcmmoClassic() != null) { return new mcMMOListPrompt(); @@ -320,11 +388,38 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { case 10: return new CustomRewardsPrompt(); case 11: + if (hasReward) { + return new OverridePrompt.Builder() + .source(this) + .promptText(Lang.get("overrideCreateEnter")) + .build(); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); + return new RewardsPrompt(plugin, context, factory); + } + case 12: return factory.returnToMenu(context); default: return null; } } + + public boolean checkReward(ConversationContext context) { + if (context.getSessionData(CK.REW_MONEY) != null + || context.getSessionData(CK.REW_EXP) != null + || context.getSessionData(CK.REW_QUEST_POINTS) != null + || context.getSessionData(CK.REW_ITEMS) != null + || context.getSessionData(CK.REW_COMMAND) != null + || context.getSessionData(CK.REW_PERMISSION) != null + || context.getSessionData(CK.REW_MCMMO_SKILLS) != null + || context.getSessionData(CK.REW_HEROES_CLASSES) != null + || context.getSessionData(CK.REW_PHAT_LOOTS) != null + || context.getSessionData(CK.REW_CUSTOM) != null) { + hasReward = true; + return true; + } + return false; + } private class MoneyPrompt extends StringPrompt { @@ -494,81 +589,6 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { return (List) context.getSessionData(CK.REW_ITEMS); } } - - private class CommandsListPrompt extends FixedSetPrompt { - - public CommandsListPrompt() { - super("1", "2", "3", "4"); - } - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.GOLD + "- " + Lang.get("rewCommands") + " -\n"; - if (context.getSessionData(CK.REW_COMMAND) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("rewSetCommands") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - " - + Lang.get("rewSetCommandsOverrides") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.RED + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("clear") + "\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("done"); - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("rewSetCommands") + "\n"; - for (String s : getCommand(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - if (context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("rewSetCommandsOverrides") + " (" + Lang.get("stageEditorOptional") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("rewSetCommandsOverrides") + "\n"; - for (String s : getCommandOverrideDisplay(context)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - } - text += ChatColor.RED + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("clear") + "\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " - + Lang.get("done"); - } - return text; - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { - return new CommandsPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(CK.REW_COMMAND) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("rewNoCommands")); - return new CommandsListPrompt(); - } else { - return new CommandsOverrideDisplayPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("rewCommandsCleared")); - context.setSessionData(CK.REW_COMMAND, null); - context.setSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY, null); - return new CommandsListPrompt(); - } else if (input.equalsIgnoreCase("4")) { - return new RewardsPrompt(plugin, context, factory); - } - return null; - } - - @SuppressWarnings("unchecked") - private List getCommand(ConversationContext context) { - return (List) context.getSessionData(CK.REW_COMMAND); - } - - @SuppressWarnings("unchecked") - private List getCommandOverrideDisplay(ConversationContext context) { - return (List) context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY); - } - } private class CommandsPrompt extends StringPrompt { @@ -597,37 +617,137 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { context.setSessionData(CK.REW_COMMAND, null); } - return new CommandsListPrompt(); + return new RewardsPrompt(plugin, context, factory); } } - private class CommandsOverrideDisplayPrompt extends StringPrompt { + private class PermissionsListPrompt extends QuestsEditorNumericPrompt { + + public PermissionsListPrompt(ConversationContext context, QuestFactory factory) { + super(context, factory); + } + + private final int size = 4; + + @Override + public int getSize() { + return size; + } + + @Override + public String getTitle(ConversationContext context) { + return Lang.get("permissionRewardsTitle"); + } + + @Override + public ChatColor getNumberColor(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.BLUE; + case 2: + if (context.getSessionData(CK.REW_PERMISSION) == null) { + return ChatColor.GRAY; + } else { + return ChatColor.BLUE; + } + case 3: + return ChatColor.RED; + case 4: + return ChatColor.GREEN; + default: + return null; + } + } + + @Override + public String getSelectionText(ConversationContext context, int number) { + switch (number) { + case 1: + return ChatColor.YELLOW + Lang.get("rewSetPermission"); + case 2: + if (context.getSessionData(CK.REW_PERMISSION) == null) { + return ChatColor.GRAY + Lang.get("rewSetPermissionWorlds"); + } else { + return ChatColor.YELLOW + Lang.get("rewSetPermissionWorlds"); + } + case 3: + return ChatColor.RED + Lang.get("clear"); + case 4: + return ChatColor.GREEN + Lang.get("done"); + default: + return null; + } + } + + @SuppressWarnings("unchecked") + @Override + public String getAdditionalText(ConversationContext context, int number) { + switch (number) { + case 1: + if (context.getSessionData(CK.REW_PERMISSION) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = "\n"; + for (String s : (List) context.getSessionData(CK.REW_PERMISSION)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; + } + return text; + } + case 2: + if (context.getSessionData(CK.REW_PERMISSION) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + if (context.getSessionData(CK.REW_PERMISSION_WORLDS) == null) { + return ChatColor.YELLOW + "(" + Lang.get("stageEditorOptional") + ")"; + } else { + String text = "\n"; + for (String s : (List) context.getSessionData(CK.REW_PERMISSION_WORLDS)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; + } + return text; + } + } + case 3: + case 4: + return ""; + default: + return null; + } + } @Override public String getPromptText(ConversationContext context) { - String text = ChatColor.YELLOW + Lang.get("rewCommandsOverridePrompt") + "\n"; - text += ChatColor.ITALIC + "" + ChatColor.GOLD + Lang.get("rewCommandsOverrideHint"); + QuestsEditorPostOpenNumericPromptEvent event + = new QuestsEditorPostOpenNumericPromptEvent(context, factory, this); + plugin.getServer().getPluginManager().callEvent(event); + + String text = ChatColor.GOLD + getTitle(context) + "\n"; + for (int i = 1; i <= size; i++) { + text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n"; + } return text; } @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false - && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - String[] args = input.split(Lang.get("charSemi")); - List overrides = new LinkedList(); - for (String s : args) { - if (s.startsWith("/")) { - s = s.substring(1); - } - overrides.add(s); - } - context.setSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY, overrides.isEmpty() ? null : overrides); - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY, null); + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + switch (input.intValue()) { + case 1: + return new PermissionsPrompt(); + case 2: + return new PermissionsWorldsPrompt(); + case 3: + context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("rewPermissionsCleared")); + context.setSessionData(CK.REW_PERMISSION, null); + context.setSessionData(CK.REW_PERMISSION_WORLDS, null); + return new PermissionsListPrompt(context, factory); + case 4: + return new RewardsPrompt(plugin, context, factory); + default: + return null; } - return new CommandsListPrompt(); } + } private class PermissionsPrompt extends StringPrompt { @@ -648,7 +768,36 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { context.setSessionData(CK.REW_PERMISSION, null); } - return new RewardsPrompt(plugin, context, factory); + return new PermissionsListPrompt(context, factory); + } + } + + private class PermissionsWorldsPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("rewPermissionsWorldPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false + && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { + String[] args = input.split(Lang.get("charSemi")); + List worlds = new LinkedList(); + worlds.addAll(Arrays.asList(args)); + for (String w : worlds) { + if (!w.equals("null") && w != null && plugin.getServer().getWorld(w) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + w + " " + + Lang.get("eventEditorInvalidWorld")); + return new PermissionsWorldsPrompt(); + } + } + context.setSessionData(CK.REW_PERMISSION_WORLDS, worlds); + } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { + context.setSessionData(CK.REW_PERMISSION_WORLDS, null); + } + return new PermissionsListPrompt(context, factory); } } diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/StageMainPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/StageMainPrompt.java index 931d3ffcc..7f996702e 100644 --- a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/StageMainPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/StageMainPrompt.java @@ -44,7 +44,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { private final Quests plugin; private final int stageNum; - private final String pref; + private final String stagePrefix; + private final String classPrefix; private final QuestFactory factory; private boolean hasObjective = false; private final int size = 16; @@ -53,7 +54,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { super(context, qf); this.plugin = plugin; this.stageNum = stageNum; - this.pref = "stage" + stageNum; + this.stagePrefix = "stage" + stageNum; + this.classPrefix = getClass().getSimpleName(); this.factory = qf; } @@ -93,13 +95,13 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return ChatColor.BLUE; } case 11: - if (context.getSessionData(pref + CK.S_DELAY) == null) { + if (context.getSessionData(stagePrefix + CK.S_DELAY) == null) { return ChatColor.GRAY; } else { return ChatColor.BLUE; } case 12: - if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) { + if (context.getSessionData(stagePrefix + CK.S_START_MESSAGE) == null) { if (!hasObjective) { return ChatColor.GRAY; } else { @@ -109,7 +111,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return ChatColor.BLUE; } case 13: - if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) { + if (context.getSessionData(stagePrefix + CK.S_COMPLETE_MESSAGE) == null) { if (!hasObjective) { return ChatColor.GRAY; } else { @@ -119,7 +121,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return ChatColor.BLUE; } case 14: - if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) { + if (context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY) == null) { if (!hasObjective) { return ChatColor.GRAY; } else { @@ -168,13 +170,13 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return ChatColor.YELLOW + Lang.get("delay"); } case 11: - if (context.getSessionData(pref + CK.S_DELAY) == null) { + if (context.getSessionData(stagePrefix + CK.S_DELAY) == null) { return ChatColor.GRAY + Lang.get("stageEditorDelayMessage"); } else { return ChatColor.YELLOW + Lang.get("stageEditorDelayMessage"); } case 12: - if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) { + if (context.getSessionData(stagePrefix + CK.S_START_MESSAGE) == null) { if (!hasObjective) { return ChatColor.GRAY + Lang.get("stageEditorStartMessage"); } else { @@ -184,7 +186,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return ChatColor.YELLOW + Lang.get("stageEditorStartMessage"); } case 13: - if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) { + if (context.getSessionData(stagePrefix + CK.S_COMPLETE_MESSAGE) == null) { if (!hasObjective) { return ChatColor.GRAY + Lang.get("stageEditorCompleteMessage"); } else { @@ -194,14 +196,14 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return ChatColor.YELLOW + Lang.get("stageEditorCompleteMessage"); } case 14: - if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) { + if (context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY) == null) { if (!hasObjective) { - return ChatColor.GRAY + Lang.get("stageEditorObjectiveOverride"); + return ChatColor.GRAY + Lang.get("overrideCreateAdd"); } else { - return ChatColor.YELLOW + Lang.get("stageEditorObjectiveOverride"); + return ChatColor.YELLOW + Lang.get("overrideCreateAdd"); } } else { - return ChatColor.YELLOW + Lang.get("stageEditorObjectiveOverride"); + return ChatColor.YELLOW + Lang.get("overrideCreateAdd"); } case 15: return ChatColor.RED + Lang.get("stageEditorDelete"); @@ -216,52 +218,52 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { public String getAdditionalText(ConversationContext context, int number) { switch (number) { case 1: - if (context.getSessionData(pref + CK.S_BREAK_NAMES) == null - && context.getSessionData(pref + CK.S_DAMAGE_NAMES) == null - && context.getSessionData(pref + CK.S_PLACE_NAMES) == null - && context.getSessionData(pref + CK.S_USE_NAMES) == null - && context.getSessionData(pref + CK.S_CUT_NAMES) == null) { + if (context.getSessionData(stagePrefix + CK.S_BREAK_NAMES) == null + && context.getSessionData(stagePrefix + CK.S_DAMAGE_NAMES) == null + && context.getSessionData(stagePrefix + CK.S_PLACE_NAMES) == null + && context.getSessionData(stagePrefix + CK.S_USE_NAMES) == null + && context.getSessionData(stagePrefix + CK.S_CUT_NAMES) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } case 2: - if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null - && context.getSessionData(pref + CK.S_SMELT_ITEMS) == null - && context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null - && context.getSessionData(pref + CK.S_BREW_ITEMS) == null) { + if (context.getSessionData(stagePrefix + CK.S_CRAFT_ITEMS) == null + && context.getSessionData(stagePrefix + CK.S_SMELT_ITEMS) == null + && context.getSessionData(stagePrefix + CK.S_ENCHANT_TYPES) == null + && context.getSessionData(stagePrefix + CK.S_BREW_ITEMS) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } case 3: - 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) { + if (context.getSessionData(stagePrefix + CK.S_DELIVERY_NPCS) == null + && context.getSessionData(stagePrefix + CK.S_NPCS_TO_TALK_TO) == null + && context.getSessionData(stagePrefix + CK.S_NPCS_TO_KILL) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } case 4: - if (context.getSessionData(pref + CK.S_MOB_TYPES) == null - && context.getSessionData(pref + CK.S_FISH) == null - && context.getSessionData(pref + CK.S_TAME_TYPES) == null - && context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { + if (context.getSessionData(stagePrefix + CK.S_MOB_TYPES) == null + && context.getSessionData(stagePrefix + CK.S_FISH) == null + && context.getSessionData(stagePrefix + CK.S_TAME_TYPES) == null + && context.getSessionData(stagePrefix + CK.S_SHEAR_COLORS) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } case 5: - if (context.getSessionData(pref + CK.S_PLAYER_KILL) == null) { + if (context.getSessionData(stagePrefix + CK.S_PLAYER_KILL) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { - Integer players = (Integer) context.getSessionData(pref + CK.S_PLAYER_KILL); + Integer players = (Integer) context.getSessionData(stagePrefix + CK.S_PLAYER_KILL); return ChatColor.GRAY + "(" + ChatColor.AQUA + players + " " + Lang.get("stageEditorPlayers") + ChatColor.GRAY + ")"; } case 6: - if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) == null) { + if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { String text = "\n"; LinkedList locations - = (LinkedList) context.getSessionData(pref + CK.S_REACH_LOCATIONS); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS); LinkedList radii - = (LinkedList) context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_RADIUS); LinkedList names - = (LinkedList) context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_NAMES); for (int i = 0; i < locations.size(); i++) { text += ChatColor.GRAY + " - " + Lang.get("stageEditorReachRadii1") + " " + ChatColor.BLUE + radii.get(i) + ChatColor.GRAY + " " + Lang.get("stageEditorReachRadii2") + " " @@ -271,14 +273,14 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return text; } case 7: - if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) == null) { + if (context.getSessionData(stagePrefix + CK.S_PASSWORD_PHRASES) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { String text = "\n"; LinkedList> passPhrases - = (LinkedList>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES); + = (LinkedList>) context.getSessionData(stagePrefix + CK.S_PASSWORD_PHRASES); LinkedList passDisplays - = (LinkedList) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_PASSWORD_DISPLAYS); for (int i = 0; i < passPhrases.size(); i++) { text += ChatColor.AQUA + " - \"" + passDisplays.get(i) + "\"\n"; LinkedList phrases = passPhrases.get(i); @@ -289,12 +291,12 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return text; } case 8: - if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) == null) { + if (context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { String text = "\n"; LinkedList customObjs - = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES); for (String s : customObjs) { text += ChatColor.LIGHT_PURPLE + " - " + ChatColor.GOLD + s + "\n"; } @@ -308,24 +310,24 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { if (!hasObjective) { return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")"; } else { - if (context.getSessionData(pref + CK.S_DELAY) == null) { + if (context.getSessionData(stagePrefix + CK.S_DELAY) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { - long time = (Long) context.getSessionData(pref + CK.S_DELAY); + long time = (Long) context.getSessionData(stagePrefix + CK.S_DELAY); return ChatColor.GRAY + "(" + ChatColor.AQUA + MiscUtil.getTime(time) + ChatColor.GRAY + ")"; } } case 11: - if (context.getSessionData(pref + CK.S_DELAY) == null) { + if (context.getSessionData(stagePrefix + CK.S_DELAY) == null) { return ChatColor.GRAY + "(" + Lang.get("noDelaySet") + ")"; - } else if (context.getSessionData(pref + CK.S_DELAY_MESSAGE) == null) { + } else if (context.getSessionData(stagePrefix + CK.S_DELAY_MESSAGE) == null) { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" - + context.getSessionData(pref + CK.S_DELAY_MESSAGE) + "\"" + ChatColor.GRAY + ")"; + + context.getSessionData(stagePrefix + CK.S_DELAY_MESSAGE) + "\"" + ChatColor.GRAY + ")"; } case 12: - if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) { + if (context.getSessionData(stagePrefix + CK.S_START_MESSAGE) == null) { if (!hasObjective) { return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")"; } else { @@ -333,10 +335,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { } } else { return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" - + context.getSessionData(pref + CK.S_START_MESSAGE) + "\"" + ChatColor.GRAY + ")"; + + context.getSessionData(stagePrefix + CK.S_START_MESSAGE) + "\"" + ChatColor.GRAY + ")"; } case 13: - if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) { + if (context.getSessionData(stagePrefix + CK.S_COMPLETE_MESSAGE) == null) { if (!hasObjective) { return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")"; } else { @@ -344,18 +346,23 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { } } else { return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" - + context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) + "\"" + ChatColor.GRAY + ")"; + + context.getSessionData(stagePrefix + CK.S_COMPLETE_MESSAGE) + "\"" + ChatColor.GRAY + ")"; } case 14: - if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) { + if (context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY) == null) { if (!hasObjective) { return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")"; } else { return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } } else { - return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" - + context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) + "\"" + ChatColor.GRAY + ")"; + String text = "\n"; + LinkedList overrides = new LinkedList(); + overrides.addAll((List) context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY)); + for (int i = 0; i < overrides.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + overrides.get(i) + "\n"; + } + return text; } case 15: case 16: @@ -365,9 +372,20 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { } } + @SuppressWarnings("unchecked") @Override public String getPromptText(ConversationContext context) { - context.setSessionData(pref, Boolean.TRUE); + // Check/add newly made override + if (context.getSessionData(classPrefix + "-override") != null) { + LinkedList overrides = new LinkedList(); + if (context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY) != null) { + overrides.addAll((List) context.getSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY)); + } + overrides.add((String) context.getSessionData(classPrefix + "-override")); + context.setSessionData(stagePrefix + CK.S_OVERRIDE_DISPLAY, overrides); + context.setSessionData(classPrefix + "-override", null); + } + context.setSessionData(stagePrefix, Boolean.TRUE); checkObjective(context); QuestsEditorPostOpenNumericPromptEvent event @@ -417,7 +435,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return new StageMainPrompt(plugin, stageNum, context, factory); } case 11: - if (context.getSessionData(pref + CK.S_DELAY) == null) { + if (context.getSessionData(stagePrefix + CK.S_DELAY) == null) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDelaySet")); return new StageMainPrompt(plugin, stageNum, context, factory); } else { @@ -439,7 +457,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { } case 14: if (hasObjective) { - return new OverrideDisplayPrompt(); + return new OverridePrompt.Builder() + .source(this) + .promptText(Lang.get("overrideCreateEnter")) + .build(); } else { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption")); return new StageMainPrompt(plugin, stageNum, context, factory); @@ -453,43 +474,31 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { } } - public void checkObjective(ConversationContext context) { - if (context.getSessionData(pref + CK.S_BREAK_NAMES) != null - || context.getSessionData(pref + CK.S_DAMAGE_NAMES) != null - || context.getSessionData(pref + CK.S_PLACE_NAMES) != null - || context.getSessionData(pref + CK.S_USE_NAMES) != null - || context.getSessionData(pref + CK.S_CUT_NAMES) != null) { - hasObjective = true; - } - if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) != null - || context.getSessionData(pref + CK.S_SMELT_ITEMS) != null - || context.getSessionData(pref + CK.S_ENCHANT_TYPES) != null - || context.getSessionData(pref + CK.S_BREW_ITEMS) != null) { - hasObjective = true; - } - 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) { - hasObjective = true; - } - if (context.getSessionData(pref + CK.S_MOB_TYPES) != null - || context.getSessionData(pref + CK.S_FISH) != null - || context.getSessionData(pref + CK.S_TAME_TYPES) != null - || context.getSessionData(pref + CK.S_SHEAR_COLORS) != null) { - hasObjective = true; - } - if (context.getSessionData(pref + CK.S_PLAYER_KILL) != null) { - hasObjective = true; - } - if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) != null) { - hasObjective = true; - } - if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) != null) { - hasObjective = true; - } - if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) != null) { + public boolean checkObjective(ConversationContext context) { + if (context.getSessionData(stagePrefix + CK.S_BREAK_NAMES) != null + || context.getSessionData(stagePrefix + CK.S_DAMAGE_NAMES) != null + || context.getSessionData(stagePrefix + CK.S_PLACE_NAMES) != null + || context.getSessionData(stagePrefix + CK.S_USE_NAMES) != null + || context.getSessionData(stagePrefix + CK.S_CUT_NAMES) != null + || context.getSessionData(stagePrefix + CK.S_CRAFT_ITEMS) != null + || context.getSessionData(stagePrefix + CK.S_SMELT_ITEMS) != null + || context.getSessionData(stagePrefix + CK.S_ENCHANT_TYPES) != null + || context.getSessionData(stagePrefix + CK.S_BREW_ITEMS) != null + || context.getSessionData(stagePrefix + CK.S_DELIVERY_NPCS) != null + || context.getSessionData(stagePrefix + CK.S_NPCS_TO_TALK_TO) != null + || context.getSessionData(stagePrefix + CK.S_NPCS_TO_KILL) != null + || context.getSessionData(stagePrefix + CK.S_MOB_TYPES) != null + || context.getSessionData(stagePrefix + CK.S_FISH) != null + || context.getSessionData(stagePrefix + CK.S_TAME_TYPES) != null + || context.getSessionData(stagePrefix + CK.S_SHEAR_COLORS) != null + || context.getSessionData(stagePrefix + CK.S_PLAYER_KILL) != null + || context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS) != null + || context.getSessionData(stagePrefix + CK.S_PASSWORD_PHRASES) != null + || context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES) != null) { hasObjective = true; + return true; } + return false; } private class PasswordListPrompt extends FixedSetPrompt { @@ -501,7 +510,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @Override public String getPromptText(ConversationContext context) { String text = ChatColor.GOLD + "- " + Lang.get("stageEditorPassword") + "-\n"; - if (context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) == null) { + if (context.getSessionData(stagePrefix + CK.S_PASSWORD_DISPLAYS) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorAddPasswordDisplay") + " (" + Lang.get("noneSet") + ")\n"; text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - " @@ -516,7 +525,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { for (String display : getPasswordDisplays(context)) { text += ChatColor.GRAY + " - " + ChatColor.AQUA + display + "\n"; } - if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) == null) { + if (context.getSessionData(stagePrefix + CK.S_PASSWORD_PHRASES) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorAddPasswordPhrases") + " (" + Lang.get("noneSet") + ")\n"; } else { @@ -547,7 +556,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { if (input.equalsIgnoreCase("1")) { return new PasswordDisplayPrompt(); } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) == null) { + if (context.getSessionData(stagePrefix + CK.S_PASSWORD_DISPLAYS) == null) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorMustSetPasswordDisplays")); return new PasswordListPrompt(); } else { @@ -555,19 +564,19 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { } } else if (input.equalsIgnoreCase("3")) { context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorObjectiveCleared")); - context.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, null); - context.setSessionData(pref + CK.S_PASSWORD_PHRASES, null); + context.setSessionData(stagePrefix + CK.S_PASSWORD_DISPLAYS, null); + context.setSessionData(stagePrefix + CK.S_PASSWORD_PHRASES, null); return new PasswordListPrompt(); } else if (input.equalsIgnoreCase("4")) { int one; int two; - if (context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) != null) { - one = ((List) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS)).size(); + if (context.getSessionData(stagePrefix + CK.S_PASSWORD_DISPLAYS) != null) { + one = ((List) context.getSessionData(stagePrefix + CK.S_PASSWORD_DISPLAYS)).size(); } else { one = 0; } - if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) != null) { - two = ((LinkedList>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES)) + if (context.getSessionData(stagePrefix + CK.S_PASSWORD_PHRASES) != null) { + two = ((LinkedList>) context.getSessionData(stagePrefix + CK.S_PASSWORD_PHRASES)) .size(); } else { two = 0; @@ -584,12 +593,12 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @SuppressWarnings("unchecked") private List getPasswordDisplays(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS); + return (List) context.getSessionData(stagePrefix + CK.S_PASSWORD_DISPLAYS); } @SuppressWarnings("unchecked") private LinkedList> getPasswordPhrases(ConversationContext context) { - return (LinkedList>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES); + return (LinkedList>) context.getSessionData(stagePrefix + CK.S_PASSWORD_PHRASES); } } @@ -597,23 +606,21 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @Override public String getPromptText(ConversationContext context) { - String text = ChatColor.YELLOW + Lang.get("stageEditorPasswordDisplayPrompt") + "\n"; - text += ChatColor.ITALIC + "" + ChatColor.GOLD + Lang.get("stageEditorPasswordDisplayHint"); - return text; + return ChatColor.YELLOW + Lang.get("stageEditorPasswordDisplayPrompt") + "\n"; } @Override public Prompt acceptInput(ConversationContext context, String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - if (context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS) != null) { + if (context.getSessionData(stagePrefix + CK.S_PASSWORD_DISPLAYS) != null) { @SuppressWarnings("unchecked") - List displays = (List) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS); + List displays = (List) context.getSessionData(stagePrefix + CK.S_PASSWORD_DISPLAYS); displays.add(input); - context.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, displays); + context.setSessionData(stagePrefix + CK.S_PASSWORD_DISPLAYS, displays); } else { List displays = new LinkedList(); displays.add(input); - context.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, displays); + context.setSessionData(stagePrefix + CK.S_PASSWORD_DISPLAYS, displays); } } return new PasswordListPrompt(); @@ -624,56 +631,32 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @Override public String getPromptText(ConversationContext context) { - String text = ChatColor.YELLOW + Lang.get("stageEditorPasswordPhrasePrompt") + "\n"; - text += ChatColor.ITALIC + "" + ChatColor.GOLD + Lang.get("stageEditorPasswordPhraseHint"); - return text; + return ChatColor.YELLOW + Lang.get("stageEditorPasswordPhrasePrompt") + "\n"; } @Override public Prompt acceptInput(ConversationContext context, String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) != null) { + if (context.getSessionData(stagePrefix + CK.S_PASSWORD_PHRASES) != null) { @SuppressWarnings("unchecked") LinkedList> phrases - = (LinkedList>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES); + = (LinkedList>) context.getSessionData(stagePrefix + CK.S_PASSWORD_PHRASES); LinkedList newPhrases = new LinkedList(); newPhrases.addAll(Arrays.asList(input.split(Lang.get("charSemi")))); phrases.add(newPhrases); - context.setSessionData(pref + CK.S_PASSWORD_PHRASES, phrases); + context.setSessionData(stagePrefix + CK.S_PASSWORD_PHRASES, phrases); } else { LinkedList> phrases = new LinkedList>(); LinkedList newPhrases = new LinkedList(); newPhrases.addAll(Arrays.asList(input.split(Lang.get("charSemi")))); phrases.add(newPhrases); - context.setSessionData(pref + CK.S_PASSWORD_PHRASES, phrases); + context.setSessionData(stagePrefix + CK.S_PASSWORD_PHRASES, phrases); } } return new PasswordListPrompt(); } } - private class OverrideDisplayPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.YELLOW + Lang.get("stageEditorObjectiveOverridePrompt") + "\n"; - text += ChatColor.ITALIC + "" + ChatColor.GOLD + Lang.get("stageEditorObjectiveOverrideHint"); - return text; - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false - && input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - context.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, input); - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, null); - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorObjectiveOverrideCleared")); - } - return new StageMainPrompt(plugin, stageNum, context, factory); - } - } - private class KillPlayerPrompt extends StringPrompt { @Override @@ -691,7 +674,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorPositiveAmount")); return new KillPlayerPrompt(); } else if (i > 0) { - context.setSessionData(pref + CK.S_PLAYER_KILL, i); + context.setSessionData(stagePrefix + CK.S_PLAYER_KILL, i); } } catch (NumberFormatException e) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber") @@ -699,7 +682,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return new KillPlayerPrompt(); } } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_PLAYER_KILL, null); + context.setSessionData(stagePrefix + CK.S_PLAYER_KILL, null); } return new StageMainPrompt(plugin, stageNum, context, factory); } @@ -714,7 +697,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @Override public String getPromptText(ConversationContext context) { String text = ChatColor.GOLD + "- " + Lang.get("stageEditorReachLocs") + " -\n"; - if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) == null) { + if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetLocations") + " (" + Lang.get("noneSet") + ")\n"; text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - " @@ -731,7 +714,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { for (String s : getLocations(context)) { text += ChatColor.GRAY + " - " + ChatColor.DARK_AQUA + s + "\n"; } - if (context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS) == null) { + if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_RADIUS) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorSetLocationRadii") + " (" + Lang.get("noneSet") + ")\n"; } else { @@ -741,7 +724,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n"; } } - if (context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES) == null) { + if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_NAMES) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorSetLocationNames") + " (" + Lang.get("noneSet") + ")\n"; } else { @@ -768,14 +751,14 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { factory.setSelectedReachLocations(temp); return new ReachLocationPrompt(); } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) == null) { + if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS) == null) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoLocations")); return new ReachListPrompt(); } else { return new ReachRadiiPrompt(); } } else if (input.equalsIgnoreCase("3")) { - if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) == null) { + if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS) == null) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoLocations")); return new ReachListPrompt(); } else { @@ -783,26 +766,26 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { } } else if (input.equalsIgnoreCase("4")) { context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorObjectiveCleared")); - context.setSessionData(pref + CK.S_REACH_LOCATIONS, null); - context.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, null); - context.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, null); + context.setSessionData(stagePrefix + CK.S_REACH_LOCATIONS, null); + context.setSessionData(stagePrefix + CK.S_REACH_LOCATIONS_RADIUS, null); + context.setSessionData(stagePrefix + CK.S_REACH_LOCATIONS_NAMES, null); return new ReachListPrompt(); } else if (input.equalsIgnoreCase("5")) { int one; int two; int three; - if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) != null) { - one = ((List) context.getSessionData(pref + CK.S_REACH_LOCATIONS)).size(); + if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS) != null) { + one = ((List) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS)).size(); } else { one = 0; } - if (context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS) != null) { - two = ((List) context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS)).size(); + if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_RADIUS) != null) { + two = ((List) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_RADIUS)).size(); } else { two = 0; } - if (context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES) != null) { - three = ((List) context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES)).size(); + if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_NAMES) != null) { + three = ((List) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_NAMES)).size(); } else { three = 0; } @@ -819,17 +802,17 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @SuppressWarnings("unchecked") private List getLocations(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_REACH_LOCATIONS); + return (List) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS); } @SuppressWarnings("unchecked") private List getLocationRadii(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS); + return (List) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_RADIUS); } @SuppressWarnings("unchecked") private List getLocationNames(ConversationContext context) { - return (List) context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES); + return (List) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_NAMES); } } @@ -849,13 +832,13 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { if (block != null) { Location loc = block.getLocation(); LinkedList locs; - if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) != null) { - locs = (LinkedList) context.getSessionData(pref + CK.S_REACH_LOCATIONS); + if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS) != null) { + locs = (LinkedList) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS); } else { locs = new LinkedList(); } locs.add(ConfigUtil.getLocationInfo(loc)); - context.setSessionData(pref + CK.S_REACH_LOCATIONS, locs); + context.setSessionData(stagePrefix + CK.S_REACH_LOCATIONS, locs); Map temp = factory.getSelectedReachLocations(); temp.remove(player.getUniqueId()); factory.setSelectedReachLocations(temp); @@ -901,7 +884,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return new ReachRadiiPrompt(); } } - context.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, radii); + context.setSessionData(stagePrefix + CK.S_REACH_LOCATIONS_RADIUS, radii); } return new ReachListPrompt(); } @@ -919,7 +902,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { LinkedList locNames = new LinkedList(); locNames.addAll(Arrays.asList(input.split(Lang.get("charSemi")))); - context.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, locNames); + context.setSessionData(stagePrefix + CK.S_REACH_LOCATIONS_NAMES, locNames); } return new ReachListPrompt(); } @@ -935,63 +918,63 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @Override public String getPromptText(ConversationContext context) { String text = ChatColor.AQUA + "- " + Lang.get("stageEditorStageEvents") + " -\n"; - if (context.getSessionData(pref + CK.S_START_EVENT) == null) { + if (context.getSessionData(stagePrefix + CK.S_START_EVENT) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorStartEvent") + " (" + Lang.get("noneSet") + ")\n"; } else { text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorStartEvent") + " (" + ChatColor.AQUA - + ((String) context.getSessionData(pref + CK.S_START_EVENT)) + ChatColor.YELLOW + ")\n"; + + ((String) context.getSessionData(stagePrefix + CK.S_START_EVENT)) + ChatColor.YELLOW + ")\n"; } - if (context.getSessionData(pref + CK.S_FINISH_EVENT) == null) { + if (context.getSessionData(stagePrefix + CK.S_FINISH_EVENT) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorFinishEvent") + " (" + Lang.get("noneSet") + ")\n"; } else { text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorFinishEvent") + " (" + ChatColor.AQUA - + ((String) context.getSessionData(pref + CK.S_FINISH_EVENT)) + ChatColor.YELLOW + ")\n"; + + ((String) context.getSessionData(stagePrefix + CK.S_FINISH_EVENT)) + ChatColor.YELLOW + ")\n"; } - if (context.getSessionData(pref + CK.S_DEATH_EVENT) == null) { + if (context.getSessionData(stagePrefix + CK.S_DEATH_EVENT) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeathEvent") + " (" + Lang.get("noneSet") + ")\n"; } else { text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeathEvent") + " (" + ChatColor.AQUA - + ((String) context.getSessionData(pref + CK.S_DEATH_EVENT)) + ChatColor.YELLOW + ")\n"; + + ((String) context.getSessionData(stagePrefix + CK.S_DEATH_EVENT)) + ChatColor.YELLOW + ")\n"; } - if (context.getSessionData(pref + CK.S_DISCONNECT_EVENT) == null) { + if (context.getSessionData(stagePrefix + CK.S_DISCONNECT_EVENT) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDisconnectEvent") + " (" + Lang.get("noneSet") + ")\n"; } else { text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDisconnectEvent") + " (" + ChatColor.AQUA - + ((String) context.getSessionData(pref + CK.S_DISCONNECT_EVENT)) + ChatColor.YELLOW + ")\n"; + + ((String) context.getSessionData(stagePrefix + CK.S_DISCONNECT_EVENT)) + ChatColor.YELLOW + ")\n"; } - if (context.getSessionData(pref + CK.S_CHAT_EVENTS) == null) { + if (context.getSessionData(stagePrefix + CK.S_CHAT_EVENTS) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorChatEvents") + " (" + Lang.get("noneSet") + ")\n"; } else { text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorChatEvents") + "\n"; - LinkedList chatEvents = (LinkedList) context.getSessionData(pref + CK.S_CHAT_EVENTS); + LinkedList chatEvents = (LinkedList) context.getSessionData(stagePrefix + CK.S_CHAT_EVENTS); LinkedList chatEventTriggers - = (LinkedList) context.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_CHAT_EVENT_TRIGGERS); for (String event : chatEvents) { text += ChatColor.AQUA + " - " + event + ChatColor.BLUE + " (" + Lang.get("stageEditorTriggeredBy") + ": \"" + chatEventTriggers.get(chatEvents.indexOf(event)) + "\")\n"; } } - if (context.getSessionData(pref + CK.S_COMMAND_EVENTS) == null) { + if (context.getSessionData(stagePrefix + CK.S_COMMAND_EVENTS) == null) { text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorCommandEvents") + " (" + Lang.get("noneSet") + ")\n"; } else { text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorCommandEvents") + "\n"; LinkedList commandEvents - = (LinkedList) context.getSessionData(pref + CK.S_COMMAND_EVENTS); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_COMMAND_EVENTS); LinkedList commandEventTriggers - = (LinkedList) context.getSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_COMMAND_EVENT_TRIGGERS); for (String event : commandEvents) { text += ChatColor.AQUA + " - " + event + ChatColor.BLUE + " (" + Lang.get("stageEditorTriggeredBy") + ": \"" @@ -1057,13 +1040,13 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { + Lang.get("stageEditorInvalidEvent")); return new StartEventPrompt(); } else { - context.setSessionData(pref + CK.S_START_EVENT, found.getName()); + context.setSessionData(stagePrefix + CK.S_START_EVENT, found.getName()); return new EventListPrompt(); } } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { return new EventListPrompt(); } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_START_EVENT, null); + context.setSessionData(stagePrefix + CK.S_START_EVENT, null); player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorStartEventCleared")); return new EventListPrompt(); } else { @@ -1104,13 +1087,13 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { + Lang.get("stageEditorInvalidEvent")); return new FinishEventPrompt(); } else { - context.setSessionData(pref + CK.S_FINISH_EVENT, found.getName()); + context.setSessionData(stagePrefix + CK.S_FINISH_EVENT, found.getName()); return new EventListPrompt(); } } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { return new EventListPrompt(); } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_FINISH_EVENT, null); + context.setSessionData(stagePrefix + CK.S_FINISH_EVENT, null); player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorFinishEventCleared")); return new EventListPrompt(); } else { @@ -1151,13 +1134,13 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { + Lang.get("stageEditorInvalidEvent")); return new DeathEventPrompt(); } else { - context.setSessionData(pref + CK.S_DEATH_EVENT, found.getName()); + context.setSessionData(stagePrefix + CK.S_DEATH_EVENT, found.getName()); return new EventListPrompt(); } } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { return new EventListPrompt(); } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_DEATH_EVENT, null); + context.setSessionData(stagePrefix + CK.S_DEATH_EVENT, null); player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDeathEventCleared")); return new EventListPrompt(); } else { @@ -1198,13 +1181,13 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { + Lang.get("stageEditorInvalidEvent")); return new DisconnectEventPrompt(); } else { - context.setSessionData(pref + CK.S_DISCONNECT_EVENT, found.getName()); + context.setSessionData(stagePrefix + CK.S_DISCONNECT_EVENT, found.getName()); return new EventListPrompt(); } } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { return new EventListPrompt(); } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_DISCONNECT_EVENT, null); + context.setSessionData(stagePrefix + CK.S_DISCONNECT_EVENT, null); player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDisconnectEventCleared")); return new EventListPrompt(); } else { @@ -1245,14 +1228,14 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { + Lang.get("stageEditorInvalidEvent")); return new ChatEventPrompt(); } else { - context.setSessionData(pref + CK.S_CHAT_TEMP_EVENT, found.getName()); + context.setSessionData(stagePrefix + CK.S_CHAT_TEMP_EVENT, found.getName()); return new ChatEventTriggerPrompt(); } } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { return new EventListPrompt(); } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_CHAT_EVENTS, null); - context.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, null); + context.setSessionData(stagePrefix + CK.S_CHAT_EVENTS, null); + context.setSessionData(stagePrefix + CK.S_CHAT_EVENT_TRIGGERS, null); player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorChatEventsCleared")); return new EventListPrompt(); } else { @@ -1265,10 +1248,11 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @Override public String getPromptText(ConversationContext context) { - String tempEvent = (String) context.getSessionData(pref + CK.S_CHAT_TEMP_EVENT); + String tempEvent = (String) context.getSessionData(stagePrefix + CK.S_CHAT_TEMP_EVENT); String text = ChatColor.GOLD + "- " + Lang.get("stageEditorChatTrigger") + " -\n"; - text += Lang.get("stageEditorChatEventsTriggerPrompt").replace("", tempEvent) - .replace("", tempEvent); + text += ChatColor.YELLOW + Lang.get("stageEditorChatEventsTriggerPrompt") + .replace("", ChatColor.AQUA + tempEvent + ChatColor.YELLOW) + .replace("", ChatColor.AQUA + tempEvent + ChatColor.YELLOW); return text; } @@ -1276,25 +1260,25 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @Override public Prompt acceptInput(ConversationContext context, String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - if (context.getSessionData(pref + CK.S_CHAT_EVENTS) == null) { + if (context.getSessionData(stagePrefix + CK.S_CHAT_EVENTS) == null) { LinkedList chatEvents = new LinkedList(); LinkedList chatEventTriggers = new LinkedList(); - String event = (String) context.getSessionData(pref + CK.S_CHAT_TEMP_EVENT); + String event = (String) context.getSessionData(stagePrefix + CK.S_CHAT_TEMP_EVENT); chatEvents.add(event); chatEventTriggers.add(input.trim()); - context.setSessionData(pref + CK.S_CHAT_EVENTS, chatEvents); - context.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, chatEventTriggers); + context.setSessionData(stagePrefix + CK.S_CHAT_EVENTS, chatEvents); + context.setSessionData(stagePrefix + CK.S_CHAT_EVENT_TRIGGERS, chatEventTriggers); return new EventListPrompt(); } else { LinkedList chatEvents - = (LinkedList) context.getSessionData(pref + CK.S_CHAT_EVENTS); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_CHAT_EVENTS); LinkedList chatEventTriggers - = (LinkedList) context.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS); - String event = (String) context.getSessionData(pref + CK.S_CHAT_TEMP_EVENT); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_CHAT_EVENT_TRIGGERS); + String event = (String) context.getSessionData(stagePrefix + CK.S_CHAT_TEMP_EVENT); chatEvents.add(event); chatEventTriggers.add(input.trim()); - context.setSessionData(pref + CK.S_CHAT_EVENTS, chatEvents); - context.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, chatEventTriggers); + context.setSessionData(stagePrefix + CK.S_CHAT_EVENTS, chatEvents); + context.setSessionData(stagePrefix + CK.S_CHAT_EVENT_TRIGGERS, chatEventTriggers); return new EventListPrompt(); } } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { @@ -1337,14 +1321,14 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { + Lang.get("stageEditorInvalidEvent")); return new CommandEventPrompt(); } else { - context.setSessionData(pref + CK.S_COMMAND_TEMP_EVENT, found.getName()); + context.setSessionData(stagePrefix + CK.S_COMMAND_TEMP_EVENT, found.getName()); return new CommandEventTriggerPrompt(); } } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { return new EventListPrompt(); } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_COMMAND_EVENTS, null); - context.setSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS, null); + context.setSessionData(stagePrefix + CK.S_COMMAND_EVENTS, null); + context.setSessionData(stagePrefix + CK.S_COMMAND_EVENT_TRIGGERS, null); player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorCommandEventsCleared")); return new EventListPrompt(); } else { @@ -1357,10 +1341,11 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @Override public String getPromptText(ConversationContext context) { - String tempEvent = (String) context.getSessionData(pref + CK.S_COMMAND_TEMP_EVENT); + String tempEvent = (String) context.getSessionData(stagePrefix + CK.S_COMMAND_TEMP_EVENT); String text = ChatColor.GOLD + "- " + Lang.get("stageEditorCommandTrigger") + " -\n"; - text += Lang.get("stageEditorCommandEventsTriggerPrompt").replace("", tempEvent) - .replace("", tempEvent); + text += ChatColor.YELLOW + Lang.get("stageEditorCommandEventsTriggerPrompt") + .replace("", ChatColor.AQUA + tempEvent + ChatColor.YELLOW) + .replace("", ChatColor.AQUA + tempEvent + ChatColor.YELLOW); return text; } @@ -1368,25 +1353,25 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @Override public Prompt acceptInput(ConversationContext context, String input) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - if (context.getSessionData(pref + CK.S_COMMAND_EVENTS) == null) { + if (context.getSessionData(stagePrefix + CK.S_COMMAND_EVENTS) == null) { LinkedList commandEvents = new LinkedList(); LinkedList commandEventTriggers = new LinkedList(); - String event = (String) context.getSessionData(pref + CK.S_COMMAND_TEMP_EVENT); + String event = (String) context.getSessionData(stagePrefix + CK.S_COMMAND_TEMP_EVENT); commandEvents.add(event); commandEventTriggers.add(input.trim()); - context.setSessionData(pref + CK.S_COMMAND_EVENTS, commandEvents); - context.setSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers); + context.setSessionData(stagePrefix + CK.S_COMMAND_EVENTS, commandEvents); + context.setSessionData(stagePrefix + CK.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers); return new EventListPrompt(); } else { LinkedList commandEvents - = (LinkedList) context.getSessionData(pref + CK.S_COMMAND_EVENTS); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_COMMAND_EVENTS); LinkedList commandEventTriggers - = (LinkedList) context.getSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS); - String event = (String) context.getSessionData(pref + CK.S_COMMAND_TEMP_EVENT); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_COMMAND_EVENT_TRIGGERS); + String event = (String) context.getSessionData(stagePrefix + CK.S_COMMAND_TEMP_EVENT); commandEvents.add(event); commandEventTriggers.add(input.trim()); - context.setSessionData(pref + CK.S_COMMAND_EVENTS, commandEvents); - context.setSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers); + context.setSessionData(stagePrefix + CK.S_COMMAND_EVENTS, commandEvents); + context.setSessionData(stagePrefix + CK.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers); return new EventListPrompt(); } } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { @@ -1411,7 +1396,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return new StageMainPrompt(plugin, stageNum, context, factory); } if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_DELAY, null); + context.setSessionData(stagePrefix + CK.S_DELAY, null); player.sendMessage(ChatColor.GREEN + Lang.get("stageEditorDelayCleared")); return new StageMainPrompt(plugin, stageNum, context, factory); } @@ -1427,7 +1412,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { player.sendMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("", "1")); return new DelayPrompt(); } else { - context.setSessionData(pref + CK.S_DELAY, stageDelay); + context.setSessionData(stagePrefix + CK.S_DELAY, stageDelay); return new StageMainPrompt(plugin, stageNum, context, factory); } } @@ -1445,10 +1430,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { Player player = (Player) context.getForWhom(); if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - context.setSessionData(pref + CK.S_DELAY_MESSAGE, input); + context.setSessionData(stagePrefix + CK.S_DELAY_MESSAGE, input); return new StageMainPrompt(plugin, stageNum, context, factory); } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_DELAY_MESSAGE, null); + context.setSessionData(stagePrefix + CK.S_DELAY_MESSAGE, null); player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorMessageCleared")); return new StageMainPrompt(plugin, stageNum, context, factory); } else { @@ -1498,10 +1483,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { Player player = (Player) context.getForWhom(); if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - context.setSessionData(pref + CK.S_START_MESSAGE, input); + context.setSessionData(stagePrefix + CK.S_START_MESSAGE, input); return new StageMainPrompt(plugin, stageNum, context, factory); } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_START_MESSAGE, null); + context.setSessionData(stagePrefix + CK.S_START_MESSAGE, null); player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorMessageCleared")); return new StageMainPrompt(plugin, stageNum, context, factory); } else { @@ -1522,10 +1507,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { Player player = (Player) context.getForWhom(); if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - context.setSessionData(pref + CK.S_COMPLETE_MESSAGE, input); + context.setSessionData(stagePrefix + CK.S_COMPLETE_MESSAGE, input); return new StageMainPrompt(plugin, stageNum, context, factory); } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_COMPLETE_MESSAGE, null); + context.setSessionData(stagePrefix + CK.S_COMPLETE_MESSAGE, null); player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorMessageCleared")); return new StageMainPrompt(plugin, stageNum, context, factory); } else { @@ -1572,21 +1557,21 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { } } if (found != null) { - if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) != null) { + if (context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES) != null) { // The custom objective may already have been added, so let's check that LinkedList list - = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES); LinkedList> datamapList = (LinkedList>) context - .getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA); + .getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA); LinkedList countList - = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_COUNT); if (list.contains(found.getName()) == false) { // Hasn't been added yet, so let's do it list.add(found.getName()); datamapList.addAll(found.getData()); countList.add(-999); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, list); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, datamapList); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES, list); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA, datamapList); } else { // Already added, so inform user context.getForWhom().sendRawMessage(ChatColor.YELLOW @@ -1601,16 +1586,16 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { countList.add(-999); LinkedList list = new LinkedList(); list.add(found.getName()); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, list); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, datamapList); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, countList); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES, list); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA, datamapList); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_COUNT, countList); } // Send user to the count prompt / custom data prompt if there is any needed if (found.canShowCount()) { return new CustomObjectiveCountPrompt(); } if (found.getData().isEmpty() == false) { - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, found + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, found .getDescriptions()); return new ObjectiveCustomDataListPrompt(); } @@ -1619,9 +1604,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { return new CustomObjectivesPrompt(); } } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, null); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, null); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES, null); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA, null); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null); context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorCustomCleared")); } return new StageMainPrompt(plugin, stageNum, context, factory); @@ -1634,7 +1619,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { public String getPromptText(ConversationContext context) { String text = ChatColor.BOLD + "" + ChatColor.AQUA + "- "; @SuppressWarnings("unchecked") - LinkedList list = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES); + LinkedList list = (LinkedList) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES); String objName = list.getLast(); text += objName + " -\n"; CustomObjective found = null; @@ -1656,9 +1641,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { try { int num = Integer.parseInt(input); LinkedList counts - = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT); + = (LinkedList) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_COUNT); counts.set(counts.size() - 1, num); - LinkedList list = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES); + LinkedList list = (LinkedList) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES); String objName = list.getLast(); CustomObjective found = null; for (CustomObjective co : plugin.getCustomObjectives()) { @@ -1668,7 +1653,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { } } if (found != null && found.getData().isEmpty() == false) { - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, found.getDescriptions()); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, found.getDescriptions()); return new ObjectiveCustomDataListPrompt(); } else { return new StageMainPrompt(plugin, stageNum, context, factory); @@ -1687,9 +1672,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @Override public String getPromptText(ConversationContext context) { String text = ChatColor.AQUA + "- "; - LinkedList list = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES); + LinkedList list = (LinkedList) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES); LinkedList> datamapList - = (LinkedList>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA); + = (LinkedList>) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA); String objName = list.getLast(); CustomObjective found = null; for (CustomObjective co : plugin.getCustomObjectives()) { @@ -1724,7 +1709,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @SuppressWarnings("unchecked") @Override public Prompt acceptInput(ConversationContext context, String input) { - LinkedList list = (LinkedList) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES); + LinkedList list = (LinkedList) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES); String objName = list.getLast(); CustomObjective found = null; for (CustomObjective co : plugin.getCustomObjectives()) { @@ -1755,16 +1740,16 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { } // Collections.sort(datamapKeys); String selectedKey = datamapKeys.get(numInput - 1); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, selectedKey); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, selectedKey); return new ObjectiveCustomDataPrompt(); } else { - for (Entry datamap : (LinkedList>) context.getSessionData(pref + for (Entry datamap : (LinkedList>) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA)) { if (datamap.getValue() == null) { return new ObjectiveCustomDataListPrompt(); } } - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, null); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, null); return new StageMainPrompt(plugin, stageNum, context, factory); } } @@ -1775,10 +1760,10 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { @Override public String getPromptText(ConversationContext context) { String text = ""; - String temp = (String) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP); + String temp = (String) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP); @SuppressWarnings("unchecked") Map descriptions - = (Map) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS); + = (Map) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS); if (descriptions.get(temp) != null) { text += ChatColor.GOLD + descriptions.get(temp) + "\n"; } @@ -1792,9 +1777,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { public Prompt acceptInput(ConversationContext context, String input) { @SuppressWarnings("unchecked") LinkedList> datamapList - = (LinkedList>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA); + = (LinkedList>) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA); LinkedList> promptList = new LinkedList>(); - String temp = (String) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP); + String temp = (String) context.getSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP); for (Entry datamap : datamapList) { if (datamap.getKey().equals(temp)) { promptList.add(new AbstractMap.SimpleEntry(datamap.getKey(), input)); @@ -1802,8 +1787,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { promptList.add(new AbstractMap.SimpleEntry(datamap.getKey(), datamap.getValue())); } } - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, promptList); - context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA, promptList); + context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null); return new ObjectiveCustomDataListPrompt(); } } diff --git a/main/src/main/java/me/blackvein/quests/tasks/ActionTimer.java b/main/src/main/java/me/blackvein/quests/tasks/ActionTimer.java index 68da39eb6..19d5d76fc 100644 --- a/main/src/main/java/me/blackvein/quests/tasks/ActionTimer.java +++ b/main/src/main/java/me/blackvein/quests/tasks/ActionTimer.java @@ -14,6 +14,7 @@ package me.blackvein.quests.tasks; import org.bukkit.scheduler.BukkitRunnable; +import de.erethon.dungeonsxl.util.commons.chat.ChatColor; import me.blackvein.quests.Quest; import me.blackvein.quests.Quester; import me.blackvein.quests.util.Lang; @@ -39,8 +40,8 @@ public class ActionTimer extends BukkitRunnable { quest.failQuest(quester); quester.updateJournal(); } else { - quester.getPlayer().sendMessage(Lang.get(quester.getPlayer(), "timerMessage") - .replace("