mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-14 14:45:41 +01:00
Supply external conversation hooks, part 20
This commit is contained in:
parent
f752ab2d16
commit
61f9979d87
@ -86,7 +86,6 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
|
|||||||
public String getAdditionalText(ConversationContext context, int number) {
|
public String getAdditionalText(ConversationContext context, int number) {
|
||||||
switch(number) {
|
switch(number) {
|
||||||
case 1:
|
case 1:
|
||||||
System.out.println("block= " + context.getSessionData(pref + CK.S_BREAK_NAMES));
|
|
||||||
if (context.getSessionData(pref + CK.S_BREAK_NAMES) == null) {
|
if (context.getSessionData(pref + CK.S_BREAK_NAMES) == null) {
|
||||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,6 +15,8 @@ package me.blackvein.quests.convo.quests.prompts;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
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;
|
||||||
@ -29,16 +31,119 @@ import org.bukkit.conversations.StringPrompt;
|
|||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class ItemsPrompt extends FixedSetPrompt {
|
public class ItemsPrompt extends QuestsEditorNumericPrompt {
|
||||||
private final int stageNum;
|
private final int stageNum;
|
||||||
private final String pref;
|
private final String pref;
|
||||||
|
|
||||||
public ItemsPrompt(int stageNum) {
|
public ItemsPrompt(int stageNum, ConversationContext context) {
|
||||||
super("1", "2", "3", "4", "5");
|
super(context);
|
||||||
this.stageNum = stageNum;
|
this.stageNum = stageNum;
|
||||||
this.pref = "stage" + stageNum;
|
this.pref = "stage" + stageNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final int size = 5;
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle(ConversationContext context) {
|
||||||
|
return Lang.get("stageEditorItems");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getNumberColor(ConversationContext context, int number) {
|
||||||
|
switch (number) {
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
return ChatColor.BLUE;
|
||||||
|
case 5:
|
||||||
|
return ChatColor.GREEN;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectionText(ConversationContext context, int number) {
|
||||||
|
switch(number) {
|
||||||
|
case 1:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorCraftItems");
|
||||||
|
case 2:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorSmeltItems");
|
||||||
|
case 3:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorEnchantItems");
|
||||||
|
case 4:
|
||||||
|
return ChatColor.YELLOW + Lang.get("stageEditorBrewPotions");
|
||||||
|
case 5:
|
||||||
|
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_CRAFT_ITEMS) == null) {
|
||||||
|
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\n";
|
||||||
|
LinkedList<ItemStack> items = (LinkedList<ItemStack>) 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";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
if (context.getSessionData(pref + CK.S_SMELT_ITEMS) == null) {
|
||||||
|
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\n";
|
||||||
|
LinkedList<ItemStack> items = (LinkedList<ItemStack>) 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";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
|
||||||
|
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\n";
|
||||||
|
LinkedList<String> enchants = (LinkedList<String>) context.getSessionData(pref + CK.S_ENCHANT_TYPES);
|
||||||
|
LinkedList<String> names = (LinkedList<String>) context.getSessionData(pref + CK.S_ENCHANT_NAMES);
|
||||||
|
LinkedList<Integer> amnts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS);
|
||||||
|
for (int i = 0; i < enchants.size(); i++) {
|
||||||
|
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getPrettyItemName(names.get(i))
|
||||||
|
+ ChatColor.GRAY + " " + Lang.get("with") + " " + ChatColor.AQUA
|
||||||
|
+ ItemUtil.getPrettyEnchantmentName(ItemUtil.getEnchantmentFromProperName(enchants.get(i)))
|
||||||
|
+ ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
case 4:
|
||||||
|
if (context.getSessionData(pref + CK.S_BREW_ITEMS) == null) {
|
||||||
|
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
||||||
|
} else {
|
||||||
|
String text = "\n";
|
||||||
|
LinkedList<ItemStack> items = (LinkedList<ItemStack>) 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";
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
|
return "";
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public String getPromptText(ConversationContext context) {
|
public String getPromptText(ConversationContext context) {
|
||||||
@ -57,80 +162,39 @@ public class ItemsPrompt extends FixedSetPrompt {
|
|||||||
context.setSessionData("tempStack", null);
|
context.setSessionData("tempStack", null);
|
||||||
}
|
}
|
||||||
context.setSessionData(pref, Boolean.TRUE);
|
context.setSessionData(pref, Boolean.TRUE);
|
||||||
String text = ChatColor.AQUA + "- " + Lang.get("stageEditorItems") + " -\n";
|
|
||||||
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null) {
|
QuestsEditorPostOpenNumericPromptEvent event
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
||||||
+ "- " + Lang.get("stageEditorCraftItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||||
} else {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
|
||||||
+ "- " + Lang.get("stageEditorCraftItems") + "\n";
|
for (int i = 1; i <= size; i++) {
|
||||||
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(pref + CK.S_CRAFT_ITEMS);
|
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||||
for (int i = 0; i < items.size(); i++) {
|
+ getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
||||||
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY
|
|
||||||
+ " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (context.getSessionData(pref + CK.S_SMELT_ITEMS) == null) {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorSmeltItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
|
||||||
} else {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorSmeltItems") + "\n";
|
|
||||||
LinkedList<ItemStack> items = (LinkedList<ItemStack>) 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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorEnchantItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
|
||||||
} else {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorEnchantItems") + "\n";
|
|
||||||
LinkedList<String> enchants = (LinkedList<String>) context.getSessionData(pref + CK.S_ENCHANT_TYPES);
|
|
||||||
LinkedList<String> names = (LinkedList<String>) context.getSessionData(pref + CK.S_ENCHANT_NAMES);
|
|
||||||
LinkedList<Integer> amnts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS);
|
|
||||||
for (int i = 0; i < enchants.size(); i++) {
|
|
||||||
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getPrettyItemName(names.get(i))
|
|
||||||
+ ChatColor.GRAY + " " + Lang.get("with") + " " + ChatColor.AQUA
|
|
||||||
+ ItemUtil.getPrettyEnchantmentName(ItemUtil.getEnchantmentFromProperName(enchants.get(i)))
|
|
||||||
+ ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (context.getSessionData(pref + CK.S_BREW_ITEMS) == null) {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorBrewPotions") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
|
||||||
} else {
|
|
||||||
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE
|
|
||||||
+ "- " + Lang.get("stageEditorBrewPotions") + "\n";
|
|
||||||
LinkedList<ItemStack> items = (LinkedList<ItemStack>) 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.GREEN + "" + ChatColor.BOLD + "5 " + 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 CraftListPrompt();
|
return new CraftListPrompt();
|
||||||
} else if (input.equalsIgnoreCase("2")) {
|
case 2:
|
||||||
return new SmeltListPrompt();
|
return new SmeltListPrompt();
|
||||||
} else if (input.equalsIgnoreCase("3")) {
|
case 3:
|
||||||
return new EnchantmentListPrompt();
|
return new EnchantmentListPrompt();
|
||||||
} else if (input.equalsIgnoreCase("4")) {
|
case 4:
|
||||||
return new BrewListPrompt();
|
return new BrewListPrompt();
|
||||||
}
|
case 5:
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +248,7 @@ public class ItemsPrompt extends FixedSetPrompt {
|
|||||||
context.setSessionData(pref + CK.S_CRAFT_ITEMS, null);
|
context.setSessionData(pref + CK.S_CRAFT_ITEMS, null);
|
||||||
return new CraftListPrompt();
|
return new CraftListPrompt();
|
||||||
} else if (input.equalsIgnoreCase("3")) {
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
return new ItemsPrompt(stageNum);
|
return new ItemsPrompt(stageNum, context);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -245,7 +309,7 @@ public class ItemsPrompt extends FixedSetPrompt {
|
|||||||
context.setSessionData(pref + CK.S_SMELT_ITEMS, null);
|
context.setSessionData(pref + CK.S_SMELT_ITEMS, null);
|
||||||
return new SmeltListPrompt();
|
return new SmeltListPrompt();
|
||||||
} else if (input.equalsIgnoreCase("3")) {
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
return new ItemsPrompt(stageNum);
|
return new ItemsPrompt(stageNum, context);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -355,7 +419,7 @@ public class ItemsPrompt extends FixedSetPrompt {
|
|||||||
three = 0;
|
three = 0;
|
||||||
}
|
}
|
||||||
if (one == two && two == three) {
|
if (one == two && two == three) {
|
||||||
return new ItemsPrompt(stageNum);
|
return new ItemsPrompt(stageNum, context);
|
||||||
} else {
|
} else {
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
|
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
|
||||||
return new EnchantmentListPrompt();
|
return new EnchantmentListPrompt();
|
||||||
@ -543,7 +607,7 @@ public class ItemsPrompt extends FixedSetPrompt {
|
|||||||
context.setSessionData(pref + CK.S_BREW_ITEMS, null);
|
context.setSessionData(pref + CK.S_BREW_ITEMS, null);
|
||||||
return new BrewListPrompt();
|
return new BrewListPrompt();
|
||||||
} else if (input.equalsIgnoreCase("3")) {
|
} else if (input.equalsIgnoreCase("3")) {
|
||||||
return new ItemsPrompt(stageNum);
|
return new ItemsPrompt(stageNum, context);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
|
|||||||
case 1:
|
case 1:
|
||||||
return new BlocksPrompt(stageNum, context);
|
return new BlocksPrompt(stageNum, context);
|
||||||
case 2:
|
case 2:
|
||||||
return new ItemsPrompt(stageNum);
|
return new ItemsPrompt(stageNum, context);
|
||||||
case 3:
|
case 3:
|
||||||
return new NPCsPrompt(stageNum, context);
|
return new NPCsPrompt(stageNum, context);
|
||||||
case 4:
|
case 4:
|
||||||
|
Loading…
Reference in New Issue
Block a user