Condense the create stage prompt, part 1. Bump version number

This commit is contained in:
BuildTools 2019-01-30 03:50:05 -05:00
parent 575e4d011d
commit a07718c7d5
6 changed files with 1875 additions and 1731 deletions

View File

@ -3,7 +3,7 @@
<groupId>me.blackvein.quests</groupId>
<artifactId>quests</artifactId>
<version>3.6.1</version>
<version>3.6.2</version>
<name>quests</name>
<url>https://github.com/FlyingPikachu/Quests/</url>
<packaging>jar</packaging>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,515 @@
/*******************************************************************************************************
* Continued by FlyingPikachu/HappyPikachu with permission from _Blackvein_. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************************************/
package me.blackvein.quests.prompts;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.FixedSetPrompt;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class ItemsPrompt extends FixedSetPrompt {
private final Quests plugin;
private final int stageNum;
private final String pref;
private final QuestFactory questFactory;
public ItemsPrompt(Quests plugin, int stageNum, QuestFactory qf) {
super("1", "2", "3");
this.plugin = plugin;
this.stageNum = stageNum;
this.pref = "stage" + stageNum;
this.questFactory = qf;
}
@SuppressWarnings("unchecked")
@Override
public String getPromptText(ConversationContext context) {
context.setSessionData(pref, Boolean.TRUE);
String text = ChatColor.AQUA + "- " + Lang.get("stageEditorItems") + " -\n";
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorEnchantItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "1 " + ChatColor.RESET + ChatColor.DARK_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 + Quester.prettyItemString(names.get(i)) + ChatColor.GRAY + " " + Lang.get("with") + " " + ChatColor.AQUA + Quester.prettyEnchantmentString(Quests.getEnchantment(enchants.get(i))) + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n";
}
}
if (plugin.getDependencies().getCitizens() != null) {
if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDeliverItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "2 " + ChatColor.RESET + ChatColor.DARK_PURPLE + "- " + Lang.get("stageEditorDeliverItems") + "\n";
LinkedList<Integer> npcs = (LinkedList<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
LinkedList<ItemStack> items = (LinkedList<ItemStack>) 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 + "2 " + ChatColor.RESET + ChatColor.GRAY + "- " + Lang.get("stageEditorDeliverItems") + ChatColor.GRAY + " (" + Lang.get("questCitNotInstalled") + ")\n";
}
text += ChatColor.GREEN + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.LIGHT_PURPLE + "- " + Lang.get("done") + "\n";
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new EnchantmentListPrompt();
} else if (input.equalsIgnoreCase("2")) {
if (plugin.getDependencies().getCitizens() != null) {
return new DeliveryListPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
return new ItemsPrompt(plugin, stageNum, questFactory);
}
}
try {
return new CreateStagePrompt(plugin, stageNum, questFactory);
} catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION;
}
}
private class EnchantmentListPrompt extends FixedSetPrompt {
public EnchantmentListPrompt() {
super("1", "2", "3", "4", "5");
}
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.GOLD + "- " + Lang.get("stageEditorEnchantItems") + " -\n";
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetEnchantments") + " (" + Lang.get("noneSet") + ")\n";
text += ChatColor.GRAY + "2 - " + Lang.get("stageEditorSetItemNames") + " (" + Lang.get("stageEditorNoEnchantmentsSet") + ")\n";
text += ChatColor.GRAY + "3 - " + Lang.get("stageEditorSetEnchantAmounts") + " (" + Lang.get("stageEditorNoEnchantmentsSet") + ")\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetEnchantments") + "\n";
for (String s : getEnchantTypes(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
if (context.getSessionData(pref + CK.S_ENCHANT_NAMES) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetItemNames") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetItemNames") + "\n";
for (String s : getEnchantItems(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + Quester.prettyItemString(s) + "\n";
}
}
if (context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetEnchantAmounts") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorSetEnchantAmounts") + "\n";
for (int i : getEnchantAmounts(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n";
}
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
}
return text;
}
@SuppressWarnings("unchecked")
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new EnchantTypesPrompt();
} else if (input.equalsIgnoreCase("2")) {
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoEnchantments"));
return new EnchantmentListPrompt();
} else {
return new EnchantItemsPrompt();
}
} else if (input.equalsIgnoreCase("3")) {
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoEnchantments"));
return new EnchantmentListPrompt();
} else {
return new EnchantAmountsPrompt();
}
} else if (input.equalsIgnoreCase("4")) {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorEnchantmentsCleared"));
context.setSessionData(pref + CK.S_ENCHANT_TYPES, null);
context.setSessionData(pref + CK.S_ENCHANT_NAMES, null);
context.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, null);
return new EnchantmentListPrompt();
} else if (input.equalsIgnoreCase("5")) {
int one;
int two;
int three;
if (context.getSessionData(pref + CK.S_ENCHANT_TYPES) != null) {
one = ((List<String>) context.getSessionData(pref + CK.S_ENCHANT_TYPES)).size();
} else {
one = 0;
}
if (context.getSessionData(pref + CK.S_ENCHANT_NAMES) != null) {
two = ((List<String>) context.getSessionData(pref + CK.S_ENCHANT_NAMES)).size();
} else {
two = 0;
}
if (context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS) != null) {
three = ((List<Integer>) context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS)).size();
} else {
three = 0;
}
if (one == two && two == three) {
return new ItemsPrompt(plugin, stageNum, questFactory);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorEnchantmentNotSameSize"));
return new EnchantmentListPrompt();
}
}
return null;
}
@SuppressWarnings("unchecked")
private List<String> getEnchantTypes(ConversationContext context) {
return (List<String>) context.getSessionData(pref + CK.S_ENCHANT_TYPES);
}
@SuppressWarnings("unchecked")
private List<String> getEnchantItems(ConversationContext context) {
return (List<String>) context.getSessionData(pref + CK.S_ENCHANT_NAMES);
}
@SuppressWarnings("unchecked")
private List<Integer> getEnchantAmounts(ConversationContext context) {
return (List<Integer>) context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS);
}
}
private class EnchantTypesPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.LIGHT_PURPLE + "- " + ChatColor.DARK_PURPLE + Lang.get("stageEditorEnchantments") + ChatColor.LIGHT_PURPLE + " -\n";
for (int i = 0; i < Enchantment.values().length; i++) {
if (i == Enchantment.values().length - 1) {
text += ChatColor.GREEN + Quester.prettyEnchantmentString(Enchantment.values()[i]) + " ";
} else {
text += ChatColor.GREEN + Quester.prettyEnchantmentString(Enchantment.values()[i]) + ", ";
}
}
text = text.substring(0, text.length() - 1);
return text + "\n" + ChatColor.YELLOW + Lang.get("stageEditorEnchantTypePrompt");
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(Lang.get("charSemi"));
LinkedList<String> enchs = new LinkedList<String>();
boolean valid;
for (String s : args) {
s = s.trim();
valid = false;
for (Enchantment e : Enchantment.values()) {
if (Quester.prettyEnchantmentString(e).equalsIgnoreCase(s)) {
if (enchs.contains(s) == false) {
enchs.add(Quester.prettyEnchantmentString(e));
valid = true;
break;
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + " " + Lang.get("stageEditorListContainsDuplicates"));
return new EnchantTypesPrompt();
}
}
}
if (valid == false) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + ChatColor.RED + " " + Lang.get("stageEditorInvalidEnchantment"));
return new EnchantTypesPrompt();
}
}
context.setSessionData(pref + CK.S_ENCHANT_TYPES, enchs);
}
return new EnchantmentListPrompt();
}
}
private class EnchantItemsPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + Lang.get("stageEditorItemNamesPrompt");
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(" ");
LinkedList<String> names = new LinkedList<String>();
for (String s : args) {
try {
if (Material.matchMaterial(s) != null) {
if (names.contains(s) == false) {
names.add(s);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + " " + Lang.get("stageEditorListContainsDuplicates"));
return new EnchantItemsPrompt();
}
} else {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + ChatColor.RED + " " + Lang.get("stageEditorInvalidItemName"));
return new EnchantItemsPrompt();
}
} catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorNotListofNumbers"));
return new EnchantItemsPrompt();
}
}
context.setSessionData(pref + CK.S_ENCHANT_NAMES, names);
}
return new EnchantmentListPrompt();
}
}
private class EnchantAmountsPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + Lang.get("stageEditorEnchantAmountsPrompt");
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(" ");
LinkedList<Integer> amounts = new LinkedList<Integer>();
for (String s : args) {
try {
if (Integer.parseInt(s) > 0) {
amounts.add(Integer.parseInt(s));
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("<number>", "1"));
return new EnchantAmountsPrompt();
}
} catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorNotListofNumbers"));
return new EnchantAmountsPrompt();
}
}
context.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, amounts);
}
return new EnchantmentListPrompt();
}
}
private class DeliveryListPrompt extends FixedSetPrompt {
public DeliveryListPrompt() {
super("1", "2", "3", "4", "5");
}
@Override
public String getPromptText(ConversationContext context) {
// Check/add newly made item
if (context.getSessionData("newItem") != null) {
if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null) {
List<ItemStack> itemRews = getItems(context);
itemRews.add((ItemStack) context.getSessionData("tempStack"));
context.setSessionData(pref + CK.S_DELIVERY_ITEMS, itemRews);
} else {
LinkedList<ItemStack> itemRews = new LinkedList<ItemStack>();
itemRews.add((ItemStack) context.getSessionData("tempStack"));
context.setSessionData(pref + CK.S_DELIVERY_ITEMS, itemRews);
}
context.setSessionData("newItem", null);
context.setSessionData("tempStack", null);
}
String text = ChatColor.GOLD + "- " + Lang.get("stageEditorDeliverItems") + " -\n";
if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) {
text += ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryAddItem") + "\n";
text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorDeliveryNPCs") + " (" + Lang.get("stageEditorNoItemsSet") + ")\n";
if (context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorDeliveryMessages") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorDeliveryMessages") + "\n";
for (String s : getDeliveryMessages(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + "\"" + s + "\"";
}
}
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryAddItem") + "\n";
for (ItemStack is : getItems(context)) {
text += ChatColor.GRAY + " - " + ItemUtil.getDisplayString(is) + "\n";
}
if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryNPCs") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryNPCs") + "\n";
for (int i : getDeliveryNPCs(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + " (" + plugin.getDependencies().getCitizens().getNPCRegistry().getById(i).getName() + ")\n";
}
}
if (context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorDeliveryMessages") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("stageEditorDeliveryMessages") + "\n";
for (String s : getDeliveryMessages(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + "\"" + s + "\"\n";
}
}
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
return text;
}
@SuppressWarnings("unchecked")
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new ItemStackPrompt(DeliveryListPrompt.this);
} else if (input.equalsIgnoreCase("2")) {
if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoItems"));
return new DeliveryListPrompt();
} else {
return new DeliveryNPCsPrompt();
}
} else if (input.equalsIgnoreCase("3")) {
return new DeliveryMessagesPrompt();
} else if (input.equalsIgnoreCase("4")) {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorDeliveriesCleared"));
context.setSessionData(pref + CK.S_DELIVERY_ITEMS, null);
context.setSessionData(pref + CK.S_DELIVERY_NPCS, null);
context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, null);
return new DeliveryListPrompt();
} else if (input.equalsIgnoreCase("5")) {
int one;
int two;
if (context.getSessionData(pref + CK.S_DELIVERY_ITEMS) != null) {
one = ((List<ItemStack>) context.getSessionData(pref + CK.S_DELIVERY_ITEMS)).size();
} else {
one = 0;
}
if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null) {
two = ((List<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS)).size();
} else {
two = 0;
}
if (one == two) {
if (context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) == null && one != 0) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDeliveryMessage"));
return new DeliveryListPrompt();
} else {
return new ItemsPrompt(plugin, stageNum, questFactory);
}
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorDeliveriesNotSameSize"));
return new DeliveryListPrompt();
}
}
return null;
}
@SuppressWarnings("unchecked")
private List<ItemStack> getItems(ConversationContext context) {
return (List<ItemStack>) context.getSessionData(pref + CK.S_DELIVERY_ITEMS);
}
@SuppressWarnings("unchecked")
private List<Integer> getDeliveryNPCs(ConversationContext context) {
return (List<Integer>) context.getSessionData(pref + CK.S_DELIVERY_NPCS);
}
@SuppressWarnings("unchecked")
private List<String> getDeliveryMessages(ConversationContext context) {
return (List<String>) context.getSessionData(pref + CK.S_DELIVERY_MESSAGES);
}
}
private class DeliveryNPCsPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
HashSet<Player> temp = questFactory.getSelectingNpcs();
temp.add((Player) context.getForWhom());
questFactory.setSelectingNpcs(temp);
return ChatColor.YELLOW + Lang.get("stageEditorNPCPrompt") + "\n" + ChatColor.GOLD + Lang.get("npcHint");
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(" ");
LinkedList<Integer> npcs = new LinkedList<Integer>();
for (String s : args) {
try {
Integer i = Integer.parseInt(s);
if (plugin.getDependencies().getCitizens().getNPCRegistry().getById(i) != null) {
npcs.add(i);
} else {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + "" + i + ChatColor.RED + " " + Lang.get("stageEditorInvalidNPC"));
return new DeliveryNPCsPrompt();
}
} catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("stageEditorNotListofNumbers"));
return new DeliveryNPCsPrompt();
}
}
context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs);
}
HashSet<Player> temp = questFactory.getSelectingNpcs();
temp.remove((Player) context.getForWhom());
questFactory.setSelectingNpcs(temp);
return new DeliveryListPrompt();
}
}
private class DeliveryMessagesPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
String note = ChatColor.GOLD + Lang.get("stageEditorNPCNote");
return ChatColor.YELLOW + Lang.get("stageEditorDeliveryMessagesPrompt") + "\n" + note;
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(Lang.get("charSemi"));
LinkedList<String> messages = new LinkedList<String>();
messages.addAll(Arrays.asList(args));
context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, messages);
}
return new DeliveryListPrompt();
}
}
}

