Supply external conversation hooks, part 21

This commit is contained in:
PikaMug 2020-03-27 22:27:35 -04:00
parent cae987511e
commit 7c3388de9c
4 changed files with 299 additions and 185 deletions

View File

@ -161,8 +161,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
context.setSessionData(pref, Boolean.TRUE); context.setSessionData(pref, Boolean.TRUE);
QuestsEditorPostOpenNumericPromptEvent event QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
context.getPlugin().getServer().getPluginManager().callEvent(event); context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n"; String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";

View File

@ -92,8 +92,8 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
String text = "\n"; String text = "\n";
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS); LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS);
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i))
+ " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n"; + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
} }
return text; return text;
} }
@ -104,8 +104,8 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
String text = "\n"; String text = "\n";
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_SMELT_ITEMS); LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_SMELT_ITEMS);
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i))
+ " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n"; + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
} }
return text; return text;
} }
@ -132,8 +132,8 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
String text = "\n"; String text = "\n";
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_BREW_ITEMS); LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_BREW_ITEMS);
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i))
+ " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n"; + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
} }
return text; return text;
} }
@ -163,8 +163,7 @@ public class ItemsPrompt extends QuestsEditorNumericPrompt {
} }
context.setSessionData(pref, Boolean.TRUE); context.setSessionData(pref, Boolean.TRUE);
QuestsEditorPostOpenNumericPromptEvent event QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
context.getPlugin().getServer().getPluginManager().callEvent(event); context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n"; String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";

View File

