diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/BlocksPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/BlocksPrompt.java index 13e444186..182b50f91 100644 --- a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/BlocksPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/BlocksPrompt.java @@ -161,8 +161,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt { public String getPromptText(ConversationContext context) { context.setSessionData(pref, Boolean.TRUE); - QuestsEditorPostOpenNumericPromptEvent event - = new QuestsEditorPostOpenNumericPromptEvent(context, this); + QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this); context.getPlugin().getServer().getPluginManager().callEvent(event); String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n"; diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/ItemsPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/ItemsPrompt.java index 68f455e1a..b1eb3e833 100644 --- a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/ItemsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/ItemsPrompt.java @@ -87,31 +87,31 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt { switch(number) { case 1: if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null) { - return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")"; + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { String text = "\n"; LinkedList items = (LinkedList) context.getSessionData(pref + CK.S_CRAFT_ITEMS); for (int i = 0; i < items.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY - + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n"; + text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n"; } return text; } case 2: if (context.getSessionData(pref + CK.S_SMELT_ITEMS) == null) { - return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")"; + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { String text = "\n"; LinkedList items = (LinkedList) context.getSessionData(pref + CK.S_SMELT_ITEMS); for (int i = 0; i < items.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY - + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n"; + text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n"; } return text; } case 3: if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) { - return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")"; + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { String text = "\n"; LinkedList enchants = (LinkedList) context.getSessionData(pref + CK.S_ENCHANT_TYPES); @@ -127,13 +127,13 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt { } case 4: if (context.getSessionData(pref + CK.S_BREW_ITEMS) == null) { - return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")"; + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; } else { String text = "\n"; LinkedList items = (LinkedList) context.getSessionData(pref + CK.S_BREW_ITEMS); for (int i = 0; i < items.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY - + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n"; + text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n"; } return text; } @@ -163,8 +163,7 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt { } context.setSessionData(pref, Boolean.TRUE); - QuestsEditorPostOpenNumericPromptEvent event - = new QuestsEditorPostOpenNumericPromptEvent(context, this); + QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this); context.getPlugin().getServer().getPluginManager().callEvent(event); String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n"; diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/MobsPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/MobsPrompt.java index 0037a65fe..70973c22c 100644 --- a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/MobsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/MobsPrompt.java @@ -31,125 +31,189 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Tameable; import me.blackvein.quests.Quests; +import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent; import me.blackvein.quests.util.CK; import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.MiscUtil; -public class MobsPrompt extends FixedSetPrompt { +public class MobsPrompt extends QuestsEditorNumericPrompt { private final Quests plugin; private final int stageNum; private final String pref; public MobsPrompt(int stageNum, ConversationContext context) { - super("1", "2", "3", "4", "5", "6"); + super(context); this.plugin = (Quests)context.getPlugin(); this.stageNum = stageNum; this.pref = "stage" + stageNum; } - + + private final int size = 6; + + public int getSize() { + return size; + } + + public String getTitle(ConversationContext context) { + return Lang.get("stageEditorMobs"); + } + + public ChatColor getNumberColor(ConversationContext context, int number) { + switch (number) { + case 1: + case 2: + case 3: + case 4: + case 5: + return ChatColor.BLUE; + case 6: + return ChatColor.GREEN; + default: + return null; + } + } + + public String getSelectionText(ConversationContext context, int number) { + switch(number) { + case 1: + return ChatColor.YELLOW + Lang.get("stageEditorKillMobs"); + case 2: + return ChatColor.YELLOW + Lang.get("stageEditorCatchFish"); + case 3: + return ChatColor.YELLOW + Lang.get("stageEditorMilkCows"); + case 4: + return ChatColor.YELLOW + Lang.get("stageEditorTameMobs"); + case 5: + return ChatColor.YELLOW + Lang.get("stageEditorShearSheep"); + case 6: + return ChatColor.GREEN + Lang.get("done"); + default: + return null; + } + } + @SuppressWarnings("unchecked") + public String getAdditionalText(ConversationContext context, int number) { + switch(number) { + case 1: + if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = "\n"; + LinkedList mobs = (LinkedList) context.getSessionData(pref + CK.S_MOB_TYPES); + LinkedList amnts = (LinkedList) context.getSessionData(pref + CK.S_MOB_AMOUNTS); + if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { + for (int i = 0; i < mobs.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + + MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY + + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n"; + } + } else { + LinkedList locs + = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS); + LinkedList radii + = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS); + LinkedList names + = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES); + for (int i = 0; i < mobs.size(); i++) { + String msg = Lang.get("blocksWithin"); + msg = msg.replace("", ChatColor.DARK_PURPLE + "" + radii.get(i) + ChatColor.GRAY); + text += ChatColor.GRAY + " - " + ChatColor.BLUE + + MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY + + " x " + ChatColor.DARK_AQUA + amnts.get(i) + ChatColor.GRAY + msg + ChatColor.YELLOW + + names.get(i) + " (" + locs.get(i) + ")\n"; + } + } + return text; + } + case 2: + if (context.getSessionData(pref + CK.S_FISH) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + Integer fish = (Integer) context.getSessionData(pref + CK.S_FISH); + return ChatColor.GRAY + "(" + ChatColor.AQUA + fish + " " + Lang.get("stageEditorFish") + + ChatColor.GRAY + ")\n"; + } + case 3: + if (context.getSessionData(pref + CK.S_COW_MILK) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + Integer cows = (Integer) context.getSessionData(pref + CK.S_COW_MILK); + return ChatColor.GRAY + "(" + ChatColor.AQUA + cows + " " + Lang.get("stageEditorCows") + + ChatColor.GRAY + ")\n"; + } + case 4: + if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = "\n"; + LinkedList mobs = (LinkedList) context.getSessionData(pref + CK.S_TAME_TYPES); + LinkedList amounts = (LinkedList) context.getSessionData(pref + CK.S_TAME_AMOUNTS); + for (int i = 0; i < mobs.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + mobs.get(i) + ChatColor.GRAY + " x " + + ChatColor.AQUA + amounts.get(i) + "\n"; + } + return text; + } + case 5: + if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = "\n"; + LinkedList colors = (LinkedList) context.getSessionData(pref + CK.S_SHEAR_COLORS); + LinkedList amounts = (LinkedList) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS); + for (int i = 0; i < colors.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + colors.get(i) + ChatColor.GRAY + " x " + + ChatColor.AQUA + amounts.get(i) + "\n"; + } + return text; + } + case 6: + return ""; + default: + return null; + } + } + @Override public String getPromptText(ConversationContext context) { context.setSessionData(pref, Boolean.TRUE); - String text = ChatColor.AQUA + "- " + Lang.get("stageEditorMobs") + " -\n"; - if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorKillMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorKillMobs") + "\n"; - LinkedList mobs = (LinkedList) context.getSessionData(pref + CK.S_MOB_TYPES); - LinkedList amnts = (LinkedList) context.getSessionData(pref + CK.S_MOB_AMOUNTS); - if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { - for (int i = 0; i < mobs.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA - + MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY + " x " - + ChatColor.DARK_AQUA + amnts.get(i) + "\n"; - } - } else { - LinkedList locs = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS); - LinkedList radii - = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS); - LinkedList names - = (LinkedList) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES); - for (int i = 0; i < mobs.size(); i++) { - String msg = Lang.get("blocksWithin"); - msg = msg.replace("", ChatColor.DARK_PURPLE + "" + radii.get(i) + ChatColor.GRAY); - text += ChatColor.GRAY + " - " + ChatColor.BLUE - + MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY + " x " - + ChatColor.DARK_AQUA + amnts.get(i) + ChatColor.GRAY + msg + ChatColor.YELLOW - + names.get(i) + " (" + locs.get(i) + ")\n"; - } - } + + QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this); + context.getPlugin().getServer().getPluginManager().callEvent(event); + + String text = ChatColor.AQUA + "- " + 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"; } - if (context.getSessionData(pref + CK.S_FISH) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorCatchFish") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - Integer fish = (Integer) context.getSessionData(pref + CK.S_FISH); - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorCatchFish") + " " + ChatColor.GRAY + "(" + ChatColor.AQUA + fish - + " " + Lang.get("stageEditorFish") + ChatColor.GRAY + ")\n"; - } - if (context.getSessionData(pref + CK.S_COW_MILK) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorMilkCows") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - Integer cows = (Integer) context.getSessionData(pref + CK.S_COW_MILK); - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorMilkCows") + " " + ChatColor.GRAY + "(" + ChatColor.AQUA + cows - + " " + Lang.get("stageEditorCows") + ChatColor.GRAY + ")\n"; - } - if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorTameMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorTameMobs") + "\n"; - LinkedList mobs = (LinkedList) context.getSessionData(pref + CK.S_TAME_TYPES); - LinkedList amounts = (LinkedList) context.getSessionData(pref + CK.S_TAME_AMOUNTS); - for (int i = 0; i < mobs.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + mobs.get(i) + ChatColor.GRAY + " x " - + ChatColor.AQUA + amounts.get(i) + "\n"; - } - } - if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "5 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorShearSheep") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "5 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorShearSheep") + "\n"; - LinkedList colors = (LinkedList) context.getSessionData(pref + CK.S_SHEAR_COLORS); - LinkedList amounts = (LinkedList) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS); - for (int i = 0; i < colors.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + colors.get(i) + ChatColor.GRAY + " x " - + ChatColor.AQUA + amounts.get(i) + "\n"; - } - } - text += ChatColor.GREEN + "" + ChatColor.BOLD + "6 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " - + Lang.get("done") + "\n"; return text; } @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + switch(input.intValue()) { + case 1: return new MobListPrompt(); - } else if (input.equalsIgnoreCase("2")) { + case 2: return new FishPrompt(); - } else if (input.equalsIgnoreCase("3")) { + case 3: return new CowsPrompt(); - } else if (input.equalsIgnoreCase("4")) { + case 4: return new TameListPrompt(); - } else if (input.equalsIgnoreCase("5")) { + case 5: return new ShearListPrompt(); - } - try { - return new StageMainPrompt(stageNum, context); - } catch (Exception e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError")); - return Prompt.END_OF_CONVERSATION; + case 6: + try { + return new StageMainPrompt(stageNum, context); + } catch (Exception e) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError")); + return Prompt.END_OF_CONVERSATION; + } + default: + return null; } } diff --git a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/NPCsPrompt.java b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/NPCsPrompt.java index d80d6517c..463280abd 100644 --- a/main/src/main/java/me/blackvein/quests/convo/quests/prompts/NPCsPrompt.java +++ b/main/src/main/java/me/blackvein/quests/convo/quests/prompts/NPCsPrompt.java @@ -27,126 +27,178 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import me.blackvein.quests.Quests; +import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt; +import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent; import me.blackvein.quests.util.CK; import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.Lang; -public class NPCsPrompt extends FixedSetPrompt { +public class NPCsPrompt extends QuestsEditorNumericPrompt { private final Quests plugin; private final int stageNum; private final String pref; public NPCsPrompt(int stageNum, ConversationContext context) { - super("1", "2", "3", "4"); + super(context); this.plugin = (Quests)context.getPlugin(); this.stageNum = stageNum; this.pref = "stage" + stageNum; } - + + private final int size = 4; + + public int getSize() { + return size; + } + + public String getTitle(ConversationContext context) { + return Lang.get("stageEditorNPCs"); + } + + public ChatColor getNumberColor(ConversationContext context, int number) { + switch (number) { + case 1: + case 2: + case 3: + return ChatColor.BLUE; + case 4: + return ChatColor.GREEN; + default: + return null; + } + } + + public String getSelectionText(ConversationContext context, int number) { + switch(number) { + case 1: + return ChatColor.YELLOW + Lang.get("stageEditorDeliverItems"); + case 2: + return ChatColor.YELLOW + Lang.get("stageEditorTalkToNPCs"); + case 3: + return ChatColor.YELLOW + Lang.get("stageEditorKillNPCs"); + case 4: + return ChatColor.GREEN + Lang.get("done"); + default: + return null; + } + } + @SuppressWarnings("unchecked") + public String getAdditionalText(ConversationContext context, int number) { + switch(number) { + case 1: + if (plugin.getDependencies().getCitizens() != null) { + if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = "\n"; + LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_DELIVERY_NPCS); + LinkedList items + = (LinkedList) context.getSessionData(pref + CK.S_DELIVERY_ITEMS); + for (int i = 0; i < npcs.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + ChatColor.GRAY + + " " + Lang.get("to") + " " + ChatColor.DARK_AQUA + + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() + + "\n"; + } + return text; + } + } else { + return ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") + ")"; + } + case 2: + if (plugin.getDependencies().getCitizens() != null) { + if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = "\n"; + LinkedList npcs + = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO); + for (int i = 0; i < npcs.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() + + "\n"; + } + return text; + } + } else { + return ChatColor.GRAY + "(" + Lang.get("questCitNotInstalled") + ")"; + } + case 3: + if (plugin.getDependencies().getCitizens() != null) { + if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { + return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")"; + } else { + String text = "\n"; + LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_KILL); + LinkedList amounts + = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS); + for (int i = 0; i < npcs.size(); i++) { + text += ChatColor.GRAY + " - " + ChatColor.BLUE + + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() + + ChatColor.GRAY + " x " + ChatColor.AQUA + amounts.get(i) + "\n"; + } + return text; + } + } else { + return ChatColor.GRAY + "(" + Lang.get("questCitNotInstalled") + ")"; + } + case 4: + return ""; + default: + return null; + } + } + @Override public String getPromptText(ConversationContext context) { context.setSessionData(pref, Boolean.TRUE); - String text = ChatColor.AQUA + "- " + Lang.get("stageEditorNPCs") + " -\n"; - if (plugin.getDependencies().getCitizens() != null) { - if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorDeliverItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") - + ")\n"; - } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorDeliverItems") + "\n"; - LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_DELIVERY_NPCS); - LinkedList items - = (LinkedList) context.getSessionData(pref + CK.S_DELIVERY_ITEMS); - for (int i = 0; i < npcs.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) - + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + ChatColor.GRAY + " " - + Lang.get("to") + " " + ChatColor.DARK_AQUA - + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() - + "\n"; - } - } - } else { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.GRAY + "- " - + Lang.get("stageEditorDeliverItems") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") - + ")\n"; + + QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this); + context.getPlugin().getServer().getPluginManager().callEvent(event); + + String text = ChatColor.AQUA + "- " + 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"; } - if (plugin.getDependencies().getCitizens() != null) { - if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorTalkToNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") - + ")\n"; - } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorTalkToNPCs") + "\n"; - LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO); - for (int i = 0; i < npcs.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE - + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() - + "\n"; - } - } - } else { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.GRAY + "- " - + Lang.get("stageEditorTalkToNPCs") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") - + ")\n"; - } - if (plugin.getDependencies().getCitizens() != null) { - if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorKillNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE - + "- " + Lang.get("stageEditorKillNPCs") + "\n"; - LinkedList npcs = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_KILL); - LinkedList amounts - = (LinkedList) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS); - for (int i = 0; i < npcs.size(); i++) { - text += ChatColor.GRAY + " - " + ChatColor.BLUE - + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() - + ChatColor.GRAY + " x " + ChatColor.AQUA + amounts.get(i) + "\n"; - } - } - } else { - text += ChatColor.GRAY + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.GRAY + "- " - + Lang.get("stageEditorKillNPCs") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") - + ")\n"; - } - text += ChatColor.GREEN + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " - + Lang.get("done") + "\n"; return text; } @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - if (input.equalsIgnoreCase("1")) { + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + switch(input.intValue()) { + case 1: if (plugin.getDependencies().getCitizens() != null) { return new DeliveryListPrompt(); } else { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); return new StageMainPrompt(stageNum, context); } - } else if (input.equalsIgnoreCase("2")) { + case 2: if (plugin.getDependencies().getCitizens() != null) { return new NPCIDsToTalkToPrompt(); } else { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); return new StageMainPrompt(stageNum, context); } - } else if (input.equalsIgnoreCase("3")) { + case 3: if (plugin.getDependencies().getCitizens() != null) { return new NPCKillListPrompt(); } else { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); return new StageMainPrompt(stageNum, context); } - } - try { - return new StageMainPrompt(stageNum, context); - } catch (Exception e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError")); - return Prompt.END_OF_CONVERSATION; + case 4: + try { + return new StageMainPrompt(stageNum, context); + } catch (Exception e) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError")); + return Prompt.END_OF_CONVERSATION; + } + default: + return null; } }