View File

@ -58,9 +58,9 @@ public class StagesPrompt extends StringPrompt {
if (i < 0) {
return new StagesPrompt(plugin, questFactory);
} else if (i < (stages + 1) && i > 0) {
return new CreateStagePrompt(plugin, (i), questFactory, plugin.getDependencies().getCitizens());
return new CreateStagePrompt(plugin, (i), questFactory);
} else if (i == (stages + 1)) {
return new CreateStagePrompt(plugin, (stages + 1), questFactory, plugin.getDependencies().getCitizens());
return new CreateStagePrompt(plugin, (stages + 1), questFactory);
} else if (i == (stages + 2)) {
return questFactory.returnToMenu();
} else {

View File

@ -109,11 +109,13 @@ stageEditorEditStage: "Edit Stage"
stageEditorNewStage: "Add new Stage"
stageEditorStages: "Stages"
stageEditorStage: "Stage"
stageEditorBlocks: "Blocks"
stageEditorBreakBlocks: "Break blocks"
stageEditorDamageBlocks: "Damage blocks"
stageEditorPlaceBlocks: "Place blocks"
stageEditorUseBlocks: "Use blocks"
stageEditorCutBlocks: "Cut blocks"
stageEditorItems: "Items"
stageEditorCatchFish: "Catch fish"
stageEditorFish: "fish"
stageEditorKillPlayers: "Kill players"
@ -173,7 +175,7 @@ stageEditorSetLocationNames: "Set location names"
stageEditorSetTameAmounts: "Set tame amounts"
stageEditorSetShearColors: "Set sheep colors"
stageEditorSetShearAmounts: "Set shear amounts"
stageEditorPassword: "Password objectives"
stageEditorPassword: "Password"
stageEditorAddPasswordDisplay: "Add password display"
stageEditorAddPasswordPhrases: "Add password phrase(s)"
stageEditorNoPasswordDisplays: "No password displays set"