@ -31,44 +31,88 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;
import me.blackvein.quests.Quests; 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.CK;
import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil; import me.blackvein.quests.util.MiscUtil;
public class MobsPrompt extends FixedSetPrompt { public class MobsPrompt extends QuestsEditorNumericPrompt {
private final Quests plugin; private final Quests plugin;
private final int stageNum; private final int stageNum;
private final String pref; private final String pref;
public MobsPrompt(int stageNum, ConversationContext context) { public MobsPrompt(int stageNum, ConversationContext context) {
super("1", "2", "3", "4", "5", "6"); super(context);
this.plugin = (Quests)context.getPlugin(); this.plugin = (Quests)context.getPlugin();
this.stageNum = stageNum; this.stageNum = stageNum;
this.pref = "stage" + 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") @SuppressWarnings("unchecked")
@Override public String getAdditionalText(ConversationContext context, int number) {
public String getPromptText(ConversationContext context) { switch(number) {
context.setSessionData(pref, Boolean.TRUE); case 1:
String text = ChatColor.AQUA + "- " + Lang.get("stageEditorMobs") + " -\n";
if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) { if (context.getSessionData(pref + CK.S_MOB_TYPES) == null) {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
+ "- " + Lang.get("stageEditorKillMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else { } else {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE String text = "\n";
+ "- " + Lang.get("stageEditorKillMobs") + "\n";
LinkedList<String> mobs = (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_TYPES); LinkedList<String> mobs = (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_TYPES);
LinkedList<Integer> amnts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_AMOUNTS); LinkedList<Integer> amnts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_AMOUNTS);
if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) { if (context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS) == null) {
for (int i = 0; i < mobs.size(); i++) { for (int i = 0; i < mobs.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA text += ChatColor.GRAY + " - " + ChatColor.AQUA
+ MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY + " x " + MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY
+ ChatColor.DARK_AQUA + amnts.get(i) + "\n"; + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n";
} }
} else { } else {
LinkedList<String> locs = (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS); LinkedList<String> locs
= (LinkedList<String>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS);
LinkedList<Integer> radii LinkedList<Integer> radii
= (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS); = (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS);
LinkedList<String> names LinkedList<String> names
@ -77,80 +121,100 @@ public class MobsPrompt extends FixedSetPrompt {
String msg = Lang.get("blocksWithin"); String msg = Lang.get("blocksWithin");
msg = msg.replace("<amount>", ChatColor.DARK_PURPLE + "" + radii.get(i) + ChatColor.GRAY); msg = msg.replace("<amount>", ChatColor.DARK_PURPLE + "" + radii.get(i) + ChatColor.GRAY);
text += ChatColor.GRAY + " - " + ChatColor.BLUE text += ChatColor.GRAY + " - " + ChatColor.BLUE
+ MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY + " x " + MiscUtil.getPrettyMobName(MiscUtil.getProperMobType(mobs.get(i))) + ChatColor.GRAY
+ ChatColor.DARK_AQUA + amnts.get(i) + ChatColor.GRAY + msg + ChatColor.YELLOW + " x " + ChatColor.DARK_AQUA + amnts.get(i) + ChatColor.GRAY + msg + ChatColor.YELLOW
+ names.get(i) + " (" + locs.get(i) + ")\n"; + names.get(i) + " (" + locs.get(i) + ")\n";
} }
} }
return text;
} }
case 2:
if (context.getSessionData(pref + CK.S_FISH) == null) { if (context.getSessionData(pref + CK.S_FISH) == null) {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
+ "- " + Lang.get("stageEditorCatchFish") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else { } else {
Integer fish = (Integer) context.getSessionData(pref + CK.S_FISH); Integer fish = (Integer) context.getSessionData(pref + CK.S_FISH);
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE return ChatColor.GRAY + "(" + ChatColor.AQUA + fish + " " + Lang.get("stageEditorFish")
+ "- " + Lang.get("stageEditorCatchFish") + " " + ChatColor.GRAY + "(" + ChatColor.AQUA + fish + ChatColor.GRAY + ")\n";
+ " " + Lang.get("stageEditorFish") + ChatColor.GRAY + ")\n";
} }
case 3:
if (context.getSessionData(pref + CK.S_COW_MILK) == null) { if (context.getSessionData(pref + CK.S_COW_MILK) == null) {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
+ "- " + Lang.get("stageEditorMilkCows") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else { } else {
Integer cows = (Integer) context.getSessionData(pref + CK.S_COW_MILK); Integer cows = (Integer) context.getSessionData(pref + CK.S_COW_MILK);
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE return ChatColor.GRAY + "(" + ChatColor.AQUA + cows + " " + Lang.get("stageEditorCows")
+ "- " + Lang.get("stageEditorMilkCows") + " " + ChatColor.GRAY + "(" + ChatColor.AQUA + cows + ChatColor.GRAY + ")\n";
+ " " + Lang.get("stageEditorCows") + ChatColor.GRAY + ")\n";
} }
case 4:
if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) { if (context.getSessionData(pref + CK.S_TAME_TYPES) == null) {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
+ "- " + Lang.get("stageEditorTameMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else { } else {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE String text = "\n";
+ "- " + Lang.get("stageEditorTameMobs") + "\n";
LinkedList<String> mobs = (LinkedList<String>) context.getSessionData(pref + CK.S_TAME_TYPES); LinkedList<String> mobs = (LinkedList<String>) context.getSessionData(pref + CK.S_TAME_TYPES);
LinkedList<Integer> amounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_TAME_AMOUNTS); LinkedList<Integer> amounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_TAME_AMOUNTS);
for (int i = 0; i < mobs.size(); i++) { for (int i = 0; i < mobs.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE + mobs.get(i) + ChatColor.GRAY + " x " text += ChatColor.GRAY + " - " + ChatColor.BLUE + mobs.get(i) + ChatColor.GRAY + " x "
+ ChatColor.AQUA + amounts.get(i) + "\n"; + ChatColor.AQUA + amounts.get(i) + "\n";
} }
return text;
} }
case 5:
if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) { if (context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "5 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
+ "- " + Lang.get("stageEditorShearSheep") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else { } else {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "5 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE String text = "\n";
+ "- " + Lang.get("stageEditorShearSheep") + "\n";
LinkedList<String> colors = (LinkedList<String>) context.getSessionData(pref + CK.S_SHEAR_COLORS); LinkedList<String> colors = (LinkedList<String>) context.getSessionData(pref + CK.S_SHEAR_COLORS);
LinkedList<Integer> amounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS); LinkedList<Integer> amounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS);
for (int i = 0; i < colors.size(); i++) { for (int i = 0; i < colors.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE + colors.get(i) + ChatColor.GRAY + " x " text += ChatColor.GRAY + " - " + ChatColor.BLUE + colors.get(i) + ChatColor.GRAY + " x "
+ ChatColor.AQUA + amounts.get(i) + "\n"; + 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);
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";
} }
text += ChatColor.GREEN + "" + ChatColor.BOLD + "6 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- "
+ Lang.get("done") + "\n";
return text; return text;
} }
@Override @Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) { protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
if (input.equalsIgnoreCase("1")) { switch(input.intValue()) {
case 1:
return new MobListPrompt(); return new MobListPrompt();
} else if (input.equalsIgnoreCase("2")) { case 2:
return new FishPrompt(); return new FishPrompt();
} else if (input.equalsIgnoreCase("3")) { case 3:
return new CowsPrompt(); return new CowsPrompt();
} else if (input.equalsIgnoreCase("4")) { case 4:
return new TameListPrompt(); return new TameListPrompt();
} else if (input.equalsIgnoreCase("5")) { case 5:
return new ShearListPrompt(); return new ShearListPrompt();
} case 6:
try { try {
return new StageMainPrompt(stageNum, context); return new StageMainPrompt(stageNum, context);
} catch (Exception e) { } catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
} }
default:
return null;
}
} }

View File

@ -27,78 +27,110 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import me.blackvein.quests.Quests; 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.CK;
import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.Lang;
public class NPCsPrompt extends FixedSetPrompt { public class NPCsPrompt extends QuestsEditorNumericPrompt {
private final Quests plugin; private final Quests plugin;
private final int stageNum; private final int stageNum;
private final String pref; private final String pref;
public NPCsPrompt(int stageNum, ConversationContext context) { public NPCsPrompt(int stageNum, ConversationContext context) {
super("1", "2", "3", "4"); super(context);
this.plugin = (Quests)context.getPlugin(); this.plugin = (Quests)context.getPlugin();
this.stageNum = stageNum; this.stageNum = stageNum;
this.pref = "stage" + 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") @SuppressWarnings("unchecked")
@Override public String getAdditionalText(ConversationContext context, int number) {
public String getPromptText(ConversationContext context) { switch(number) {
context.setSessionData(pref, Boolean.TRUE); case 1:
String text = ChatColor.AQUA + "- " + Lang.get("stageEditorNPCs") + " -\n";
if (plugin.getDependencies().getCitizens() != null) { if (plugin.getDependencies().getCitizens() != null) {
if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) { if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
+ "- " + Lang.get("stageEditorDeliverItems") + ChatColor.GRAY + " (" + Lang.get("noneSet")
+ ")\n";
} else { } else {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE String text = "\n";
+ "- " + Lang.get("stageEditorDeliverItems") + "\n";
LinkedList<Integer> npcs = (LinkedList<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS); LinkedList<Integer> npcs = (LinkedList<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
LinkedList<ItemStack> items LinkedList<ItemStack> items
= (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_DELIVERY_ITEMS); = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_DELIVERY_ITEMS);
for (int i = 0; i < npcs.size(); i++) { for (int i = 0; i < npcs.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i))
+ ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + ChatColor.GRAY + " " + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + ChatColor.GRAY
+ Lang.get("to") + " " + ChatColor.DARK_AQUA + " " + Lang.get("to") + " " + ChatColor.DARK_AQUA
+ plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName()
+ "\n"; + "\n";
} }
return text;
} }
} else { } else {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.GRAY + "- " return ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") + ")";
+ Lang.get("stageEditorDeliverItems") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled")
+ ")\n";
} }
case 2:
if (plugin.getDependencies().getCitizens() != null) { if (plugin.getDependencies().getCitizens() != null) {
if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null) { if (context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null) {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
+ "- " + Lang.get("stageEditorTalkToNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet")
+ ")\n";
} else { } else {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE String text = "\n";
+ "- " + Lang.get("stageEditorTalkToNPCs") + "\n"; LinkedList<Integer> npcs
LinkedList<Integer> npcs = (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO); = (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO);
for (int i = 0; i < npcs.size(); i++) { for (int i = 0; i < npcs.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE text += ChatColor.GRAY + " - " + ChatColor.BLUE
+ plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName()
+ "\n"; + "\n";
} }
return text;
} }
} else { } else {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.GRAY + "- " return ChatColor.GRAY + "(" + Lang.get("questCitNotInstalled") + ")";
+ Lang.get("stageEditorTalkToNPCs") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled")
+ ")\n";
} }
case 3:
if (plugin.getDependencies().getCitizens() != null) { if (plugin.getDependencies().getCitizens() != null) {
if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) { if (context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
+ "- " + Lang.get("stageEditorKillNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else { } else {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE String text = "\n";
+ "- " + Lang.get("stageEditorKillNPCs") + "\n";
LinkedList<Integer> npcs = (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL); LinkedList<Integer> npcs = (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL);
LinkedList<Integer> amounts LinkedList<Integer> amounts
= (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS); = (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS);
@ -107,47 +139,67 @@ public class NPCsPrompt extends FixedSetPrompt {
+ plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName() + plugin.getDependencies().getCitizens().getNPCRegistry().getById(npcs.get(i)).getName()
+ ChatColor.GRAY + " x " + ChatColor.AQUA + amounts.get(i) + "\n"; + ChatColor.GRAY + " x " + ChatColor.AQUA + amounts.get(i) + "\n";
} }
return text;
} }
} else { } else {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.GRAY + "- " return ChatColor.GRAY + "(" + Lang.get("questCitNotInstalled") + ")";
+ Lang.get("stageEditorKillNPCs") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") }
+ ")\n"; case 4:
return "";
default:
return null;
}
}
@Override
public String getPromptText(ConversationContext context) {
context.setSessionData(pref, Boolean.TRUE);
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";
} }
text += ChatColor.GREEN + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- "
+ Lang.get("done") + "\n";
return text; return text;
} }
@Override @Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) { protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
if (input.equalsIgnoreCase("1")) { switch(input.intValue()) {
case 1:
if (plugin.getDependencies().getCitizens() != null) { if (plugin.getDependencies().getCitizens() != null) {
return new DeliveryListPrompt(); return new DeliveryListPrompt();
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
return new StageMainPrompt(stageNum, context); return new StageMainPrompt(stageNum, context);
} }
} else if (input.equalsIgnoreCase("2")) { case 2:
if (plugin.getDependencies().getCitizens() != null) { if (plugin.getDependencies().getCitizens() != null) {
return new NPCIDsToTalkToPrompt(); return new NPCIDsToTalkToPrompt();
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
return new StageMainPrompt(stageNum, context); return new StageMainPrompt(stageNum, context);
} }
} else if (input.equalsIgnoreCase("3")) { case 3:
if (plugin.getDependencies().getCitizens() != null) { if (plugin.getDependencies().getCitizens() != null) {
return new NPCKillListPrompt(); return new NPCKillListPrompt();
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
return new StageMainPrompt(stageNum, context); return new StageMainPrompt(stageNum, context);
} }
} case 4:
try { try {
return new StageMainPrompt(stageNum, context); return new StageMainPrompt(stageNum, context);
} catch (Exception e) { } catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
} }
default:
return null;
}
} }
private class DeliveryListPrompt extends FixedSetPrompt { private class DeliveryListPrompt extends FixedSetPrompt {